Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Bug 527206 - Merge LSP support into master - contentAssist.changes
This does not include the necessary changes to make the LSP's
CompletionItem's additionalTextEdits work.

The current code in utils.js uses a property named additionalEdits
which conflicts with a property that was created for people extending
Orion to add additional text edits to a completion proposal.

See bug 439272 and bug 527206 comment 14 for more details.

Signed-off-by: Remy Suen <remy.suen@gmail.com>
  • Loading branch information
rcjsuen committed Jan 13, 2018
1 parent 169c7f1 commit 15c2706
Showing 1 changed file with 31 additions and 6 deletions.
@@ -1,6 +1,6 @@
/*******************************************************************************
* @license
* Copyright (c) 2011, 2016 IBM Corporation and others.
* Copyright (c) 2011, 2018 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials are made
* available under the terms of the Eclipse Public License v1.0
* (http://www.eclipse.org/legal/epl-v10.html), and the Eclipse Distribution
Expand All @@ -22,8 +22,9 @@ define("orion/editor/contentAssist", [
'orion/editor/util',
'orion/util',
'orion/webui/littlelib',
'orion/metrics'
], function(messages, mKeyBinding, mKeyModes, mEventTarget, Deferred, objects, mTooltip, textUtil, util, lib, mMetrics) {
'orion/metrics',
'lsp/utils'
], function(messages, mKeyBinding, mKeyModes, mEventTarget, Deferred, objects, mTooltip, textUtil, util, lib, mMetrics, Utils) {
/**
* @name orion.editor.ContentAssistProvider
* @class Interface defining a provider of content assist proposals.
Expand Down Expand Up @@ -407,7 +408,12 @@ define("orion/editor/contentAssist", [
indentation: indentation
};
try {
if ((func = provider.computeContentAssist)) {
if (providerInfo.lspServer) {
// completion comes from the lsp service
editorContext = ecProvider.getEditorContext();
params = objects.mixin(params, ecProvider.getOptions());
promise = Utils.computeContentAssist(provider, editorContext, params);
} else if ((func = provider.computeContentAssist)) {
ecProvider = _self.editorContextProvider;
editorContext = ecProvider.getEditorContext();
params = objects.mixin(params, ecProvider.getOptions());
Expand Down Expand Up @@ -637,7 +643,7 @@ define("orion/editor/contentAssist", [

this._providers = providerInfoArray;
this._charTriggersInstalled = providerInfoArray.some(function(info){
return info.charTriggers;
return info.charTriggers || info.lspServer;
});
this._updateAutoTriggerListenerState();
},
Expand Down Expand Up @@ -731,7 +737,26 @@ define("orion/editor/contentAssist", [
// check if the charTriggers RegExp matches the currentChar
// we're assuming that this will fail much more often than
// the excludedStyles test so do this first for better performance
var charTriggers = info.charTriggers;
var charTriggers = null;
if (info.lspServer) {
var capabilities = info.provider.capabilities;
if (capabilities && capabilities.completionProvider && !info.charTriggers) {
// we should get the completion options
var completionOptions = capabilities.completionProvider;

// build up the regex for triggerCharacters
var triggers = "[";
// don't assume that the language server supports trigger characters
if (completionOptions.triggerCharacters) {
completionOptions.triggerCharacters.forEach(function(character) {
triggers += character;
});
}
triggers += "]";
info.charTriggers = new RegExp(triggers);
}
}
charTriggers = info.charTriggers;
if (charTriggers && charTriggers.test(currentChar)) {
var isExcluded = false;
var excludedStyles = info.excludedStyles;
Expand Down

0 comments on commit 15c2706

Please sign in to comment.