Merge branch 'master' of github.com:spring-projects/sts4
This commit is contained in:
@@ -0,0 +1,11 @@
|
||||
package org.springframework.ide.vscode.commons.languageserver.util;
|
||||
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
|
||||
import org.eclipse.lsp4j.Hover;
|
||||
import org.eclipse.lsp4j.TextDocumentPositionParams;
|
||||
|
||||
@FunctionalInterface
|
||||
public interface HoverHandler {
|
||||
CompletableFuture<Hover> handle(TextDocumentPositionParams params);
|
||||
}
|
||||
@@ -53,12 +53,19 @@ public class SimpleTextDocumentService implements TextDocumentService {
|
||||
private ListenerList<TextDocumentContentChange> documentChangeListeners = new ListenerList<>();
|
||||
private CompletionHandler completionHandler = null;
|
||||
private CompletionResolveHandler completionResolveHandler = null;
|
||||
private HoverHandler hoverHandler = null;
|
||||
|
||||
public SimpleTextDocumentService(SimpleLanguageServer server) {
|
||||
this.server = server;
|
||||
}
|
||||
|
||||
public synchronized void onCompletion(CompletionHandler h) {
|
||||
|
||||
public synchronized void onHover(HoverHandler h) {
|
||||
Assert.isNull("A hover handler is already set, multiple handlers not supported yet", hoverHandler);
|
||||
this.hoverHandler = h;
|
||||
}
|
||||
|
||||
public synchronized void onCompletion(CompletionHandler h) {
|
||||
Assert.isNull("A completion handler is already set, multiple handlers not supported yet", completionHandler);
|
||||
this.completionHandler = h;
|
||||
}
|
||||
@@ -181,6 +188,10 @@ public class SimpleTextDocumentService implements TextDocumentService {
|
||||
|
||||
@Override
|
||||
public CompletableFuture<Hover> hover(TextDocumentPositionParams position) {
|
||||
HoverHandler h = hoverHandler;
|
||||
if (h!=null) {
|
||||
return hoverHandler.handle(position);
|
||||
}
|
||||
return Futures.of(null);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user