Skip to content
This repository was archived by the owner on Sep 6, 2021. It is now read-only.

Commit bb0aac0

Browse files
Subhash Jhashubhsnov
authored andcommitted
Language Server Protocol Support for Brackets (#14606)
* LSP Initial set of changes * Adding comments and a bit of cleanup * Adding php client for lsp * further cleanup * removing dependency on HintUtils * removing phpClient extension from this branch * Cleanup * fixing eslint errors * Refactoring code- Removing dependency on JSUtils ANd adding basic structure for client capabilities * Bug Fix: too many listeners were getting attached to node process + code cleanup * putting null check and settign capabilities to default values * reinitializing server on workspace change and moving out capabilities from client code * cleanup * First cut for LSP support in Brackets * First cut for LSP support in Brackets * Adding client infrastructure * Adding client infrastructure * Adding handlers on Language Client Proxy, fixing eslint errors * Adding handlers on Language Client Proxy, fixing eslint errors * Fixing protocol adapter * Fixing protocol adapter * Fix typo * Fix typo * Removing older implementation * Removing older implementation * Added error checks to the auto update mechanism. So in case the auto update mechansim fails, we will now give chance to the default update process Handler to handle the update mechanism (Which is essentially taking the user to brackets.io). (#14605) * First cut for LSP support in Brackets * First cut for LSP support in Brackets * Adding client infrastructure * Adding client infrastructure * Adding handlers on Language Client Proxy, fixing eslint errors * Adding handlers on Language Client Proxy, fixing eslint errors * Fixing protocol adapter * Fixing protocol adapter * Fix typo * Fix typo * Removing older implementation * Removing older implementation * Removing custom comments * Removing custom comments * Fixing Typo * Fixing Typo * Add missing Params in function call * Add missing Params in function call * Correcting message type, handlers * Correcting message type, handlers * Minor correction on active project change * Minor correction on active project change * Correcting the message format for didChange * Correcting the message format for didChange * Changing custom notification and request handlers, correcting typo, adding catch block for Connection * Changing custom notification and request handlers, correcting typo, adding catch block for Connection * Stop Creation of Multiple Language Servers * Stop Creation of Multiple Language Servers * Make Language Client Generic, address review comments * Make Language Client Generic, address review comments * Correcting param descriptions * Correcting param descriptions * Modifying events handling logic for Language Client, add formatting option for communication params * Modifying events handling logic for Language Client, add formatting option for communication params * Add handlers for node side * Add handlers for node side * Removing explicit param creation, substituting with appropriate checks * Removing explicit param creation, substituting with appropriate checks * Fixing lint errors in MessageHandler.js * Fixing lint errors in MessageHandler.js * Messaging related cleanup * Messaging related cleanup * Adding default providers and feature managers * Adding default providers and feature managers * Adding banner and fixing lint error * Adding banner and fixing lint error * fix spacing issue * fix spacing issue * Fix spacing issues * Fix spacing issues * Add filetype checks for all events, minor server info corrections * Add filetype checks for all events, minor server info corrections * Handling Reload with Extension Scenario, minor JumpToDef provider fix * Handling Reload with Extension Scenario, minor JumpToDef provider fix * Correcting Typo * Correcting Typo * Adding bug fixes * Adding bug fixes * Adding bug fixes 2 * Adding bug fixes 2 * Addressing Review: Fixing minor typo * Addressing Review: Fixing minor typo * Minor bug fixes, functionality enhancements * Minor bug fixes, functionality enhancements * Adding tests for Language Server Support: first cut * Adding tests for Language Server Support: first cut * Adding banner, fixing lint errors * Adding banner, fixing lint errors * Adding dependency related tasks * Adding dependency related tasks * Fixing npm environment string * Fixing npm environment string * Changing handler name * Changing handler name * Changing file name to ClientLoader * Changing file name to ClientLoader * Changing variable name appropriately * Changing variable name appropriately * Grunt related changes for build * Grunt related changes for build * Adding additional requests and notifications for handling various scenarios * Adding additional requests and notifications for handling various scenarios * Adding Path Converter Utilities * Adding Path Converter Utilities * Changing Ternary operator to OR operater * Changing Ternary operator to OR operater * Addressing review comments * Addressing review comments * Removing the handler for editor change, will be handled explicitely * Removing the handler for editor change, will be handled explicitely * Patching JavaScriptCodeHints * Patching JavaScriptCodeHints * Preferences infra for LanguageTools * Preferences infra for LanguageTools * Fixing JS ParameterHints * Fixing JS ParameterHints * Fixing Default Parameter Hints Provider * Fixing Default Parameter Hints Provider * Fixing Path Converters * Fixing Path Converters * Fixing Lint in PathConverters * Fixing Lint in PathConverters * Retaining Posix Path on Win * Retaining Posix Path on Win * Fixing lint errors * Fixing lint errors * Fixing Node side Utils * Fixing Node side Utils * Fixing Promise related Issues * Fixing Promise related Issues * Set Server Capability in Start call * Set Server Capability in Start call * Review Comments & Bug Fixes * Review Comments & Bug Fixes * Addressing Review Comments * Addressing Review Comments * Fixing Lint * Fixing Lint Co-authored-by: Shubham Yadav <[email protected]>
1 parent 6cd2092 commit bb0aac0

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

55 files changed

+7527
-647
lines changed

.eslintrc.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,5 +80,15 @@ module.exports = {
8080
"Uint32Array": false,
8181
"WebSocket": false,
8282
"XMLHttpRequest": false
83+
},
84+
"parserOptions": {
85+
"ecmaVersion": 6,
86+
"sourceType": "script",
87+
"ecmaFeatures": {
88+
"arrowFunctions": true,
89+
"binaryLiterals": true,
90+
"blockBindings": true,
91+
"classes": true
92+
}
8393
}
8494
};

Gruntfile.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,9 @@ module.exports = function (grunt) {
8282
src: [
8383
'extensibility/node/**',
8484
'JSUtils/node/**',
85+
'languageTools/node/**',
86+
'languageTools/styles/**',
87+
'languageTools/LanguageClient/**',
8588
'!extensibility/node/spec/**',
8689
'!extensibility/node/node_modules/**/{test,tst}/**/*',
8790
'!extensibility/node/node_modules/**/examples/**/*',

src/brackets.js

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,10 @@ define(function (require, exports, module) {
137137
return PathUtils;
138138
}
139139
});
140+
141+
//load language features
142+
require("features/ParameterHintsManager");
143+
require("features/JumpToDefManager");
140144

141145
// Load modules that self-register and just need to get included in the main project
142146
require("command/DefaultMenus");
@@ -155,6 +159,15 @@ define(function (require, exports, module) {
155159
require("JSUtils/Session");
156160
require("JSUtils/ScopeManager");
157161

162+
//load Language Tools Module
163+
require("languageTools/PathConverters");
164+
require("languageTools/LanguageTools");
165+
require("languageTools/ClientLoader");
166+
require("languageTools/BracketsToNodeInterface");
167+
require("languageTools/DefaultProviders");
168+
require("languageTools/DefaultEventHandlers");
169+
170+
158171
PerfUtils.addMeasurement("brackets module dependencies resolved");
159172

160173
// Local variables

src/command/Commands.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ define(function (require, exports, module) {
123123
exports.NAVIGATE_SHOW_IN_FILE_TREE = "navigate.showInFileTree"; // DocumentCommandHandlers.js handleShowInTree()
124124
exports.NAVIGATE_SHOW_IN_OS = "navigate.showInOS"; // DocumentCommandHandlers.js handleShowInOS()
125125
exports.NAVIGATE_QUICK_OPEN = "navigate.quickOpen"; // QuickOpen.js doFileSearch()
126-
exports.NAVIGATE_JUMPTO_DEFINITION = "navigate.jumptoDefinition"; // EditorManager.js _doJumpToDef()
126+
exports.NAVIGATE_JUMPTO_DEFINITION = "navigate.jumptoDefinition"; // JumpToDefManager.js _doJumpToDef()
127127
exports.NAVIGATE_GOTO_DEFINITION = "navigate.gotoDefinition"; // QuickOpen.js doDefinitionSearch()
128128
exports.NAVIGATE_GOTO_LINE = "navigate.gotoLine"; // QuickOpen.js doGotoLine()
129129
exports.NAVIGATE_GOTO_FIRST_PROBLEM = "navigate.gotoFirstProblem"; // CodeInspection.js handleGotoFirstProblem()

src/editor/EditorManager.js

Lines changed: 0 additions & 76 deletions
Original file line numberDiff line numberDiff line change
@@ -92,15 +92,6 @@ define(function (require, exports, module) {
9292
*/
9393
var _inlineDocsProviders = [];
9494

95-
/**
96-
* Registered jump-to-definition providers.
97-
* @see {@link #registerJumpToDefProvider}.
98-
* @private
99-
* @type {Array.<function(...)>}
100-
*/
101-
var _jumpToDefProviders = [];
102-
103-
10495
/**
10596
* DOM element to house any hidden editors created soley for inline widgets
10697
* @private
@@ -423,19 +414,6 @@ define(function (require, exports, module) {
423414
_insertProviderSorted(_inlineDocsProviders, provider, priority);
424415
}
425416

426-
/**
427-
* Registers a new jump-to-definition provider. When jump-to-definition is invoked each
428-
* registered provider is asked if it wants to provide jump-to-definition results, given
429-
* the current editor and cursor location.
430-
*
431-
* @param {function(!Editor, !{line:number, ch:number}):?$.Promise} provider
432-
* The provider returns a promise that is resolved whenever it's done handling the operation,
433-
* or returns null to indicate the provider doesn't want to respond to this case. It is entirely
434-
* up to the provider to open the file containing the definition, select the appropriate text, etc.
435-
*/
436-
function registerJumpToDefProvider(provider) {
437-
_jumpToDefProviders.push(provider);
438-
}
439417

440418
/**
441419
* @private
@@ -705,55 +683,6 @@ define(function (require, exports, module) {
705683
return _lastFocusedEditor;
706684
}
707685

708-
709-
/**
710-
* Asynchronously asks providers to handle jump-to-definition.
711-
* @return {!Promise} Resolved when the provider signals that it's done; rejected if no
712-
* provider responded or the provider that responded failed.
713-
*/
714-
function _doJumpToDef() {
715-
var providers = _jumpToDefProviders;
716-
var promise,
717-
i,
718-
result = new $.Deferred();
719-
720-
var editor = getActiveEditor();
721-
722-
if (editor) {
723-
var pos = editor.getCursorPos();
724-
725-
PerfUtils.markStart(PerfUtils.JUMP_TO_DEFINITION);
726-
727-
// Run through providers until one responds
728-
for (i = 0; i < providers.length && !promise; i++) {
729-
var provider = providers[i];
730-
promise = provider(editor, pos);
731-
}
732-
733-
// Will one of them will provide a result?
734-
if (promise) {
735-
promise.done(function () {
736-
PerfUtils.addMeasurement(PerfUtils.JUMP_TO_DEFINITION);
737-
result.resolve();
738-
}).fail(function () {
739-
// terminate timer that was started above
740-
PerfUtils.finalizeMeasurement(PerfUtils.JUMP_TO_DEFINITION);
741-
result.reject();
742-
});
743-
} else {
744-
// terminate timer that was started above
745-
PerfUtils.finalizeMeasurement(PerfUtils.JUMP_TO_DEFINITION);
746-
result.reject();
747-
}
748-
749-
} else {
750-
result.reject();
751-
}
752-
753-
return result.promise();
754-
}
755-
756-
757686
/**
758687
* file removed from pane handler.
759688
* @param {jQuery.Event} e
@@ -797,10 +726,6 @@ define(function (require, exports, module) {
797726
CommandManager.register(Strings.CMD_TOGGLE_QUICK_DOCS, Commands.TOGGLE_QUICK_DOCS, function () {
798727
return _toggleInlineWidget(_inlineDocsProviders, Strings.ERROR_QUICK_DOCS_PROVIDER_NOT_FOUND);
799728
});
800-
CommandManager.register(Strings.CMD_JUMPTO_DEFINITION, Commands.NAVIGATE_JUMPTO_DEFINITION, _doJumpToDef);
801-
802-
// Create PerfUtils measurement
803-
PerfUtils.createPerfMeasurement("JUMP_TO_DEFINITION", "Jump-To-Definiiton");
804729

805730
MainViewManager.on("currentFileChange", _handleCurrentFileChange);
806731
MainViewManager.on("workingSetRemove workingSetRemoveList", _handleRemoveFromPaneView);
@@ -830,7 +755,6 @@ define(function (require, exports, module) {
830755

831756
exports.registerInlineEditProvider = registerInlineEditProvider;
832757
exports.registerInlineDocsProvider = registerInlineDocsProvider;
833-
exports.registerJumpToDefProvider = registerJumpToDefProvider;
834758

835759
// Deprecated
836760
exports.registerCustomViewer = registerCustomViewer;

0 commit comments

Comments
 (0)