added support for lsp-based hovers in JDT editor

This commit is contained in:
Martin Lippert
2017-02-23 13:06:49 +01:00
parent 68ea3cf060
commit 13c75be060
2 changed files with 54 additions and 0 deletions

View File

@@ -25,5 +25,14 @@
needsSortingAfterFiltering="false">
</javaCompletionProposalComputer>
</extension>
<extension
id="springbootjava-hover-provider"
point="org.eclipse.jdt.ui.javaEditorTextHovers">
<hover
activate="true"
class="org.springframework.boot.ide.java.servers.SpringBootJavaHoverProvider"
id="org.springframework.boot.ide.java.servers.hoverprovider">
</hover>
</extension>
</plugin>

View File

@@ -0,0 +1,45 @@
/*******************************************************************************
* Copyright (c) 2017 Pivotal, Inc.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Pivotal, Inc. - initial API and implementation
*******************************************************************************/
package org.springframework.boot.ide.java.servers;
import org.eclipse.jdt.ui.text.java.hover.IJavaEditorTextHover;
import org.eclipse.jface.text.IRegion;
import org.eclipse.jface.text.ITextViewer;
import org.eclipse.lsp4e.operations.hover.LSBasedHover;
import org.eclipse.ui.IEditorPart;
/**
* @author Martin Lippert
*/
@SuppressWarnings("restriction")
public class SpringBootJavaHoverProvider implements IJavaEditorTextHover {
private LSBasedHover lsBasedHover;
public SpringBootJavaHoverProvider() {
lsBasedHover = new LSBasedHover();
}
@Override
public String getHoverInfo(ITextViewer textViewer, IRegion hoverRegion) {
return this.lsBasedHover.getHoverInfo(textViewer, hoverRegion);
}
@Override
public IRegion getHoverRegion(ITextViewer textViewer, int offset) {
return this.lsBasedHover.getHoverRegion(textViewer, offset);
}
@Override
public void setEditor(IEditorPart editor) {
}
}