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

Commit

Permalink
Language Server Protocol Support for Brackets (#14606)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
Subhash Jha authored and swmitra committed Apr 2, 2019
1 parent 6cd2092 commit df7aea4
Show file tree
Hide file tree
Showing 55 changed files with 7,527 additions and 647 deletions.
10 changes: 10 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -80,5 +80,15 @@ module.exports = {
"Uint32Array": false,
"WebSocket": false,
"XMLHttpRequest": false
},
"parserOptions": {
"ecmaVersion": 6,
"sourceType": "script",
"ecmaFeatures": {
"arrowFunctions": true,
"binaryLiterals": true,
"blockBindings": true,
"classes": true
}
}
};
3 changes: 3 additions & 0 deletions Gruntfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,9 @@ module.exports = function (grunt) {
src: [
'extensibility/node/**',
'JSUtils/node/**',
'languageTools/node/**',
'languageTools/styles/**',
'languageTools/LanguageClient/**',
'!extensibility/node/spec/**',
'!extensibility/node/node_modules/**/{test,tst}/**/*',
'!extensibility/node/node_modules/**/examples/**/*',
Expand Down
13 changes: 13 additions & 0 deletions src/brackets.js
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,10 @@ define(function (require, exports, module) {
return PathUtils;
}
});

//load language features
require("features/ParameterHintsManager");
require("features/JumpToDefManager");

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

//load Language Tools Module
require("languageTools/PathConverters");
require("languageTools/LanguageTools");
require("languageTools/ClientLoader");
require("languageTools/BracketsToNodeInterface");
require("languageTools/DefaultProviders");
require("languageTools/DefaultEventHandlers");


PerfUtils.addMeasurement("brackets module dependencies resolved");

// Local variables
Expand Down
2 changes: 1 addition & 1 deletion src/command/Commands.js
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ define(function (require, exports, module) {
exports.NAVIGATE_SHOW_IN_FILE_TREE = "navigate.showInFileTree"; // DocumentCommandHandlers.js handleShowInTree()
exports.NAVIGATE_SHOW_IN_OS = "navigate.showInOS"; // DocumentCommandHandlers.js handleShowInOS()
exports.NAVIGATE_QUICK_OPEN = "navigate.quickOpen"; // QuickOpen.js doFileSearch()
exports.NAVIGATE_JUMPTO_DEFINITION = "navigate.jumptoDefinition"; // EditorManager.js _doJumpToDef()
exports.NAVIGATE_JUMPTO_DEFINITION = "navigate.jumptoDefinition"; // JumpToDefManager.js _doJumpToDef()
exports.NAVIGATE_GOTO_DEFINITION = "navigate.gotoDefinition"; // QuickOpen.js doDefinitionSearch()
exports.NAVIGATE_GOTO_LINE = "navigate.gotoLine"; // QuickOpen.js doGotoLine()
exports.NAVIGATE_GOTO_FIRST_PROBLEM = "navigate.gotoFirstProblem"; // CodeInspection.js handleGotoFirstProblem()
Expand Down
76 changes: 0 additions & 76 deletions src/editor/EditorManager.js
Original file line number Diff line number Diff line change
Expand Up @@ -92,15 +92,6 @@ define(function (require, exports, module) {
*/
var _inlineDocsProviders = [];

/**
* Registered jump-to-definition providers.
* @see {@link #registerJumpToDefProvider}.
* @private
* @type {Array.<function(...)>}
*/
var _jumpToDefProviders = [];


/**
* DOM element to house any hidden editors created soley for inline widgets
* @private
Expand Down Expand Up @@ -423,19 +414,6 @@ define(function (require, exports, module) {
_insertProviderSorted(_inlineDocsProviders, provider, priority);
}

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

/**
* @private
Expand Down Expand Up @@ -705,55 +683,6 @@ define(function (require, exports, module) {
return _lastFocusedEditor;
}


/**
* Asynchronously asks providers to handle jump-to-definition.
* @return {!Promise} Resolved when the provider signals that it's done; rejected if no
* provider responded or the provider that responded failed.
*/
function _doJumpToDef() {
var providers = _jumpToDefProviders;
var promise,
i,
result = new $.Deferred();

var editor = getActiveEditor();

if (editor) {
var pos = editor.getCursorPos();

PerfUtils.markStart(PerfUtils.JUMP_TO_DEFINITION);

// Run through providers until one responds
for (i = 0; i < providers.length && !promise; i++) {
var provider = providers[i];
promise = provider(editor, pos);
}

// Will one of them will provide a result?
if (promise) {
promise.done(function () {
PerfUtils.addMeasurement(PerfUtils.JUMP_TO_DEFINITION);
result.resolve();
}).fail(function () {
// terminate timer that was started above
PerfUtils.finalizeMeasurement(PerfUtils.JUMP_TO_DEFINITION);
result.reject();
});
} else {
// terminate timer that was started above
PerfUtils.finalizeMeasurement(PerfUtils.JUMP_TO_DEFINITION);
result.reject();
}

} else {
result.reject();
}

return result.promise();
}


/**
* file removed from pane handler.
* @param {jQuery.Event} e
Expand Down Expand Up @@ -797,10 +726,6 @@ define(function (require, exports, module) {
CommandManager.register(Strings.CMD_TOGGLE_QUICK_DOCS, Commands.TOGGLE_QUICK_DOCS, function () {
return _toggleInlineWidget(_inlineDocsProviders, Strings.ERROR_QUICK_DOCS_PROVIDER_NOT_FOUND);
});
CommandManager.register(Strings.CMD_JUMPTO_DEFINITION, Commands.NAVIGATE_JUMPTO_DEFINITION, _doJumpToDef);

// Create PerfUtils measurement
PerfUtils.createPerfMeasurement("JUMP_TO_DEFINITION", "Jump-To-Definiiton");

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

exports.registerInlineEditProvider = registerInlineEditProvider;
exports.registerInlineDocsProvider = registerInlineDocsProvider;
exports.registerJumpToDefProvider = registerJumpToDefProvider;

// Deprecated
exports.registerCustomViewer = registerCustomViewer;
Expand Down
Loading

0 comments on commit df7aea4

Please sign in to comment.