From 9eb5a29ea36a949fe244c8eb76b626284f9b3eb8 Mon Sep 17 00:00:00 2001 From: Jinbo Wang Date: Fri, 21 Feb 2020 15:36:03 +0800 Subject: [PATCH] Adopt the new lsp4j 0.9.0 bits to fix build errors Signed-off-by: Jinbo Wang --- .../internal/handlers/JDTLanguageServer.java | 28 +++++++++++-------- .../preferences/ClientPreferences.java | 8 +++++- 2 files changed, 24 insertions(+), 12 deletions(-) diff --git a/org.eclipse.jdt.ls.core/src/org/eclipse/jdt/ls/core/internal/handlers/JDTLanguageServer.java b/org.eclipse.jdt.ls.core/src/org/eclipse/jdt/ls/core/internal/handlers/JDTLanguageServer.java index 6a9abbddc2..b6bac2b435 100644 --- a/org.eclipse.jdt.ls.core/src/org/eclipse/jdt/ls/core/internal/handlers/JDTLanguageServer.java +++ b/org.eclipse.jdt.ls.core/src/org/eclipse/jdt/ls/core/internal/handlers/JDTLanguageServer.java @@ -91,6 +91,7 @@ import org.eclipse.lsp4j.CompletionItem; import org.eclipse.lsp4j.CompletionList; import org.eclipse.lsp4j.CompletionParams; +import org.eclipse.lsp4j.DefinitionParams; import org.eclipse.lsp4j.DidChangeConfigurationParams; import org.eclipse.lsp4j.DidChangeTextDocumentParams; import org.eclipse.lsp4j.DidChangeWatchedFilesParams; @@ -100,6 +101,7 @@ import org.eclipse.lsp4j.DidSaveTextDocumentParams; import org.eclipse.lsp4j.DocumentFormattingParams; import org.eclipse.lsp4j.DocumentHighlight; +import org.eclipse.lsp4j.DocumentHighlightParams; import org.eclipse.lsp4j.DocumentOnTypeFormattingOptions; import org.eclipse.lsp4j.DocumentOnTypeFormattingParams; import org.eclipse.lsp4j.DocumentRangeFormattingParams; @@ -110,11 +112,14 @@ import org.eclipse.lsp4j.FoldingRange; import org.eclipse.lsp4j.FoldingRangeRequestParams; import org.eclipse.lsp4j.Hover; +import org.eclipse.lsp4j.HoverParams; +import org.eclipse.lsp4j.ImplementationParams; import org.eclipse.lsp4j.InitializeParams; import org.eclipse.lsp4j.InitializeResult; import org.eclipse.lsp4j.InitializedParams; import org.eclipse.lsp4j.Location; import org.eclipse.lsp4j.LocationLink; +import org.eclipse.lsp4j.PrepareRenameParams; import org.eclipse.lsp4j.PrepareRenameResult; import org.eclipse.lsp4j.Range; import org.eclipse.lsp4j.ReferenceParams; @@ -129,6 +134,7 @@ import org.eclipse.lsp4j.TextDocumentIdentifier; import org.eclipse.lsp4j.TextDocumentPositionParams; import org.eclipse.lsp4j.TextEdit; +import org.eclipse.lsp4j.TypeDefinitionParams; import org.eclipse.lsp4j.Unregistration; import org.eclipse.lsp4j.UnregistrationParams; import org.eclipse.lsp4j.WillSaveTextDocumentParams; @@ -526,10 +532,10 @@ public CompletableFuture resolveCompletionItem(CompletionItem un } /* (non-Javadoc) - * @see org.eclipse.lsp4j.services.TextDocumentService#hover(org.eclipse.lsp4j.TextDocumentPositionParams) + * @see org.eclipse.lsp4j.services.TextDocumentService#hover(org.eclipse.lsp4j.HoverParams) */ @Override - public CompletableFuture hover(TextDocumentPositionParams position) { + public CompletableFuture hover(HoverParams position) { logInfo(">> document/hover"); HoverHandler handler = new HoverHandler(this.preferenceManager); return computeAsync((monitor) -> handler.hover(position, monitor)); @@ -546,10 +552,10 @@ public CompletableFuture signatureHelp(SignatureHelpParams positi } /* (non-Javadoc) - * @see org.eclipse.lsp4j.services.TextDocumentService#definition(org.eclipse.lsp4j.TextDocumentPositionParams) + * @see org.eclipse.lsp4j.services.TextDocumentService#definition(org.eclipse.lsp4j.DefinitionParams) */ @Override - public CompletableFuture, List>> definition(TextDocumentPositionParams position) { + public CompletableFuture, List>> definition(DefinitionParams position) { logInfo(">> document/definition"); NavigateToDefinitionHandler handler = new NavigateToDefinitionHandler(this.preferenceManager); return computeAsync((monitor) -> { @@ -559,10 +565,10 @@ public CompletableFuture, List, List>> typeDefinition(TextDocumentPositionParams position) { + public CompletableFuture, List>> typeDefinition(TypeDefinitionParams position) { logInfo(">> document/typeDefinition"); NavigateToTypeDefinitionHandler handler = new NavigateToTypeDefinitionHandler(); return computeAsync((monitor) -> { @@ -588,10 +594,10 @@ public CompletableFuture> findLinks(FindLinksParams par } /* (non-Javadoc) - * @see org.eclipse.lsp4j.services.TextDocumentService#documentHighlight(org.eclipse.lsp4j.TextDocumentPositionParams) + * @see org.eclipse.lsp4j.services.TextDocumentService#documentHighlight(org.eclipse.lsp4j.DocumentHighlightParams) */ @Override - public CompletableFuture> documentHighlight(TextDocumentPositionParams position) { + public CompletableFuture> documentHighlight(DocumentHighlightParams position) { logInfo(">> document/documentHighlight"); DocumentHighlightHandler handler = new DocumentHighlightHandler(); return computeAsync((monitor) -> handler.documentHighlight(position, monitor)); @@ -681,10 +687,10 @@ public CompletableFuture> onTypeFormatting(DocumentOnTy } /* (non-Javadoc) - * @see org.eclipse.lsp4j.services.TextDocumentService#prepareRename(org.eclipse.lsp4j.TextDocumentPositionParams) + * @see org.eclipse.lsp4j.services.TextDocumentService#prepareRename(org.eclipse.lsp4j.PrepareRenameParams) */ @Override - public CompletableFuture> prepareRename(TextDocumentPositionParams params) { + public CompletableFuture> prepareRename(PrepareRenameParams params) { logInfo(">> document/prepareRename"); PrepareRenameHandler handler = new PrepareRenameHandler(); @@ -789,7 +795,7 @@ public void didChangeWorkspaceFolders(DidChangeWorkspaceFoldersParams params) { } @Override - public CompletableFuture, List>> implementation(TextDocumentPositionParams position) { + public CompletableFuture, List>> implementation(ImplementationParams position) { logInfo(">> document/implementation"); return computeAsyncWithClientProgress((monitor) -> { ImplementationsHandler handler = new ImplementationsHandler(preferenceManager); diff --git a/org.eclipse.jdt.ls.core/src/org/eclipse/jdt/ls/core/internal/preferences/ClientPreferences.java b/org.eclipse.jdt.ls.core/src/org/eclipse/jdt/ls/core/internal/preferences/ClientPreferences.java index c833da5985..67ddb22286 100644 --- a/org.eclipse.jdt.ls.core/src/org/eclipse/jdt/ls/core/internal/preferences/ClientPreferences.java +++ b/org.eclipse.jdt.ls.core/src/org/eclipse/jdt/ls/core/internal/preferences/ClientPreferences.java @@ -18,9 +18,11 @@ import java.util.Map; import org.eclipse.lsp4j.ClientCapabilities; +import org.eclipse.lsp4j.DiagnosticsTagSupport; import org.eclipse.lsp4j.DynamicRegistrationCapabilities; import org.eclipse.lsp4j.MarkupKind; import org.eclipse.lsp4j.ResourceOperationKind; +import org.eclipse.lsp4j.jsonrpc.messages.Either; /** * A wrapper around {@link ClientCapabilities} @@ -287,10 +289,14 @@ public boolean isDiagnosticTagSupported() { //@formatter:off return v3supported && capabilities.getTextDocument().getPublishDiagnostics() != null && capabilities.getTextDocument().getPublishDiagnostics().getTagSupport() != null - && capabilities.getTextDocument().getPublishDiagnostics().getTagSupport().getValueSet() != null; + && isTagSupported(capabilities.getTextDocument().getPublishDiagnostics().getTagSupport()); //@formatter:on } + private boolean isTagSupported(Either tagSupport) { + return tagSupport.isLeft() ? tagSupport.getLeft() : tagSupport.getRight().getValueSet() != null; + } + public boolean isCallHierarchyDynamicRegistered() { return v3supported && isDynamicRegistrationSupported(capabilities.getTextDocument().getCallHierarchy()); }