CHE-6910: Use JDT-LS to update maven projects (#7972)
Signed-off-by: Mykola Morhun <mmorhun@redhat.com>6.19.x
parent
bb2758d149
commit
9511583998
|
|
@ -131,6 +131,10 @@
|
|||
<artifactId>che-plugin-languageserver-ide</artifactId>
|
||||
<type>gwt-lib</type>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.eclipse.che.plugin</groupId>
|
||||
<artifactId>che-plugin-maven-shared</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.eclipse.che.plugin</groupId>
|
||||
<artifactId>che-plugin-orion-compare</artifactId>
|
||||
|
|
|
|||
|
|
@ -487,4 +487,17 @@ public interface JavaLocalizationConstant extends Messages {
|
|||
|
||||
@Key("formatter.preferences.import.button")
|
||||
String formatterPreferencesImportButton();
|
||||
|
||||
// Maven
|
||||
@Key("action.effectivePom.title")
|
||||
String actionGetEffectivePomTitle();
|
||||
|
||||
@Key("action.effectivePom.description")
|
||||
String actionGetEffectivePomDescription();
|
||||
|
||||
@Key("action.reimportDependencies.title")
|
||||
String actionReimportDependenciesTitle();
|
||||
|
||||
@Key("action.reimportDependencies.description")
|
||||
String actionReimportDependenciesDescription();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,40 @@
|
|||
/*
|
||||
* Copyright (c) 2012-2017 Red Hat, 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
|
||||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*
|
||||
* Contributors:
|
||||
* Red Hat, Inc. - initial API and implementation
|
||||
*/
|
||||
package org.eclipse.che.ide.ext.java.client;
|
||||
|
||||
import com.google.gwt.resources.client.ClientBundle;
|
||||
import com.google.gwt.resources.client.CssResource;
|
||||
import org.vectomatic.dom.svg.ui.SVGResource;
|
||||
|
||||
/**
|
||||
* Client resources.
|
||||
*
|
||||
* @author Ann Shumilova
|
||||
*/
|
||||
public interface MavenResources extends ClientBundle {
|
||||
@Source("svg/maven.svg")
|
||||
SVGResource maven();
|
||||
|
||||
@Source("svg/maven-command-type.svg")
|
||||
SVGResource mavenCommandType();
|
||||
|
||||
@Source({"maven.css", "org/eclipse/che/ide/api/ui/style.css"})
|
||||
MavenCss css();
|
||||
|
||||
interface MavenCss extends CssResource {
|
||||
|
||||
String editorInfoPanel();
|
||||
|
||||
String downloadLink();
|
||||
|
||||
String editorMessage();
|
||||
}
|
||||
}
|
||||
|
|
@ -9,14 +9,13 @@
|
|||
* Contributors:
|
||||
* Red Hat, Inc. - initial API and implementation
|
||||
*/
|
||||
package org.eclipse.che.plugin.maven.client.actions;
|
||||
package org.eclipse.che.ide.ext.java.client.action;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
import static com.google.common.base.Preconditions.checkState;
|
||||
import static org.eclipse.che.ide.api.notification.StatusNotification.DisplayMode.EMERGE_MODE;
|
||||
import static org.eclipse.che.ide.api.notification.StatusNotification.Status.FAIL;
|
||||
import static org.eclipse.che.ide.part.perspectives.project.ProjectPerspective.PROJECT_PERSPECTIVE_ID;
|
||||
import static org.eclipse.che.plugin.maven.shared.MavenAttributes.MAVEN_ID;
|
||||
|
||||
import com.google.inject.Inject;
|
||||
import com.google.inject.Singleton;
|
||||
|
|
@ -33,10 +32,10 @@ import org.eclipse.che.ide.api.notification.NotificationManager;
|
|||
import org.eclipse.che.ide.api.resources.Project;
|
||||
import org.eclipse.che.ide.api.resources.Resource;
|
||||
import org.eclipse.che.ide.api.resources.SyntheticFile;
|
||||
import org.eclipse.che.ide.ext.java.client.JavaLocalizationConstant;
|
||||
import org.eclipse.che.ide.ext.java.client.MavenResources;
|
||||
import org.eclipse.che.ide.ext.java.client.service.JavaLanguageExtensionServiceClient;
|
||||
import org.eclipse.che.ide.resource.Path;
|
||||
import org.eclipse.che.plugin.maven.client.MavenLocalizationConstant;
|
||||
import org.eclipse.che.plugin.maven.client.MavenResources;
|
||||
import org.eclipse.che.plugin.maven.shared.MavenAttributes;
|
||||
|
||||
/**
|
||||
|
|
@ -55,7 +54,7 @@ public class GetEffectivePomAction extends AbstractPerspectiveAction {
|
|||
|
||||
@Inject
|
||||
public GetEffectivePomAction(
|
||||
MavenLocalizationConstant constant,
|
||||
JavaLocalizationConstant localization,
|
||||
MavenResources mavenResources,
|
||||
EditorAgent editorAgent,
|
||||
NotificationManager notificationManager,
|
||||
|
|
@ -63,8 +62,8 @@ public class GetEffectivePomAction extends AbstractPerspectiveAction {
|
|||
AppContext appContext) {
|
||||
super(
|
||||
Collections.singletonList(PROJECT_PERSPECTIVE_ID),
|
||||
constant.actionGetEffectivePomTitle(),
|
||||
constant.actionGetEffectivePomDescription(),
|
||||
localization.actionGetEffectivePomTitle(),
|
||||
localization.actionGetEffectivePomDescription(),
|
||||
mavenResources.maven());
|
||||
this.editorAgent = editorAgent;
|
||||
this.notificationManager = notificationManager;
|
||||
|
|
@ -86,7 +85,7 @@ public class GetEffectivePomAction extends AbstractPerspectiveAction {
|
|||
return;
|
||||
}
|
||||
|
||||
event.getPresentation().setEnabledAndVisible(project.isTypeOf(MAVEN_ID));
|
||||
event.getPresentation().setEnabledAndVisible(project.isTypeOf(MavenAttributes.MAVEN_ID));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
@ -95,7 +94,7 @@ public class GetEffectivePomAction extends AbstractPerspectiveAction {
|
|||
checkNotNull(resource);
|
||||
|
||||
final Project project = resource.getProject();
|
||||
checkState(MAVEN_ID.equals(project.getType()));
|
||||
checkState(MavenAttributes.MAVEN_ID.equals(project.getType()));
|
||||
|
||||
javaLanguageExtensionServiceClient
|
||||
.effectivePom(project.getLocation().toString())
|
||||
|
|
@ -9,14 +9,12 @@
|
|||
* Contributors:
|
||||
* Red Hat, Inc. - initial API and implementation
|
||||
*/
|
||||
package org.eclipse.che.plugin.maven.client.actions;
|
||||
package org.eclipse.che.ide.ext.java.client.action;
|
||||
|
||||
import static org.eclipse.che.ide.api.notification.StatusNotification.DisplayMode.EMERGE_MODE;
|
||||
import static org.eclipse.che.ide.api.notification.StatusNotification.Status.FAIL;
|
||||
import static org.eclipse.che.ide.part.perspectives.project.ProjectPerspective.PROJECT_PERSPECTIVE_ID;
|
||||
import static org.eclipse.che.plugin.maven.shared.MavenAttributes.MAVEN_ID;
|
||||
|
||||
import com.google.common.base.Optional;
|
||||
import com.google.inject.Inject;
|
||||
import com.google.inject.Singleton;
|
||||
import java.util.ArrayList;
|
||||
|
|
@ -25,9 +23,6 @@ import java.util.HashSet;
|
|||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import javax.validation.constraints.NotNull;
|
||||
import org.eclipse.che.api.promises.client.Operation;
|
||||
import org.eclipse.che.api.promises.client.OperationException;
|
||||
import org.eclipse.che.api.promises.client.PromiseError;
|
||||
import org.eclipse.che.ide.Resources;
|
||||
import org.eclipse.che.ide.api.action.AbstractPerspectiveAction;
|
||||
import org.eclipse.che.ide.api.action.ActionEvent;
|
||||
|
|
@ -35,36 +30,43 @@ import org.eclipse.che.ide.api.app.AppContext;
|
|||
import org.eclipse.che.ide.api.notification.NotificationManager;
|
||||
import org.eclipse.che.ide.api.resources.Project;
|
||||
import org.eclipse.che.ide.api.resources.Resource;
|
||||
import org.eclipse.che.plugin.maven.client.MavenLocalizationConstant;
|
||||
import org.eclipse.che.plugin.maven.client.service.MavenServerServiceClient;
|
||||
import org.eclipse.che.ide.dto.DtoFactory;
|
||||
import org.eclipse.che.ide.ext.java.client.JavaLocalizationConstant;
|
||||
import org.eclipse.che.ide.ext.java.client.service.JavaLanguageExtensionServiceClient;
|
||||
import org.eclipse.che.jdt.ls.extension.api.dto.ReImportMavenProjectsCommandParameters;
|
||||
import org.eclipse.che.plugin.maven.shared.MavenAttributes;
|
||||
|
||||
/**
|
||||
* Action for reimport maven dependencies.
|
||||
*
|
||||
* @author Roman Nikitenko
|
||||
* @author Mykola Morhun
|
||||
*/
|
||||
@Singleton
|
||||
public class ReimportMavenDependenciesAction extends AbstractPerspectiveAction {
|
||||
|
||||
private final AppContext appContext;
|
||||
private final NotificationManager notificationManager;
|
||||
private final MavenServerServiceClient mavenServerServiceClient;
|
||||
private final JavaLanguageExtensionServiceClient javaLanguageExtensionServiceClient;
|
||||
private final DtoFactory dtoFactory;
|
||||
|
||||
@Inject
|
||||
public ReimportMavenDependenciesAction(
|
||||
MavenLocalizationConstant constant,
|
||||
AppContext appContext,
|
||||
NotificationManager notificationManager,
|
||||
Resources resources,
|
||||
MavenServerServiceClient mavenServerServiceClient) {
|
||||
JavaLanguageExtensionServiceClient javaLanguageExtensionServiceClient,
|
||||
DtoFactory dtoFactory,
|
||||
JavaLocalizationConstant localization) {
|
||||
super(
|
||||
Collections.singletonList(PROJECT_PERSPECTIVE_ID),
|
||||
constant.actionReimportDependenciesTitle(),
|
||||
constant.actionReimportDependenciesDescription(),
|
||||
localization.actionReimportDependenciesTitle(),
|
||||
localization.actionReimportDependenciesDescription(),
|
||||
resources.refresh());
|
||||
this.appContext = appContext;
|
||||
this.notificationManager = notificationManager;
|
||||
this.mavenServerServiceClient = mavenServerServiceClient;
|
||||
this.javaLanguageExtensionServiceClient = javaLanguageExtensionServiceClient;
|
||||
this.dtoFactory = dtoFactory;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
@ -74,18 +76,35 @@ public class ReimportMavenDependenciesAction extends AbstractPerspectiveAction {
|
|||
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
mavenServerServiceClient
|
||||
.reImportProjects(getPathsToSelectedMavenProject())
|
||||
.catchError(
|
||||
new Operation<PromiseError>() {
|
||||
@Override
|
||||
public void apply(PromiseError arg) throws OperationException {
|
||||
notificationManager.notify(
|
||||
"Problem with reimporting maven dependencies",
|
||||
arg.getMessage(),
|
||||
FAIL,
|
||||
EMERGE_MODE);
|
||||
ReImportMavenProjectsCommandParameters paramsDto =
|
||||
dtoFactory
|
||||
.createDto(ReImportMavenProjectsCommandParameters.class)
|
||||
.withProjectsToUpdate(getPathsToSelectedMavenProject());
|
||||
|
||||
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(
|
||||
"Problem with reimporting maven dependencies",
|
||||
error.getMessage(),
|
||||
FAIL,
|
||||
EMERGE_MODE);
|
||||
});
|
||||
}
|
||||
|
||||
|
|
@ -104,10 +123,10 @@ public class ReimportMavenDependenciesAction extends AbstractPerspectiveAction {
|
|||
Set<String> paths = new HashSet<>();
|
||||
|
||||
for (Resource resource : resources) {
|
||||
final Optional<Project> project = resource.getRelatedProject();
|
||||
final Project project = resource.getProject();
|
||||
|
||||
if (project.isPresent() && project.get().isTypeOf(MAVEN_ID)) {
|
||||
paths.add(project.get().getLocation().toString());
|
||||
if (project != null && project.isTypeOf(MavenAttributes.MAVEN_ID)) {
|
||||
paths.add(project.getLocation().toString());
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -13,6 +13,7 @@ package org.eclipse.che.ide.ext.java.client.service;
|
|||
import static org.eclipse.che.api.promises.client.js.JsPromiseError.create;
|
||||
import static org.eclipse.che.ide.api.jsonrpc.Constants.WS_AGENT_JSON_RPC_ENDPOINT_ID;
|
||||
import static org.eclipse.che.ide.ext.java.shared.Constants.CLASS_PATH_TREE;
|
||||
import static org.eclipse.che.ide.ext.java.shared.Constants.EFFECTIVE_POM;
|
||||
import static org.eclipse.che.ide.ext.java.shared.Constants.EFFECTIVE_POM_REQUEST_TIMEOUT;
|
||||
import static org.eclipse.che.ide.ext.java.shared.Constants.EXTERNAL_LIBRARIES;
|
||||
import static org.eclipse.che.ide.ext.java.shared.Constants.EXTERNAL_LIBRARIES_CHILDREN;
|
||||
|
|
@ -20,6 +21,8 @@ import static org.eclipse.che.ide.ext.java.shared.Constants.EXTERNAL_LIBRARY_CHI
|
|||
import static org.eclipse.che.ide.ext.java.shared.Constants.EXTERNAL_LIBRARY_ENTRY;
|
||||
import static org.eclipse.che.ide.ext.java.shared.Constants.EXTERNAL_NODE_CONTENT;
|
||||
import static org.eclipse.che.ide.ext.java.shared.Constants.FILE_STRUCTURE;
|
||||
import static org.eclipse.che.ide.ext.java.shared.Constants.REIMPORT_MAVEN_PROJECTS;
|
||||
import static org.eclipse.che.ide.ext.java.shared.Constants.REIMPORT_MAVEN_PROJECTS_REQUEST_TIMEOUT;
|
||||
import static org.eclipse.che.ide.ext.java.shared.Constants.REQUEST_TIMEOUT;
|
||||
|
||||
import com.google.gwt.jsonp.client.TimeoutException;
|
||||
|
|
@ -36,6 +39,7 @@ import org.eclipse.che.jdt.ls.extension.api.dto.ExternalLibrariesParameters;
|
|||
import org.eclipse.che.jdt.ls.extension.api.dto.FileStructureCommandParameters;
|
||||
import org.eclipse.che.jdt.ls.extension.api.dto.Jar;
|
||||
import org.eclipse.che.jdt.ls.extension.api.dto.JarEntry;
|
||||
import org.eclipse.che.jdt.ls.extension.api.dto.ReImportMavenProjectsCommandParameters;
|
||||
import org.eclipse.che.plugin.languageserver.ide.service.ServiceUtil;
|
||||
|
||||
@Singleton
|
||||
|
|
@ -75,7 +79,7 @@ public class JavaLanguageExtensionServiceClient {
|
|||
requestTransmitter
|
||||
.newRequest()
|
||||
.endpointId(WS_AGENT_JSON_RPC_ENDPOINT_ID)
|
||||
.methodName("java/effective-pom")
|
||||
.methodName(EFFECTIVE_POM)
|
||||
.paramsAsString(pathToProject)
|
||||
.sendAndReceiveResultAsString(EFFECTIVE_POM_REQUEST_TIMEOUT)
|
||||
.onSuccess(resolve::apply)
|
||||
|
|
@ -86,6 +90,27 @@ public class JavaLanguageExtensionServiceClient {
|
|||
.onFailure(error -> reject.apply(ServiceUtil.getPromiseError(error))));
|
||||
}
|
||||
|
||||
/**
|
||||
* Updates specified maven projects.
|
||||
*
|
||||
* @param params contains list of paths to projects which should be reimported
|
||||
* @return list of paths to updated projects
|
||||
*/
|
||||
public Promise<List<String>> reImportMavenProjects(
|
||||
ReImportMavenProjectsCommandParameters params) {
|
||||
return Promises.create(
|
||||
(resolve, reject) ->
|
||||
requestTransmitter
|
||||
.newRequest()
|
||||
.endpointId(WS_AGENT_JSON_RPC_ENDPOINT_ID)
|
||||
.methodName(REIMPORT_MAVEN_PROJECTS)
|
||||
.paramsAsDto(params)
|
||||
.sendAndReceiveResultAsListOfString(REIMPORT_MAVEN_PROJECTS_REQUEST_TIMEOUT)
|
||||
.onSuccess(resolve::apply)
|
||||
.onTimeout(() -> reject.apply(create("Failed to update maven project.")))
|
||||
.onFailure(error -> reject.apply(ServiceUtil.getPromiseError(error))));
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets external libraries of the project.
|
||||
*
|
||||
|
|
|
|||
|
|
@ -205,3 +205,9 @@ formatter.preferences.workspace.label=Workspace
|
|||
formatter.preferences.workspace.description=Import For Workspace
|
||||
formatter.preferences.label=Import Code Formatter
|
||||
formatter.preferences.import.button=Import
|
||||
|
||||
################ Maven #############
|
||||
action.effectivePom.title = Generate Effective Pom
|
||||
action.effectivePom.description = Generate effective pom for current project
|
||||
action.reimportDependencies.title = Reimport
|
||||
action.reimportDependencies.description = Reimport maven dependencies
|
||||
|
|
|
|||
|
|
@ -0,0 +1,26 @@
|
|||
/**
|
||||
* Copyright (c) 2012-2017 Red Hat, 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
|
||||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*
|
||||
* Contributors:
|
||||
* Red Hat, Inc. - initial API and implementation
|
||||
*/
|
||||
.editorInfoPanel {
|
||||
width: 100%;
|
||||
height: 20px;
|
||||
}
|
||||
|
||||
.editorMessage {
|
||||
float: left;
|
||||
padding-left: 10px;
|
||||
padding-right: 10px;
|
||||
}
|
||||
|
||||
.downloadLink {
|
||||
text-decoration: underline;
|
||||
cursor:pointer;
|
||||
color: primaryButtonBackground;
|
||||
}
|
||||
|
|
@ -0,0 +1,20 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!--
|
||||
|
||||
Copyright (c) 2012-2017 Red Hat, 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
|
||||
http://www.eclipse.org/legal/epl-v10.html
|
||||
|
||||
Contributors:
|
||||
Red Hat, Inc. - initial API and implementation
|
||||
|
||||
-->
|
||||
<svg width="352px" height="246px" viewBox="0 0 352 246" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
|
||||
<g stroke="none" stroke-width="1" fill="none" fill-rule="evenodd">
|
||||
<g fill="#D8D8D8">
|
||||
<path d="M0,7.99283665 C0,3.57851486 3.5840954,0 7.99230925,0 L344.007691,0 C348.421721,0 352,3.5723605 352,7.99283665 L352,238.007163 C352,242.421485 348.415905,246 344.007691,246 L7.99230925,246 C3.57827873,246 0,242.427639 0,238.007163 L0,7.99283665 Z M151.960111,68.9457064 L128.310249,45.2958449 C127.388366,44.3739613 125.828255,44.3739613 124.906371,45.2958449 L48.8864267,121.280332 C47.964543,122.202216 47.964543,123.762327 48.8864267,124.684211 L124.906371,200.704156 C125.828255,201.626039 127.388366,201.626039 128.310249,200.704156 L151.960111,177.054294 C152.881995,176.13241 152.881995,174.5723 151.960111,173.650416 L103.029363,124.719668 C102.107479,123.797784 102.107479,122.237673 103.029363,121.315789 L151.960111,72.3495846 C152.881995,71.4277009 152.881995,69.8675901 151.960111,68.9457064 Z M227.129086,45.2958449 C226.207202,44.3739613 224.647091,44.3739613 223.725208,45.2958449 L147.811634,121.173961 C146.889751,122.095845 146.889751,123.655956 147.811634,124.577839 L171.461496,148.263158 C172.38338,149.185042 173.94349,149.185042 174.865374,148.263158 L223.725208,99.4033242 C224.647091,98.4814405 226.207202,98.4814405 227.129086,99.4033242 L249.006094,121.280332 C249.927978,122.202216 249.927978,123.762327 249.006094,124.684211 L200.075346,173.614959 C199.153463,174.536843 199.153463,176.096953 200.075346,177.018837 L223.725208,200.668699 C224.647091,201.590582 226.207202,201.590582 227.129086,200.668699 L303.113573,124.684211 C304.035457,123.762327 304.035457,122.202216 303.113573,121.280332 L227.129086,45.2958449 Z"></path>
|
||||
</g>
|
||||
</g>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 2.2 KiB |
|
|
@ -0,0 +1,25 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!--
|
||||
|
||||
Copyright (c) 2012-2017 Red Hat, 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
|
||||
http://www.eclipse.org/legal/epl-v10.html
|
||||
|
||||
Contributors:
|
||||
Red Hat, Inc. - initial API and implementation
|
||||
|
||||
-->
|
||||
<svg version="1.1" id="pomFile" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
|
||||
width="16px" height="16px" viewBox="7 5 18 18" enable-background="new 0 0 32 32" xml:space="preserve">
|
||||
<g>
|
||||
<path fill-rule="evenodd" clip-rule="evenodd" fill="#3193D4" d="M12.52,12.441c0.83-0.934,1.95-1.802,3.272-1.691
|
||||
c1.108,0.005,1.985,0.879,2.267,1.904c1.015-1.361,2.828-2.389,4.525-1.7c1.342,0.535,1.539,2.203,1.358,3.454
|
||||
c-0.357,2.29-0.807,4.565-1.2,6.85c-0.982,0.01-1.964,0.006-2.946,0.006c0.372-2.121,0.765-4.239,1.139-6.358
|
||||
c0.068-0.556,0.136-1.38-0.507-1.623c-1.095-0.324-1.991,0.669-2.313,1.609c-0.655,2.068-0.825,4.253-1.276,6.37
|
||||
c-0.979,0.003-1.957,0.005-2.937-0.004c0.354-2.39,0.994-4.747,1.144-7.16c0.073-0.745-0.777-1.042-1.372-0.812
|
||||
c-1.044,0.339-1.484,1.488-1.726,2.461c-0.373,1.832-0.655,3.681-1.01,5.517C9.958,21.265,8.979,21.265,8,21.262
|
||||
c0.609-3.423,1.218-6.847,1.836-10.269c0.98-0.007,1.959-0.003,2.938-0.001C12.691,11.474,12.603,11.957,12.52,12.441z"/>
|
||||
</g>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 1.5 KiB |
|
|
@ -32,6 +32,7 @@ public final class Constants {
|
|||
// LS requests timeout constants
|
||||
public static final int REQUEST_TIMEOUT = 10_000;
|
||||
public static final int EFFECTIVE_POM_REQUEST_TIMEOUT = 30_000;
|
||||
public static final int REIMPORT_MAVEN_PROJECTS_REQUEST_TIMEOUT = 60_000;
|
||||
|
||||
// JSON RPC methods
|
||||
public static final String FILE_STRUCTURE = "java/filestructure";
|
||||
|
|
@ -41,6 +42,8 @@ public final class Constants {
|
|||
public static final String EXTERNAL_LIBRARY_ENTRY = "java/libraryEntry";
|
||||
public static final String EXTERNAL_NODE_CONTENT = "java/libraryNodeContentByPath";
|
||||
public static final String CLASS_PATH_TREE = "java/classpathTree";
|
||||
public static final String EFFECTIVE_POM = "java/effective-pom";
|
||||
public static final String REIMPORT_MAVEN_PROJECTS = "java/reimport-maven-projects";
|
||||
|
||||
private Constants() {
|
||||
throw new UnsupportedOperationException("Unused constructor.");
|
||||
|
|
|
|||
|
|
@ -13,7 +13,9 @@ package org.eclipse.che.plugin.java.languageserver;
|
|||
import static java.util.Collections.emptyList;
|
||||
import static java.util.Collections.singletonList;
|
||||
import static org.eclipse.che.api.languageserver.service.LanguageServiceUtils.prefixURI;
|
||||
import static org.eclipse.che.api.languageserver.service.LanguageServiceUtils.removePrefixUri;
|
||||
import static org.eclipse.che.ide.ext.java.shared.Constants.CLASS_PATH_TREE;
|
||||
import static org.eclipse.che.ide.ext.java.shared.Constants.EFFECTIVE_POM;
|
||||
import static org.eclipse.che.ide.ext.java.shared.Constants.EFFECTIVE_POM_REQUEST_TIMEOUT;
|
||||
import static org.eclipse.che.ide.ext.java.shared.Constants.EXTERNAL_LIBRARIES;
|
||||
import static org.eclipse.che.ide.ext.java.shared.Constants.EXTERNAL_LIBRARIES_CHILDREN;
|
||||
|
|
@ -21,6 +23,8 @@ import static org.eclipse.che.ide.ext.java.shared.Constants.EXTERNAL_LIBRARY_CHI
|
|||
import static org.eclipse.che.ide.ext.java.shared.Constants.EXTERNAL_LIBRARY_ENTRY;
|
||||
import static org.eclipse.che.ide.ext.java.shared.Constants.EXTERNAL_NODE_CONTENT;
|
||||
import static org.eclipse.che.ide.ext.java.shared.Constants.FILE_STRUCTURE;
|
||||
import static org.eclipse.che.ide.ext.java.shared.Constants.REIMPORT_MAVEN_PROJECTS;
|
||||
import static org.eclipse.che.ide.ext.java.shared.Constants.REIMPORT_MAVEN_PROJECTS_REQUEST_TIMEOUT;
|
||||
import static org.eclipse.che.jdt.ls.extension.api.Commands.FILE_STRUCTURE_COMMAND;
|
||||
import static org.eclipse.che.jdt.ls.extension.api.Commands.FIND_TESTS_FROM_ENTRY_COMMAND;
|
||||
import static org.eclipse.che.jdt.ls.extension.api.Commands.FIND_TESTS_FROM_FOLDER_COMMAND;
|
||||
|
|
@ -35,6 +39,7 @@ import static org.eclipse.che.jdt.ls.extension.api.Commands.GET_LIBRARY_CHILDREN
|
|||
import static org.eclipse.che.jdt.ls.extension.api.Commands.GET_LIBRARY_ENTRY_COMMAND;
|
||||
import static org.eclipse.che.jdt.ls.extension.api.Commands.GET_LIBRARY_NODE_CONTENT_BY_PATH_COMMAND;
|
||||
import static org.eclipse.che.jdt.ls.extension.api.Commands.GET_OUTPUT_DIR_COMMAND;
|
||||
import static org.eclipse.che.jdt.ls.extension.api.Commands.REIMPORT_MAVEN_PROJECTS_COMMAND;
|
||||
import static org.eclipse.che.jdt.ls.extension.api.Commands.RESOLVE_CLASSPATH_COMMAND;
|
||||
import static org.eclipse.che.jdt.ls.extension.api.Commands.TEST_DETECT_COMMAND;
|
||||
|
||||
|
|
@ -48,6 +53,7 @@ import java.lang.reflect.Type;
|
|||
import java.util.ArrayList;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.ListIterator;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
import java.util.concurrent.ExecutionException;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
|
@ -69,6 +75,7 @@ import org.eclipse.che.jdt.ls.extension.api.dto.ExternalLibrariesParameters;
|
|||
import org.eclipse.che.jdt.ls.extension.api.dto.FileStructureCommandParameters;
|
||||
import org.eclipse.che.jdt.ls.extension.api.dto.Jar;
|
||||
import org.eclipse.che.jdt.ls.extension.api.dto.JarEntry;
|
||||
import org.eclipse.che.jdt.ls.extension.api.dto.ReImportMavenProjectsCommandParameters;
|
||||
import org.eclipse.che.jdt.ls.extension.api.dto.ResourceLocation;
|
||||
import org.eclipse.che.jdt.ls.extension.api.dto.TestFindParameters;
|
||||
import org.eclipse.che.jdt.ls.extension.api.dto.TestPosition;
|
||||
|
|
@ -123,11 +130,18 @@ public class JavaLanguageServerExtensionService {
|
|||
|
||||
requestHandler
|
||||
.newConfiguration()
|
||||
.methodName("java/effective-pom")
|
||||
.methodName(EFFECTIVE_POM)
|
||||
.paramsAsString()
|
||||
.resultAsString()
|
||||
.withFunction(this::getEffectivePom);
|
||||
|
||||
requestHandler
|
||||
.newConfiguration()
|
||||
.methodName(REIMPORT_MAVEN_PROJECTS)
|
||||
.paramsAsDto(ReImportMavenProjectsCommandParameters.class)
|
||||
.resultAsListOfString()
|
||||
.withFunction(this::reImportMavenProjects);
|
||||
|
||||
requestHandler
|
||||
.newConfiguration()
|
||||
.methodName(EXTERNAL_LIBRARIES)
|
||||
|
|
@ -361,13 +375,54 @@ public class JavaLanguageServerExtensionService {
|
|||
Type targetClassType = new TypeToken<String>() {}.getType();
|
||||
try {
|
||||
return gson.fromJson(
|
||||
gson.toJson(result.get(EFFECTIVE_POM_REQUEST_TIMEOUT, TimeUnit.SECONDS)),
|
||||
gson.toJson(result.get(EFFECTIVE_POM_REQUEST_TIMEOUT, TimeUnit.MILLISECONDS)),
|
||||
targetClassType);
|
||||
} catch (JsonSyntaxException | InterruptedException | ExecutionException | TimeoutException e) {
|
||||
throw new JsonRpcException(-27000, e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Updates given maven projects.
|
||||
*
|
||||
* @param parameters dto with list of paths to projects (relatively to projects root (e.g.
|
||||
* /projects)) which should be re-imported.
|
||||
* @return list of paths (relatively to projects root) to projects which were updated.
|
||||
*/
|
||||
public List<String> reImportMavenProjects(ReImportMavenProjectsCommandParameters parameters) {
|
||||
final List<String> projectsToReImport = parameters.getProjectsToUpdate();
|
||||
if (projectsToReImport.isEmpty()) {
|
||||
return emptyList();
|
||||
}
|
||||
|
||||
ListIterator<String> iterator = projectsToReImport.listIterator();
|
||||
while (iterator.hasNext()) {
|
||||
iterator.set(prefixURI(iterator.next()));
|
||||
}
|
||||
|
||||
CompletableFuture<Object> requestResult =
|
||||
executeCommand(REIMPORT_MAVEN_PROJECTS_COMMAND, singletonList(parameters));
|
||||
|
||||
final List<String> result;
|
||||
Type targetClassType = new TypeToken<ArrayList<String>>() {}.getType();
|
||||
try {
|
||||
result =
|
||||
gson.fromJson(
|
||||
gson.toJson(
|
||||
requestResult.get(
|
||||
REIMPORT_MAVEN_PROJECTS_REQUEST_TIMEOUT, TimeUnit.MILLISECONDS)),
|
||||
targetClassType);
|
||||
} catch (JsonSyntaxException | InterruptedException | ExecutionException | TimeoutException e) {
|
||||
throw new JsonRpcException(-27000, e.getMessage());
|
||||
}
|
||||
|
||||
iterator = result.listIterator();
|
||||
while (iterator.hasNext()) {
|
||||
iterator.set(removePrefixUri(iterator.next()));
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
private List<Jar> getProjectExternalLibraries(ExternalLibrariesParameters params) {
|
||||
params.setProjectUri(prefixURI(params.getProjectUri()));
|
||||
Type type = new TypeToken<ArrayList<Jar>>() {}.getType();
|
||||
|
|
|
|||
|
|
@ -26,8 +26,8 @@ import org.eclipse.che.ide.api.constraints.Constraints;
|
|||
import org.eclipse.che.ide.api.extension.Extension;
|
||||
import org.eclipse.che.ide.api.filetypes.FileTypeRegistry.FileTypeProvider;
|
||||
import org.eclipse.che.ide.api.project.type.wizard.PreSelectedProjectTypeManager;
|
||||
import org.eclipse.che.plugin.maven.client.actions.GetEffectivePomAction;
|
||||
import org.eclipse.che.plugin.maven.client.actions.ReimportMavenDependenciesAction;
|
||||
import org.eclipse.che.ide.ext.java.client.action.GetEffectivePomAction;
|
||||
import org.eclipse.che.ide.ext.java.client.action.ReimportMavenDependenciesAction;
|
||||
import org.eclipse.che.plugin.maven.client.comunnication.MavenMessagesHandler;
|
||||
import org.eclipse.che.plugin.maven.client.comunnication.progressor.background.DependencyResolverAction;
|
||||
import org.eclipse.che.plugin.maven.client.editor.ClassFileSourcesDownloader;
|
||||
|
|
|
|||
|
|
@ -19,7 +19,7 @@ import org.eclipse.che.ide.api.command.CommandPage;
|
|||
import org.eclipse.che.ide.api.command.CommandType;
|
||||
import org.eclipse.che.ide.api.icon.Icon;
|
||||
import org.eclipse.che.ide.api.icon.IconRegistry;
|
||||
import org.eclipse.che.plugin.maven.client.MavenResources;
|
||||
import org.eclipse.che.ide.ext.java.client.MavenResources;
|
||||
|
||||
/**
|
||||
* Maven command type.
|
||||
|
|
|
|||
|
|
@ -35,10 +35,10 @@ import org.eclipse.che.ide.api.editor.texteditor.TextEditorPartView;
|
|||
import org.eclipse.che.ide.api.notification.NotificationManager;
|
||||
import org.eclipse.che.ide.api.notification.StatusNotification;
|
||||
import org.eclipse.che.ide.api.resources.VirtualFile;
|
||||
import org.eclipse.che.ide.ext.java.client.MavenResources;
|
||||
import org.eclipse.che.ide.ext.java.client.tree.library.JarFileNode;
|
||||
import org.eclipse.che.ide.util.dom.Elements;
|
||||
import org.eclipse.che.plugin.maven.client.MavenLocalizationConstant;
|
||||
import org.eclipse.che.plugin.maven.client.MavenResources;
|
||||
import org.eclipse.che.plugin.maven.client.service.MavenServerServiceClient;
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -17,7 +17,7 @@ import com.google.gwtmockito.GwtMockitoTestRunner;
|
|||
import java.util.Collection;
|
||||
import org.eclipse.che.ide.api.command.CommandPage;
|
||||
import org.eclipse.che.ide.api.icon.IconRegistry;
|
||||
import org.eclipse.che.plugin.maven.client.MavenResources;
|
||||
import org.eclipse.che.ide.ext.java.client.MavenResources;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.mockito.InjectMocks;
|
||||
|
|
|
|||
Loading…
Reference in New Issue