diff --git a/eclipse-language-servers/org.springframework.tooling.ls.eclipse.commons/META-INF/MANIFEST.MF b/eclipse-language-servers/org.springframework.tooling.ls.eclipse.commons/META-INF/MANIFEST.MF index f45c975cf..444e8de6a 100644 --- a/eclipse-language-servers/org.springframework.tooling.ls.eclipse.commons/META-INF/MANIFEST.MF +++ b/eclipse-language-servers/org.springframework.tooling.ls.eclipse.commons/META-INF/MANIFEST.MF @@ -7,9 +7,9 @@ Bundle-Vendor: Pivotal, Inc. Require-Bundle: org.eclipse.jdt.launching;bundle-version="3.8.0", org.eclipse.ui, org.eclipse.core.runtime, - org.eclipse.lsp4e;bundle-version="0.7.0", - org.eclipse.lsp4j.jsonrpc;bundle-version="0.4.0", - org.eclipse.lsp4j;bundle-version="0.4.0", + org.eclipse.lsp4e;bundle-version="0.9.0", + org.eclipse.lsp4j.jsonrpc;bundle-version="0.6.0", + org.eclipse.lsp4j;bundle-version="0.6.0", org.eclipse.ui.workbench.texteditor, org.eclipse.jface.text, com.google.guava, diff --git a/eclipse-language-servers/pom.xml b/eclipse-language-servers/pom.xml index 198faa11c..bfb76a78f 100644 --- a/eclipse-language-servers/pom.xml +++ b/eclipse-language-servers/pom.xml @@ -139,11 +139,11 @@ p2 http://dist.springframework.org/snapshot/IDE/nightly --> - + tm4e p2 @@ -194,11 +194,11 @@ p2 http://dist.springframework.org/snapshot/IDE/nightly --> - + tm4e p2 diff --git a/headless-services/commons/commons-language-server/src/main/java/org/springframework/ide/vscode/commons/languageserver/util/SimpleTextDocumentService.java b/headless-services/commons/commons-language-server/src/main/java/org/springframework/ide/vscode/commons/languageserver/util/SimpleTextDocumentService.java index e470dd5aa..cca028f38 100644 --- a/headless-services/commons/commons-language-server/src/main/java/org/springframework/ide/vscode/commons/languageserver/util/SimpleTextDocumentService.java +++ b/headless-services/commons/commons-language-server/src/main/java/org/springframework/ide/vscode/commons/languageserver/util/SimpleTextDocumentService.java @@ -19,6 +19,7 @@ import java.util.concurrent.CompletableFuture; import java.util.function.Consumer; import java.util.stream.Collectors; +import org.eclipse.lsp4j.CodeAction; import org.eclipse.lsp4j.CodeActionParams; import org.eclipse.lsp4j.CodeLens; import org.eclipse.lsp4j.CodeLensParams; @@ -35,6 +36,7 @@ import org.eclipse.lsp4j.DocumentFormattingParams; import org.eclipse.lsp4j.DocumentHighlight; import org.eclipse.lsp4j.DocumentOnTypeFormattingParams; import org.eclipse.lsp4j.DocumentRangeFormattingParams; +import org.eclipse.lsp4j.DocumentSymbol; import org.eclipse.lsp4j.DocumentSymbolParams; import org.eclipse.lsp4j.Hover; import org.eclipse.lsp4j.Location; @@ -62,7 +64,6 @@ import org.springframework.ide.vscode.commons.util.AsyncRunner; import org.springframework.ide.vscode.commons.util.BadLocationException; import org.springframework.ide.vscode.commons.util.CollectorUtil; import org.springframework.ide.vscode.commons.util.ExceptionUtil; -import org.springframework.ide.vscode.commons.util.Log; import org.springframework.ide.vscode.commons.util.text.LanguageId; import org.springframework.ide.vscode.commons.util.text.TextDocument; @@ -166,7 +167,7 @@ public class SimpleTextDocumentService implements TextDocumentService, DocumentE didChangeContent(doc, changes); } } catch (BadLocationException e) { - Log.log(e); + log.error("", e); } }); } @@ -182,7 +183,7 @@ public class SimpleTextDocumentService implements TextDocumentService, DocumentE if (url!=null) { String text = params.getTextDocument().getText(); TrackedDocument td = createDocument(url, languageId, version, text).open(); - Log.debug("Opened "+td.getOpenCount()+" times: "+url); + log.debug("Opened "+td.getOpenCount()+" times: "+url); TextDocument doc = td.getDocument(); TextDocumentContentChangeEvent change = new TextDocumentContentChangeEvent() { @Override @@ -215,7 +216,7 @@ public class SimpleTextDocumentService implements TextDocumentService, DocumentE TrackedDocument doc = documents.get(url); if (doc!=null) { if (doc.close()) { - Log.info("Closed: "+url); + log.info("Closed: "+url); //Clear diagnostics when a file is closed. This makes the errors disapear when the language is changed for // a document (this resulst in a dicClose even as being sent to the language server if that changes make the // document go 'out of scope'. @@ -223,10 +224,10 @@ public class SimpleTextDocumentService implements TextDocumentService, DocumentE documentCloseListeners.fire(doc.getDocument()); documents.remove(url); } else { - Log.warn("Close event ignored! Assuming document still open because openCount = "+doc.getOpenCount()); + log.warn("Close event ignored! Assuming document still open because openCount = "+doc.getOpenCount()); } } else { - Log.warn("Document closed, but it didn't exist! Close event ignored"); + log.warn("Document closed, but it didn't exist! Close event ignored"); } } }); @@ -255,7 +256,7 @@ public class SimpleTextDocumentService implements TextDocumentService, DocumentE public synchronized TextDocument getDocument(String url) { TrackedDocument doc = documents.get(url); if (doc==null) { - Log.warn("Trying to get document ["+url+"] but it did not exists. Creating it with language-id 'plaintext'"); + log.warn("Trying to get document ["+url+"] but it did not exists. Creating it with language-id 'plaintext'"); doc = createDocument(url, LanguageId.PLAINTEXT, 0, ""); } return doc.getDocument(); @@ -264,7 +265,7 @@ public class SimpleTextDocumentService implements TextDocumentService, DocumentE private synchronized TrackedDocument createDocument(String url, LanguageId languageId, int version, String text) { TrackedDocument existingDoc = documents.get(url); if (existingDoc!=null) { - Log.warn("Creating document ["+url+"] but it already exists. Reusing existing!"); + log.warn("Creating document ["+url+"] but it already exists. Reusing existing!"); return existingDoc; } TrackedDocument doc = new TrackedDocument(new TextDocument(url, languageId, version, text)); @@ -347,7 +348,7 @@ public class SimpleTextDocumentService implements TextDocumentService, DocumentE } @Override - public CompletableFuture> documentSymbol(DocumentSymbolParams params) { + public CompletableFuture>> documentSymbol(DocumentSymbolParams params) { return async.invoke(() -> { DocumentSymbolHandler documentSymbolHandler = this.documentSymbolHandler; if (documentSymbolHandler==null) { @@ -356,19 +357,23 @@ public class SimpleTextDocumentService implements TextDocumentService, DocumentE server.waitForReconcile(); List r = documentSymbolHandler.handle(params); //handle it when symbolHandler is sloppy and returns null instead of empty list. - return r == null ? ImmutableList.of() : r; - }); + return r == null ? ImmutableList.of() + : r.stream().map(symbolInfo -> Either.forLeft(symbolInfo)) + .collect(Collectors.toList()); + }); } @Override - public CompletableFuture> codeAction(CodeActionParams params) { + public CompletableFuture>> codeAction(CodeActionParams params) { return async.invoke(() -> { TrackedDocument doc = documents.get(params.getTextDocument().getUri()); if (doc!=null) { - return doc.getQuickfixes().stream() - .filter((fix) -> fix.appliesTo(params.getRange(), params.getContext())) - .map(Quickfix::getCodeAction) - .collect(CollectorUtil.toImmutableList()); + ImmutableList> list = doc.getQuickfixes().stream() + .filter((fix) -> fix.appliesTo(params.getRange(), params.getContext())) + .map(Quickfix::getCodeAction) + .map(command -> Either.forLeft(command)) + .collect(CollectorUtil.toImmutableList()); + return list; } else { return ImmutableList.of(); } @@ -425,7 +430,7 @@ public class SimpleTextDocumentService implements TextDocumentService, DocumentE if (documentSaveListeners != null) { TextDocumentIdentifier docId = params.getTextDocument(); String url = docId.getUri(); - Log.debug("didSave: "+url); + log.debug("didSave: "+url); if (url!=null) { TextDocument doc = getDocument(url); for (Consumer l : documentSaveListeners) { diff --git a/headless-services/commons/commons-yaml/src/main/java/org/springframework/ide/vscode/commons/yaml/quickfix/YamlQuickfixes.java b/headless-services/commons/commons-yaml/src/main/java/org/springframework/ide/vscode/commons/yaml/quickfix/YamlQuickfixes.java index db716d708..68885e1cf 100644 --- a/headless-services/commons/commons-yaml/src/main/java/org/springframework/ide/vscode/commons/yaml/quickfix/YamlQuickfixes.java +++ b/headless-services/commons/commons-yaml/src/main/java/org/springframework/ide/vscode/commons/yaml/quickfix/YamlQuickfixes.java @@ -43,7 +43,7 @@ public class YamlQuickfixes { private static final Logger LOG = LoggerFactory.getLogger(YamlQuickfixes.class); private static final QuickfixEdit NULL_FIX = new QuickfixEdit( - new WorkspaceEdit(ImmutableMap.of(), null), + new WorkspaceEdit(ImmutableMap.of()), null ); public final QuickfixType MISSING_PROP_FIX; @@ -107,8 +107,7 @@ public class YamlQuickfixes { if (_doc!=null) { return new QuickfixEdit( new WorkspaceEdit( - ImmutableMap.of(params.getUri(), ImmutableList.of(params.getEdit())), - null + ImmutableMap.of(params.getUri(), ImmutableList.of(params.getEdit())) ), null //TODO: compute end of the range after applying the edit ); diff --git a/headless-services/commons/language-server-test-harness/src/main/java/org/springframework/ide/vscode/languageserver/testharness/LanguageServerHarness.java b/headless-services/commons/language-server-test-harness/src/main/java/org/springframework/ide/vscode/languageserver/testharness/LanguageServerHarness.java index 68032578c..849cd3f4e 100644 --- a/headless-services/commons/language-server-test-harness/src/main/java/org/springframework/ide/vscode/languageserver/testharness/LanguageServerHarness.java +++ b/headless-services/commons/language-server-test-harness/src/main/java/org/springframework/ide/vscode/languageserver/testharness/LanguageServerHarness.java @@ -678,9 +678,10 @@ public class LanguageServerHarness { public List getCodeActions(TextDocumentInfo doc, Diagnostic problem) throws Exception { CodeActionContext context = new CodeActionContext(ImmutableList.of(problem)); - List actions = + List> actions = getServer().getTextDocumentService().codeAction(new CodeActionParams(doc.getId(), problem.getRange(), context)).get(); return actions.stream() + .map(e -> e.getLeft()) .map((command) -> new CodeAction(this, command)) .collect(Collectors.toList()); } @@ -741,7 +742,7 @@ public class LanguageServerHarness { public List getDocumentSymbols(TextDocumentInfo document) throws Exception { waitForReconcile(); //TODO: if the server works properly this shouldn't be needed it should do that internally itself somehow. DocumentSymbolParams params = new DocumentSymbolParams(document.getId()); - return getServer().getTextDocumentService().documentSymbol(params).get(); + return getServer().getTextDocumentService().documentSymbol(params).get().stream().map(e -> e.getLeft()).collect(Collectors.toList()); } /** diff --git a/headless-services/commons/pom.xml b/headless-services/commons/pom.xml index 85de8ba2b..ea6f09b11 100644 --- a/headless-services/commons/pom.xml +++ b/headless-services/commons/pom.xml @@ -87,7 +87,7 @@ 1.10.19 2.5.0 2.10 - 0.4.0-SNAPSHOT + 0.6.0 3.2.7 3.8.0.RELEASE