diff --git a/org.eclipse.corrosion/META-INF/MANIFEST.MF b/org.eclipse.corrosion/META-INF/MANIFEST.MF index 3b8314d..2d7e0dd 100644 --- a/org.eclipse.corrosion/META-INF/MANIFEST.MF +++ b/org.eclipse.corrosion/META-INF/MANIFEST.MF @@ -9,7 +9,7 @@ Bundle-Vendor: %Bundle-Vendor Require-Bundle: org.eclipse.core.contenttype, org.eclipse.ui.genericeditor;bundle-version="1.0.1", org.eclipse.ui, - org.eclipse.lsp4e;bundle-version="0.9.0", + org.eclipse.lsp4e;bundle-version="0.17.0", org.eclipse.tm4e.core, org.eclipse.tm4e.ui, org.eclipse.core.runtime;bundle-version="3.22.0", @@ -51,3 +51,4 @@ Export-Package: org.eclipse.corrosion;x-friends:="org.eclipse.corrosion.tests", org.eclipse.corrosion.snippet;x-friends:="org.eclipse.corrosion.tests", org.eclipse.corrosion.wizards.export;x-friends:="org.eclipse.corrosion.tests", org.eclipse.corrosion.wizards.newproject;x-friends:="org.eclipse.corrosion.tests" +Import-Package: org.eclipse.jdt.annotation diff --git a/org.eclipse.corrosion/src/org/eclipse/corrosion/CorrosionPlugin.java b/org.eclipse.corrosion/src/org/eclipse/corrosion/CorrosionPlugin.java index eb1bb83..a3ab03c 100644 --- a/org.eclipse.corrosion/src/org/eclipse/corrosion/CorrosionPlugin.java +++ b/org.eclipse.corrosion/src/org/eclipse/corrosion/CorrosionPlugin.java @@ -42,10 +42,13 @@ import org.eclipse.debug.core.sourcelookup.ISourceContainer; import org.eclipse.ecf.filetransfer.service.IRetrieveFileTransfer; import org.eclipse.ecf.filetransfer.service.IRetrieveFileTransferFactory; +import org.eclipse.jdt.annotation.NonNull; import org.eclipse.jface.dialogs.IDialogConstants; import org.eclipse.jface.dialogs.MessageDialog; import org.eclipse.jface.resource.ImageDescriptor; import org.eclipse.jface.resource.ImageRegistry; +import org.eclipse.lsp4e.LanguageServersRegistry; +import org.eclipse.lsp4e.LanguageServersRegistry.LanguageServerDefinition; import org.eclipse.swt.widgets.Display; import org.eclipse.ui.PlatformUI; import org.eclipse.ui.plugin.AbstractUIPlugin; @@ -361,4 +364,8 @@ private static boolean startBundle(String bundleId) { } return false; } + + public static @NonNull LanguageServerDefinition languageServerDefinition() { + return LanguageServersRegistry.getInstance().getDefinition("org.eclipse.corrosion.rls"); //$NON-NLS-1$ + } } diff --git a/org.eclipse.corrosion/src/org/eclipse/corrosion/RustManager.java b/org.eclipse.corrosion/src/org/eclipse/corrosion/RustManager.java index 1444acb..073fbce 100644 --- a/org.eclipse.corrosion/src/org/eclipse/corrosion/RustManager.java +++ b/org.eclipse.corrosion/src/org/eclipse/corrosion/RustManager.java @@ -177,8 +177,7 @@ private static void sendDidChangeConfigurationsMessage(Map updat params.setSettings(updatedSettings); LSPDocumentInfo info = infoFromOpenEditors(); if (info != null) { - info.getInitializedLanguageClient() - .thenAccept(languageServer -> languageServer.getWorkspaceService().didChangeConfiguration(params)); + info.getLanguageServerWrapper().sendNotification(languageServer -> languageServer.getWorkspaceService().didChangeConfiguration(params)); } } diff --git a/org.eclipse.corrosion/src/org/eclipse/corrosion/extensions/ImplementationsSearchQuery.java b/org.eclipse.corrosion/src/org/eclipse/corrosion/extensions/ImplementationsSearchQuery.java index 8c1003c..09d175d 100644 --- a/org.eclipse.corrosion/src/org/eclipse/corrosion/extensions/ImplementationsSearchQuery.java +++ b/org.eclipse.corrosion/src/org/eclipse/corrosion/extensions/ImplementationsSearchQuery.java @@ -79,8 +79,8 @@ public IStatus run(IProgressMonitor monitor) { params.setContext(new ReferenceContext(true)); params.setTextDocument(new TextDocumentIdentifier(info.getFileUri().toString())); params.setPosition(position); - info.getInitializedLanguageClient() - .thenCompose(languageServer -> ((RLSServerInterface) languageServer).implementations(params)) + info.getLanguageServerWrapper() + .execute(languageServer -> ((RLSServerInterface) languageServer).implementations(params)) .thenAccept(locs -> { // Loop for each LSP Location and convert it to Match search. for (Location loc : locs) { diff --git a/org.eclipse.corrosion/src/org/eclipse/corrosion/test/actions/OpenTestAction.java b/org.eclipse.corrosion/src/org/eclipse/corrosion/test/actions/OpenTestAction.java index 675853c..d8d8dc8 100644 --- a/org.eclipse.corrosion/src/org/eclipse/corrosion/test/actions/OpenTestAction.java +++ b/org.eclipse.corrosion/src/org/eclipse/corrosion/test/actions/OpenTestAction.java @@ -12,6 +12,7 @@ *******************************************************************************/ package org.eclipse.corrosion.test.actions; +import java.io.IOException; import java.util.ArrayList; import java.util.List; import java.util.concurrent.CompletableFuture; @@ -29,6 +30,7 @@ import org.eclipse.jface.action.Action; import org.eclipse.lsp4e.LSPEclipseUtils; import org.eclipse.lsp4e.LanguageServerPlugin; +import org.eclipse.lsp4e.LanguageServerWrapper; import org.eclipse.lsp4e.LanguageServiceAccessor; import org.eclipse.lsp4j.Location; import org.eclipse.lsp4j.Position; @@ -38,7 +40,6 @@ import org.eclipse.lsp4j.WorkspaceSymbol; import org.eclipse.lsp4j.WorkspaceSymbolParams; import org.eclipse.lsp4j.jsonrpc.messages.Either; -import org.eclipse.lsp4j.services.LanguageServer; import org.eclipse.ui.IWorkbenchPage; import org.eclipse.ui.PlatformUI; import org.eclipse.unittest.model.ITestCaseElement; @@ -69,13 +70,17 @@ public void run() { if (project == null) { return; } - List languageServers = LanguageServiceAccessor.getLanguageServers(project, - capabilities -> Boolean.TRUE.equals(capabilities.getWorkspaceSymbolProvider().get())); - if (languageServers != null && languageServers.isEmpty()) { + LanguageServerWrapper languageServer = null; + try { + languageServer = LanguageServiceAccessor.getLSWrapper(project, CorrosionPlugin.languageServerDefinition()); + } catch (IOException ex) { + CorrosionPlugin.logError(ex); + } + if (languageServer == null) { return; } SymbolKind kind = fTestElement instanceof ITestCaseElement ? SymbolKind.Function : SymbolKind.Module; - List result = getQualifiedSymbols(languageServers, fTestElement.getTestName(), kind); + List result = getQualifiedSymbols(languageServer, fTestElement.getTestName(), kind); if (result == null || result.isEmpty()) { return; } @@ -108,7 +113,7 @@ private static IProject getProject(ITestElement element) { return null; } - private static List getQualifiedSymbols(List languageServers, String path, + private static List getQualifiedSymbols(LanguageServerWrapper languageServer, String path, SymbolKind kind) { List result = new ArrayList<>(); @@ -123,7 +128,7 @@ private static List getQualifiedSymbols(List String parent = i > 0 ? pathArray[i - 1] : null; SymbolKind expectedKind = i < pathArray.length - 1 ? SymbolKind.Module : kind; - List symbols = getSymbols(languageServers, name, parent, expectedKind); + List symbols = getSymbols(languageServer, name, parent, expectedKind); List currents; if (parents != null) { List matches = new ArrayList<>(); @@ -150,30 +155,27 @@ private static List getQualifiedSymbols(List return parents; } - private static List getSymbols(List languageServers, String name, String parent, + private static List getSymbols(LanguageServerWrapper languageServer, final String name, String parent, SymbolKind kind) { List result = new ArrayList<>(); - for (LanguageServer server : languageServers) { - WorkspaceSymbolParams params = new WorkspaceSymbolParams(name); - CompletableFuture, List>> symbols = server - .getWorkspaceService().symbol(params); - - try { - List items = (List) symbols.get(10, TimeUnit.SECONDS).get(); - if (items != null) { - for (Object item : items) { - SymbolInformation match = getMatchingItem(item, name, parent, kind); - if (match != null) { - result.add(match); - } + WorkspaceSymbolParams params = new WorkspaceSymbolParams(name); + CompletableFuture, List>> symbols = languageServer.execute(ls -> ls.getWorkspaceService().symbol(params)); + + try { + List items = (List) symbols.get(10, TimeUnit.SECONDS).get(); + if (items != null) { + for (Object item : items) { + SymbolInformation match = getMatchingItem(item, name, parent, kind); + if (match != null) { + result.add(match); } } - } catch (ExecutionException | TimeoutException e) { - LanguageServerPlugin.logError(e); - } catch (InterruptedException e) { - LanguageServerPlugin.logError(e); } + } catch (ExecutionException | TimeoutException e) { + LanguageServerPlugin.logError(e); + } catch (InterruptedException e) { + LanguageServerPlugin.logError(e); } return result; } diff --git a/repository/corrosion.product b/repository/corrosion.product index c9184a8..369c991 100644 --- a/repository/corrosion.product +++ b/repository/corrosion.product @@ -201,7 +201,7 @@ United States, other countries, or both. - +