Adopt API removal in LSP4E
This commit is contained in:
@@ -32,8 +32,6 @@ import org.springframework.tooling.boot.ls.prefs.LiveInformationPreferencePage;
|
||||
*/
|
||||
public class BootLanguageServerPlugin extends AbstractUIPlugin {
|
||||
|
||||
public static String BOOT_LS_DEFINITION_ID = "org.eclipse.languageserver.languages.springboot";
|
||||
|
||||
public static String PLUGIN_ID = "org.springframework.tooling.boot.ls";
|
||||
|
||||
private static final Object LSP4E_COMMAND_SYMBOL_IN_WORKSPACE = "org.eclipse.lsp4e.symbolinworkspace";
|
||||
@@ -41,6 +39,8 @@ public class BootLanguageServerPlugin extends AbstractUIPlugin {
|
||||
// The shared instance
|
||||
private static BootLanguageServerPlugin plugin;
|
||||
|
||||
public static final String BOOT_LS_DEFINITION_ID = "org.eclipse.languageserver.languages.springboot";
|
||||
|
||||
public BootLanguageServerPlugin() {
|
||||
// Empty
|
||||
}
|
||||
|
||||
@@ -25,7 +25,6 @@ import org.springframework.tooling.jdt.ls.commons.Logger;
|
||||
@SuppressWarnings("restriction")
|
||||
public class Startup implements IStartup {
|
||||
|
||||
private static final String BOOT_LS_DEFINITION_ID = "org.eclipse.languageserver.languages.springboot";
|
||||
private boolean started;
|
||||
|
||||
@Override
|
||||
@@ -41,7 +40,7 @@ public class Startup implements IStartup {
|
||||
if (!started && !springProjects.isEmpty()) {
|
||||
BootLanguageServerPlugin.getDefault().getLog().info("Starting Boot LS...");
|
||||
LanguageServerDefinition serverDefinition = LanguageServersRegistry.getInstance()
|
||||
.getDefinition(BOOT_LS_DEFINITION_ID);
|
||||
.getDefinition(BootLanguageServerPlugin.BOOT_LS_DEFINITION_ID);
|
||||
|
||||
try {
|
||||
LanguageServiceAccessor.startLanguageServer(serverDefinition);
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*******************************************************************************
|
||||
* Copyright (c) 2019 Pivotal, Inc.
|
||||
* Copyright (c) 2019, 2023 Pivotal, Inc.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
@@ -18,12 +18,12 @@ import java.util.Random;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import org.eclipse.jdt.annotation.NonNull;
|
||||
import org.eclipse.jface.resource.ImageDescriptor;
|
||||
import org.eclipse.lsp4e.LanguageServiceAccessor;
|
||||
import org.eclipse.lsp4e.LanguageServers;
|
||||
import org.eclipse.lsp4e.LanguageServersRegistry;
|
||||
import org.eclipse.lsp4j.ExecuteCommandParams;
|
||||
import org.eclipse.lsp4j.services.LanguageServer;
|
||||
import org.eclipse.ui.quickaccess.QuickAccessElement;
|
||||
import org.springframework.tooling.boot.ls.BootLanguageServerPlugin;
|
||||
|
||||
/**
|
||||
* @author Martin Lippert
|
||||
@@ -79,12 +79,6 @@ public class LiveProcessCommandElement extends QuickAccessElement {
|
||||
|
||||
@Override
|
||||
public void execute() {
|
||||
List<@NonNull LanguageServer> usedLanguageServers = LanguageServiceAccessor.getActiveLanguageServers(serverCapabilities -> true);
|
||||
|
||||
if (usedLanguageServers.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
|
||||
ExecuteCommandParams commandParams = new ExecuteCommandParams();
|
||||
commandParams.setCommand(this.action);
|
||||
|
||||
@@ -94,10 +88,15 @@ public class LiveProcessCommandElement extends QuickAccessElement {
|
||||
arguments.add(argumentMap);
|
||||
|
||||
commandParams.setArguments(arguments);
|
||||
|
||||
List<CompletableFuture<Object>> futures = LanguageServers
|
||||
.forProject(null)
|
||||
.excludeInactive()
|
||||
.withPreferredServer(LanguageServersRegistry.getInstance().getDefinition(BootLanguageServerPlugin.BOOT_LS_DEFINITION_ID))
|
||||
.computeAll(ls -> ls.getWorkspaceService().executeCommand(commandParams));
|
||||
|
||||
try {
|
||||
CompletableFuture.allOf(usedLanguageServers.stream().map(ls ->
|
||||
ls.getWorkspaceService().executeCommand(commandParams)).toArray(CompletableFuture[]::new)).get(2, TimeUnit.SECONDS);
|
||||
CompletableFuture.allOf(futures.toArray(CompletableFuture[]::new)).get(2, TimeUnit.SECONDS);
|
||||
}
|
||||
catch (Exception e) {
|
||||
// TODO: better exception handling
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*******************************************************************************
|
||||
* Copyright (c) 2019 Pivotal, Inc.
|
||||
* Copyright (c) 2019, 2023 Pivotal, Inc.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
@@ -19,12 +19,15 @@ import java.util.concurrent.TimeUnit;
|
||||
|
||||
import org.eclipse.core.runtime.IProgressMonitor;
|
||||
import org.eclipse.jdt.annotation.NonNull;
|
||||
import org.eclipse.lsp4e.LanguageServiceAccessor;
|
||||
import org.eclipse.jdt.annotation.Nullable;
|
||||
import org.eclipse.lsp4e.LanguageServers;
|
||||
import org.eclipse.lsp4e.LanguageServersRegistry;
|
||||
import org.eclipse.lsp4j.ExecuteCommandParams;
|
||||
import org.eclipse.lsp4j.services.LanguageServer;
|
||||
import org.eclipse.ui.quickaccess.IQuickAccessComputer;
|
||||
import org.eclipse.ui.quickaccess.IQuickAccessComputerExtension;
|
||||
import org.eclipse.ui.quickaccess.QuickAccessElement;
|
||||
import org.springframework.tooling.boot.ls.BootLanguageServerPlugin;
|
||||
|
||||
/**
|
||||
* @author Martin Lippert
|
||||
@@ -50,23 +53,24 @@ public class LiveProcessCommandsQuickAccessProvider implements IQuickAccessCompu
|
||||
|
||||
@Override
|
||||
public QuickAccessElement[] computeElements(String query, IProgressMonitor monitor) {
|
||||
this.usedLanguageServers = LanguageServiceAccessor.getActiveLanguageServers(serverCapabilities -> true);
|
||||
|
||||
if (usedLanguageServers.isEmpty()) {
|
||||
return new QuickAccessElement[0];
|
||||
}
|
||||
|
||||
ExecuteCommandParams commandParams = new ExecuteCommandParams();
|
||||
commandParams.setCommand(LiveProcessCommandElement.COMMAND_LIST_PROCESSES);
|
||||
|
||||
List<QuickAccessElement> res = Collections.synchronizedList(new ArrayList<>());
|
||||
|
||||
usedLanguageServers = new ArrayList<>();
|
||||
@NonNull
|
||||
List<@NonNull CompletableFuture<@Nullable Void>> futures = LanguageServers
|
||||
.forProject(null)
|
||||
.excludeInactive()
|
||||
.withPreferredServer(LanguageServersRegistry.getInstance().getDefinition(BootLanguageServerPlugin.BOOT_LS_DEFINITION_ID))
|
||||
.computeAll(ls -> {
|
||||
usedLanguageServers.add(ls);
|
||||
return ls.getWorkspaceService().executeCommand(commandParams).thenAcceptAsync(commandResult ->
|
||||
createCommandItems(res, commandResult));
|
||||
});
|
||||
try {
|
||||
CompletableFuture.allOf(usedLanguageServers.stream().map(ls ->
|
||||
ls.getWorkspaceService().executeCommand(commandParams).thenAcceptAsync(commandResult ->
|
||||
createCommandItems(res, commandResult))).toArray(CompletableFuture[]::new)).get(2000, TimeUnit.MILLISECONDS);
|
||||
}
|
||||
catch (Exception e) {
|
||||
CompletableFuture.allOf(futures.toArray(new CompletableFuture[futures.size()])).get(2000, TimeUnit.MILLISECONDS);
|
||||
} catch (Exception e) {
|
||||
// TODO: better error handling
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
@@ -17,9 +17,9 @@ import java.util.concurrent.TimeUnit;
|
||||
|
||||
import org.eclipse.core.runtime.IProgressMonitor;
|
||||
import org.eclipse.jface.resource.ImageDescriptor;
|
||||
import org.eclipse.lsp4e.LanguageServiceAccessor;
|
||||
import org.eclipse.lsp4e.LanguageServers;
|
||||
import org.eclipse.lsp4e.LanguageServersRegistry;
|
||||
import org.eclipse.lsp4j.ExecuteCommandParams;
|
||||
import org.eclipse.lsp4j.services.LanguageServer;
|
||||
import org.eclipse.ui.quickaccess.IQuickAccessComputer;
|
||||
import org.eclipse.ui.quickaccess.IQuickAccessComputerExtension;
|
||||
import org.eclipse.ui.quickaccess.QuickAccessElement;
|
||||
@@ -60,20 +60,19 @@ public class SpringQuickAccessProvider implements IQuickAccessComputer, IQuickAc
|
||||
|
||||
@Override
|
||||
public void execute() {
|
||||
List<LanguageServer> usedLanguageServers = LanguageServiceAccessor.getActiveLanguageServers(serverCapabilities -> true);
|
||||
|
||||
if (usedLanguageServers.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
|
||||
ExecuteCommandParams commandParams = new ExecuteCommandParams();
|
||||
commandParams.setCommand(commandId);
|
||||
|
||||
commandParams.setArguments(Collections.emptyList());
|
||||
|
||||
List<CompletableFuture<Object>> futures = LanguageServers
|
||||
.forProject(null)
|
||||
.excludeInactive()
|
||||
.withPreferredServer(LanguageServersRegistry.getInstance().getDefinition(BootLanguageServerPlugin.BOOT_LS_DEFINITION_ID))
|
||||
.computeAll(ls -> ls.getWorkspaceService().executeCommand(commandParams));
|
||||
|
||||
try {
|
||||
CompletableFuture.allOf(usedLanguageServers.stream().map(ls ->
|
||||
ls.getWorkspaceService().executeCommand(commandParams)).toArray(CompletableFuture[]::new)).get(2, TimeUnit.SECONDS);
|
||||
CompletableFuture.allOf(futures.toArray(CompletableFuture[]::new)).get(2, TimeUnit.SECONDS);
|
||||
}
|
||||
catch (Exception e) {
|
||||
BootLanguageServerPlugin.getDefault().getLog().error(errorMsg, e);
|
||||
|
||||
Reference in New Issue
Block a user