Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Bug 527206 - Merge LSP support into master - hover.js changes
Signed-off-by: Remy Suen <remy.suen@gmail.com>
  • Loading branch information
rcjsuen committed Jan 13, 2018
1 parent 64afac6 commit d612d2b
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 14 deletions.
Expand Up @@ -485,7 +485,7 @@ define([
foldingRulerFactory: new mEditorFeatures.FoldingRulerFactory(),
zoomRulerFactory: new mEditorFeatures.ZoomRulerFactory(),
lineNumberRulerFactory: new mEditorFeatures.LineNumberRulerFactory(),
hoverFactory: new mHoverFactory.HoverFactory(serviceRegistry, inputManager, commandRegistry),
hoverFactory: new mHoverFactory.HoverFactory(serviceRegistry, inputManager, commandRegistry, languageServerRegistry),
contentAssistFactory: contentAssistFactory,
keyBindingFactory: keyBindingFactory,
statusReporter: this.statusReporter,
Expand Down
37 changes: 24 additions & 13 deletions bundles/org.eclipse.orion.client.ui/web/orion/hover.js
@@ -1,6 +1,6 @@
/*******************************************************************************
* @license
* Copyright (c) 2014, 2016 IBM Corporation and others.
* Copyright (c) 2014, 2017 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 @@ -12,8 +12,9 @@
/*eslint-env browser, amd*/

define ([
'marked/marked'
], function(Markdown) {
'marked/marked',
'lsp/utils'
], function(Markdown, Utils) {

function Hover(editor, hoverFactory) {
this.editor = editor;
Expand All @@ -29,10 +30,14 @@ define ([
computeHoverInfo: function (context) {
var hoverInfo = [];
this.hoverFactory._applicableProviders.forEach(function(provider) {
var providerImpl = this.serviceRegistry.getService(provider);
if (providerImpl && providerImpl.computeHoverInfo) {
var editorContext = this.editor.getEditorContext();
hoverInfo.push(providerImpl.computeHoverInfo(editorContext, context));
if (provider._id && provider.isHoverEnabled()) {
hoverInfo.push(Utils.computeHoverInfo(provider, this.inputManager, this.editor, context));
} else {
var providerImpl = this.serviceRegistry.getService(provider);
if (providerImpl && providerImpl.computeHoverInfo) {
var editorContext = this.editor.getEditorContext();
hoverInfo.push(providerImpl.computeHoverInfo(editorContext, context));
}
}
}.bind(this));

Expand Down Expand Up @@ -75,10 +80,11 @@ define ([

};

function HoverFactory(serviceRegistry, inputManager, commandRegistry) {
function HoverFactory(serviceRegistry, inputManager, commandRegistry, languageServerRegistry) {
this.serviceRegistry = serviceRegistry;
this.inputManager = inputManager;
this.commandRegistry = commandRegistry;
this.languageServerRegistry = languageServerRegistry;

// Filter the plugins based on contentType...
this.filterHoverPlugins();
Expand All @@ -94,12 +100,17 @@ define ([
},

filterHoverPlugins: function () {
var contentType = this.inputManager.getContentType();
this._applicableProviders = [];
var infoProviders = this.serviceRegistry.getServiceReferences("orion.edit.hover"); //$NON-NLS-0$
for (var i = 0; i < infoProviders.length; i++) {
var providerRef = infoProviders[i];
var contentType = this.inputManager.getContentType();
if (contentType) {
if (contentType) {
// check lsp extensions
var lspServer = this.languageServerRegistry.getServerByContentType(contentType);
if (lspServer) {
this._applicableProviders.push(lspServer);
}
var infoProviders = this.serviceRegistry.getServiceReferences("orion.edit.hover"); //$NON-NLS-0$
for (var i = 0; i < infoProviders.length; i++) {
var providerRef = infoProviders[i];
var validTypes = providerRef.getProperty('contentType'); //$NON-NLS-0$
if (validTypes && validTypes.indexOf(contentType.id) !== -1) {
this._applicableProviders.push(providerRef);
Expand Down

0 comments on commit d612d2b

Please sign in to comment.