diff --git a/plugins/plugin-java/che-plugin-java-ext-lang-client/src/main/java/org/eclipse/che/ide/ext/java/client/action/ReimportMavenDependenciesAction.java b/plugins/plugin-java/che-plugin-java-ext-lang-client/src/main/java/org/eclipse/che/ide/ext/java/client/action/ReimportMavenDependenciesAction.java index f2aa8c0b7c2..17d1e963ce0 100644 --- a/plugins/plugin-java/che-plugin-java-ext-lang-client/src/main/java/org/eclipse/che/ide/ext/java/client/action/ReimportMavenDependenciesAction.java +++ b/plugins/plugin-java/che-plugin-java-ext-lang-client/src/main/java/org/eclipse/che/ide/ext/java/client/action/ReimportMavenDependenciesAction.java @@ -83,21 +83,6 @@ public void actionPerformed(ActionEvent e) { javaLanguageExtensionServiceClient .reImportMavenProjects(paramsDto) - .then( - updatedProjects -> { - for (final String path : updatedProjects) { - appContext - .getWorkspaceRoot() - .getContainer(path) - .then( - container -> { - if (container.isPresent()) { - container.get().synchronize(); - } - }); - } - // TODO update error markers in poms if needed - }) .catchError( error -> { notificationManager.notify( diff --git a/plugins/plugin-java/che-plugin-java-server/src/main/java/org/eclipse/che/plugin/java/languageserver/JavaLanguageServerLauncher.java b/plugins/plugin-java/che-plugin-java-server/src/main/java/org/eclipse/che/plugin/java/languageserver/JavaLanguageServerLauncher.java index 923bfae95c2..da4f2efdd7b 100644 --- a/plugins/plugin-java/che-plugin-java-server/src/main/java/org/eclipse/che/plugin/java/languageserver/JavaLanguageServerLauncher.java +++ b/plugins/plugin-java/che-plugin-java-server/src/main/java/org/eclipse/che/plugin/java/languageserver/JavaLanguageServerLauncher.java @@ -10,8 +10,10 @@ */ package org.eclipse.che.plugin.java.languageserver; +import static java.util.Collections.singletonList; import static org.eclipse.che.api.languageserver.LanguageServiceUtils.removePrefixUri; import static org.eclipse.che.api.languageserver.util.JsonUtil.convertToJson; +import static org.eclipse.che.jdt.ls.extension.api.Commands.CLIENT_UPDATE_PROJECT; import static org.eclipse.che.jdt.ls.extension.api.Commands.CLIENT_UPDATE_PROJECTS_CLASSPATH; import com.google.inject.Inject; @@ -122,12 +124,22 @@ public CompletableFuture executeClientCommand(ExecuteCommandParams param } private ExecuteCommandParams convertParams(ExecuteCommandParams params) { - if (CLIENT_UPDATE_PROJECTS_CLASSPATH.equals(params.getCommand())) { - List fixedPathList = new ArrayList<>(); - for (Object uri : params.getArguments()) { - fixedPathList.add(removePrefixUri(convertToJson(uri).getAsString())); - } - params.setArguments(fixedPathList); + String command = params.getCommand(); + switch (command) { + case CLIENT_UPDATE_PROJECTS_CLASSPATH: + List fixedPathList = new ArrayList<>(params.getArguments().size()); + for (Object uri : params.getArguments()) { + fixedPathList.add(removePrefixUri(convertToJson(uri).getAsString())); + } + params.setArguments(fixedPathList); + break; + case CLIENT_UPDATE_PROJECT: + Object projectUri = params.getArguments().get(0); + params.setArguments( + singletonList(removePrefixUri(convertToJson(projectUri).getAsString()))); + break; + default: + break; } return params; } diff --git a/plugins/plugin-languageserver/che-plugin-languageserver-ide/src/main/java/org/eclipse/che/plugin/languageserver/ide/service/ExecuteClientCommandProcessor.java b/plugins/plugin-languageserver/che-plugin-languageserver-ide/src/main/java/org/eclipse/che/plugin/languageserver/ide/service/ExecuteClientCommandProcessor.java index ee297cbb0ec..09b1c709177 100644 --- a/plugins/plugin-languageserver/che-plugin-languageserver-ide/src/main/java/org/eclipse/che/plugin/languageserver/ide/service/ExecuteClientCommandProcessor.java +++ b/plugins/plugin-languageserver/che-plugin-languageserver-ide/src/main/java/org/eclipse/che/plugin/languageserver/ide/service/ExecuteClientCommandProcessor.java @@ -10,10 +10,14 @@ */ package org.eclipse.che.plugin.languageserver.ide.service; +import static org.eclipse.che.jdt.ls.extension.api.Commands.CLIENT_UPDATE_PROJECT; +import static org.eclipse.che.jdt.ls.extension.api.Commands.CLIENT_UPDATE_PROJECTS_CLASSPATH; + import com.google.gwt.json.client.JSONString; import com.google.inject.Inject; import com.google.inject.Singleton; import com.google.web.bindery.event.shared.EventBus; +import org.eclipse.che.ide.api.app.AppContext; import org.eclipse.che.ide.project.node.ProjectClasspathChangedEvent; import org.eclipse.lsp4j.ExecuteCommandParams; @@ -25,24 +29,42 @@ */ @Singleton public class ExecuteClientCommandProcessor { - private static final String CLIENT_UPDATE_PROJECTS_CLASSPATH = - "che.jdt.ls.extension.workspace.clientUpdateProjectsClasspath"; - private EventBus eventBus; + private AppContext appContext; @Inject - public ExecuteClientCommandProcessor(EventBus eventBus) { + public ExecuteClientCommandProcessor(EventBus eventBus, AppContext appContext) { this.eventBus = eventBus; + this.appContext = appContext; } public void execute(ExecuteCommandParams params) { - if (CLIENT_UPDATE_PROJECTS_CLASSPATH.equals(params.getCommand())) { - for (Object project : params.getArguments()) { - eventBus.fireEvent(new ProjectClasspathChangedEvent(stringValue(project))); - } + switch (params.getCommand()) { + case CLIENT_UPDATE_PROJECTS_CLASSPATH: + for (Object project : params.getArguments()) { + eventBus.fireEvent(new ProjectClasspathChangedEvent(stringValue(project))); + } + break; + case CLIENT_UPDATE_PROJECT: + updateProject(stringValue(params.getArguments())); + break; + default: + break; } } + private void updateProject(String project) { + appContext + .getWorkspaceRoot() + .getContainer(project) + .then( + container -> { + if (container.isPresent()) { + container.get().synchronize(); + } + }); + } + private String stringValue(Object value) { return value instanceof JSONString ? ((JSONString) value).stringValue() : String.valueOf(value); }