Update lsp4j to 2.0 snapshot version
This commit is contained in:
@@ -10,21 +10,23 @@
|
||||
*******************************************************************************/
|
||||
package org.springframework.ide.vscode.commons.languageserver.hover;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
|
||||
import org.eclipse.lsp4j.Hover;
|
||||
import org.eclipse.lsp4j.Range;
|
||||
import org.eclipse.lsp4j.TextDocumentPositionParams;
|
||||
import org.eclipse.lsp4j.jsonrpc.messages.Either;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.ide.vscode.commons.languageserver.util.SimpleLanguageServer;
|
||||
import org.springframework.ide.vscode.commons.languageserver.util.SimpleTextDocumentService;
|
||||
import org.springframework.ide.vscode.commons.util.Futures;
|
||||
import org.springframework.ide.vscode.commons.util.Renderable;
|
||||
import org.springframework.ide.vscode.commons.util.StringUtil;
|
||||
import org.springframework.ide.vscode.commons.util.text.IRegion;
|
||||
import org.springframework.ide.vscode.commons.util.text.TextDocument;
|
||||
|
||||
import com.google.common.collect.ImmutableList;
|
||||
|
||||
import reactor.util.function.Tuple2;
|
||||
|
||||
public class VscodeHoverEngineAdapter implements VscodeHoverEngine {
|
||||
@@ -71,9 +73,11 @@ public class VscodeHoverEngineAdapter implements VscodeHoverEngine {
|
||||
IRegion region = hoverTuple.getT2();
|
||||
Range range = doc.toRange(region.getOffset(), region.getLength());
|
||||
|
||||
Hover hover = new Hover(Collections.singletonList(render(hoverInfo, type)), range);
|
||||
|
||||
return Futures.of(hover);
|
||||
String rendered = render(hoverInfo, type);
|
||||
if (StringUtil.hasText(rendered)) {
|
||||
Hover hover = new Hover(ImmutableList.of(Either.forLeft(rendered)), range);
|
||||
return CompletableFuture.completedFuture(hover);
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
|
||||
@@ -51,6 +51,7 @@ import org.eclipse.lsp4j.TextDocumentPositionParams;
|
||||
import org.eclipse.lsp4j.TextEdit;
|
||||
import org.eclipse.lsp4j.VersionedTextDocumentIdentifier;
|
||||
import org.eclipse.lsp4j.WorkspaceEdit;
|
||||
import org.eclipse.lsp4j.jsonrpc.messages.Either;
|
||||
import org.eclipse.lsp4j.services.LanguageClient;
|
||||
import org.eclipse.lsp4j.services.TextDocumentService;
|
||||
import org.springframework.ide.vscode.commons.languageserver.LanguageIds;
|
||||
@@ -207,12 +208,13 @@ public class SimpleTextDocumentService implements TextDocumentService {
|
||||
public final static CompletableFuture<Hover> NO_HOVER = CompletableFuture.completedFuture(new Hover(ImmutableList.of(), null));
|
||||
|
||||
@Override
|
||||
public CompletableFuture<CompletionList> completion(TextDocumentPositionParams position) {
|
||||
public CompletableFuture<Either<List<CompletionItem>, CompletionList>> completion(TextDocumentPositionParams position) {
|
||||
CompletionHandler h = completionHandler;
|
||||
if (h!=null) {
|
||||
return completionHandler.handle(position);
|
||||
return completionHandler.handle(position)
|
||||
.thenApply(Either::forRight);
|
||||
}
|
||||
return CompletableFuture.completedFuture(NO_COMPLETIONS);
|
||||
return CompletableFuture.completedFuture(Either.forRight(NO_COMPLETIONS));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -39,6 +39,7 @@ import org.eclipse.lsp4j.Hover;
|
||||
import org.eclipse.lsp4j.InitializeParams;
|
||||
import org.eclipse.lsp4j.InitializeResult;
|
||||
import org.eclipse.lsp4j.Location;
|
||||
import org.eclipse.lsp4j.MessageActionItem;
|
||||
import org.eclipse.lsp4j.MessageParams;
|
||||
import org.eclipse.lsp4j.Position;
|
||||
import org.eclipse.lsp4j.PublishDiagnosticsParams;
|
||||
@@ -48,9 +49,10 @@ import org.eclipse.lsp4j.TextDocumentContentChangeEvent;
|
||||
import org.eclipse.lsp4j.TextDocumentItem;
|
||||
import org.eclipse.lsp4j.TextDocumentPositionParams;
|
||||
import org.eclipse.lsp4j.TextDocumentSyncKind;
|
||||
import org.eclipse.lsp4j.TextDocumentSyncOptions;
|
||||
import org.eclipse.lsp4j.VersionedTextDocumentIdentifier;
|
||||
import org.eclipse.lsp4j.jsonrpc.messages.Either;
|
||||
import org.eclipse.lsp4j.services.LanguageClientAware;
|
||||
import org.eclipse.lsp4j.services.LanguageServer;
|
||||
import org.springframework.ide.vscode.commons.languageserver.LanguageIds;
|
||||
import org.springframework.ide.vscode.commons.languageserver.ProgressParams;
|
||||
import org.springframework.ide.vscode.commons.languageserver.STS4LanguageClient;
|
||||
@@ -147,9 +149,9 @@ public class LanguageServerHarness {
|
||||
}
|
||||
|
||||
@Override
|
||||
public CompletableFuture<Void> showMessageRequest(ShowMessageRequestParams requestParams) {
|
||||
public CompletableFuture<MessageActionItem> showMessageRequest(ShowMessageRequestParams requestParams) {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
return CompletableFuture.completedFuture(new MessageActionItem("Some Message Request Answer"));
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -256,9 +258,11 @@ public class LanguageServerHarness {
|
||||
|
||||
private TextDocumentSyncKind getDocumentSyncMode() {
|
||||
if (initResult!=null) {
|
||||
TextDocumentSyncKind mode = initResult.getCapabilities().getTextDocumentSync();
|
||||
if (mode!=null) {
|
||||
return mode;
|
||||
Either<TextDocumentSyncKind, TextDocumentSyncOptions> mode = initResult.getCapabilities().getTextDocumentSync();
|
||||
if (mode.isLeft()) {
|
||||
return mode.getLeft();
|
||||
} else {
|
||||
throw new IllegalStateException("Harness doesn't support fancy Sync options yet!");
|
||||
}
|
||||
}
|
||||
return TextDocumentSyncKind.None;
|
||||
@@ -303,7 +307,13 @@ public class LanguageServerHarness {
|
||||
params.setPosition(cursor);
|
||||
params.setTextDocument(doc.getId());
|
||||
server.waitForReconcile();
|
||||
return server.getTextDocumentService().completion(params).get();
|
||||
Either<List<CompletionItem>, CompletionList> completions = server.getTextDocumentService().completion(params).get();
|
||||
if (completions.isLeft()) {
|
||||
List<CompletionItem> list = completions.getLeft();
|
||||
return new CompletionList(false, list);
|
||||
} else /* sompletions.isRight() */ {
|
||||
return completions.getRight();
|
||||
}
|
||||
}
|
||||
|
||||
public Hover getHover(TextDocumentInfo document, Position cursor) throws Exception {
|
||||
|
||||
@@ -76,7 +76,7 @@
|
||||
<guava-version>19.0</guava-version>
|
||||
<jackson-2-version>2.5.0</jackson-2-version>
|
||||
<jersey-2-version>2.10</jersey-2-version>
|
||||
<lsp4j-version>0.1.0</lsp4j-version>
|
||||
<lsp4j-version>0.2.0-SNAPSHOT</lsp4j-version>
|
||||
<!-- NOTE: Reactor version must match version used by the CF client -->
|
||||
<reactor-version>3.0.5.RELEASE</reactor-version>
|
||||
<reactor-netty>0.6.0.RELEASE</reactor-netty>
|
||||
|
||||
Reference in New Issue
Block a user