Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GLSP-1380: Remove dependency to Guava #244

Merged
merged 3 commits into from
Aug 30, 2024
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
156 changes: 156 additions & 0 deletions examples/org.eclipse.glsp.example.workflow/dependency-reduced-pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,156 @@
<?xml version="1.0" encoding="UTF-8"?>
martin-fleck-at marked this conversation as resolved.
Show resolved Hide resolved
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<parent>
<artifactId>org.eclipse.glsp.parent</artifactId>
<groupId>org.eclipse.glsp</groupId>
<version>2.3.0-SNAPSHOT</version>
<relativePath>../../pom.xml</relativePath>
</parent>
<modelVersion>4.0.0</modelVersion>
<groupId>org.eclipse.glsp.example</groupId>
<artifactId>org.eclipse.glsp.example.workflow</artifactId>
<packaging>${package-type}</packaging>
<description>GLSP Workflow Server</description>
<url>https://www.eclipse.org/glsp</url>
<developers>
<developer>
<name>Eclipse GLSP Project</name>
<email>[email protected]</email>
<organization>Eclipse GLSP</organization>
<organizationUrl>https://projects.eclipse.org/projects/ecd.glsp</organizationUrl>
</developer>
</developers>
<licenses>
<license>
<name>Eclipse Public License - v 2.0</name>
<url>http://www.eclipse.org/legal/epl-v20.html</url>
<distribution>repo</distribution>
</license>
</licenses>
<scm>
<connection>scm:[email protected]:eclipse-glsp/glsp-server.git</connection>
<developerConnection>scm:[email protected]:eclipse-glsp/glsp-server.git</developerConnection>
<url>https://github.com/eclipse-glsp/glsp-server</url>
</scm>
<profiles>
<profile>
<id>m2</id>
<build>
<plugins>
<plugin>
<artifactId>maven-deploy-plugin</artifactId>
<version>${maven.deploy.version}</version>
<configuration>
<skip>false</skip>
</configuration>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>build-helper-maven-plugin</artifactId>
<version>${buildhelper.maven.version}</version>
<executions>
<execution>
<id>add-resource</id>
<phase>generate-resources</phase>
<goals>
<goal>add-resource</goal>
</goals>
<configuration>
<resources>
<resource>
<directory>model</directory>
<targetPath>model</targetPath>
</resource>
</resources>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
<properties>
<package-type>jar</package-type>
</properties>
</profile>
<profile>
<id>fatjar</id>
<build>
<plugins>
<plugin>
<artifactId>maven-shade-plugin</artifactId>
<version>${maven.shade.version}</version>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
</execution>
</executions>
<configuration>
<transformers>
<transformer>
<mainClass>org.eclipse.glsp.example.workflow.launch.WorkflowServerLauncher</mainClass>
<manifestEntries>
<Multi-Release>true</Multi-Release>
</manifestEntries>
</transformer>
</transformers>
<artifactSet>
<excludes>
<exclude>jakarta.websocket:jakarta.websocket-api</exclude>
<exclude>javax.websocket:javax.websocket-api</exclude>
<exclude>log4j:log4j</exclude>
</excludes>
</artifactSet>
<filters>
<filter>
<artifact>*:*</artifact>
<excludes>
<exclude>META-INF/MANIFEST.MF</exclude>
<exclude>META-INF/DEPENDENCIES</exclude>
<exclude>META-INF/ECLIPSE_*</exclude>
<exclude>META-INF/LICENSE*</exclude>
<exclude>META-INF/services/javax.servlet.ServletContainerInitializer</exclude>
<exclude>META-INF/services/jakarta.servlet.ServletContainerInitializer*</exclude>
<exclude>META-INF/services/org.eclipse.jetty.webapp.Configuration*</exclude>
<exclude>META-INF/services/org.eclipse.elk.core.data.ILayoutMetaDataProvider*</exclude>
<exclude>META-INF/versions/9/module-info.class</exclude>
<exclude>META-INF/NOTICE*</exclude>
<exclude>.options</exclude>
<exclude>.api_description</exclude>
<exclude>*.profile</exclude>
<exclude>*.html</exclude>
<exclude>about.*</exclude>
<exclude>about_files/*</exclude>
<exclude>plugin.xml</exclude>
<exclude>modeling32.png</exclude>
<exclude>systembundle.properties</exclude>
<exclude>profile.list</exclude>
<exclude>module-info.class</exclude>
<exclude>plugin.properties</exclude>
<exclude>**/*._trace</exclude>
<exclude>**/*.g</exclude>
<exclude>**/*.tokens</exclude>
<exclude>**/*.mwe2</exclude>
<exclude>**/*.xtext</exclude>
<exclude>**/*.xtextbin</exclude>
<exclude>META-INF/*.SF</exclude>
<exclude>META-INF/*.RSA</exclude>
<exclude>META-INF/*.INF</exclude>
</excludes>
</filter>
</filters>
<shadedArtifactAttached>true</shadedArtifactAttached>
<shadedClassifierName>glsp</shadedClassifierName>
<minimizeJar>false</minimizeJar>
</configuration>
</plugin>
</plugins>
</build>
</profile>
</profiles>
<properties>
<package-type>eclipse-plugin</package-type>
</properties>
</project>
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,10 @@
import static org.eclipse.glsp.graph.DefaultTypes.EDGE;
import static org.eclipse.glsp.graph.util.GraphUtil.point;

import java.util.ArrayList;
import java.util.HashSet;
import java.util.Iterator;
import java.util.LinkedHashSet;
import java.util.List;
import java.util.Optional;
import java.util.Set;
Expand All @@ -38,8 +41,6 @@
import org.eclipse.glsp.server.operations.DeleteOperation;
import org.eclipse.glsp.server.types.EditorContext;

import com.google.common.collect.Lists;
import com.google.common.collect.Sets;
import com.google.inject.Inject;

public class WorkflowCommandPaletteActionProvider implements CommandPaletteActionProvider {
Expand All @@ -50,7 +51,7 @@ public class WorkflowCommandPaletteActionProvider implements CommandPaletteActio
@Override
@SuppressWarnings("checkstyle:CyclomaticComplexity")
public List<LabeledAction> getActions(final EditorContext editorContext) {
List<LabeledAction> actions = Lists.newArrayList();
List<LabeledAction> actions = new ArrayList<>();
if (modelState.isReadonly()) {
return actions;
}
Expand All @@ -60,20 +61,22 @@ public List<LabeledAction> getActions(final EditorContext editorContext) {
Set<GModelElement> selectedElements = index.getAll(selectedIds);

// Create node actions are always possible
actions.addAll(Sets.newHashSet(
new LabeledAction("Create Automated Task", Lists.newArrayList(
actions.addAll(new HashSet<>(Set.of(
new LabeledAction("Create Automated Task", new ArrayList<>(List.of(
new CreateNodeOperation(ModelTypes.AUTOMATED_TASK,
lastMousePosition.orElse(point(0, 0)), "fa-plus-square"))),
lastMousePosition.orElse(point(0, 0)), "fa-plus-square")))),
new LabeledAction("Create Manual Task",
Lists.newArrayList(new CreateNodeOperation(ModelTypes.MANUAL_TASK, lastMousePosition.orElse(point(0, 0)),
"fa-plus-square"))),
new ArrayList<>(
List.of(new CreateNodeOperation(ModelTypes.MANUAL_TASK, lastMousePosition.orElse(point(0, 0)),
"fa-plus-square")))),
new LabeledAction("Create Merge Node",
Lists.newArrayList(new CreateNodeOperation(ModelTypes.MERGE_NODE, lastMousePosition.orElse(point(0, 0)),
"fa-plus-square"))),
new LabeledAction("Create Decision Node", Lists.newArrayList(new CreateNodeOperation(
ModelTypes.DECISION_NODE, lastMousePosition.orElse(point(0, 0)), "fa-plus-square"))),
new LabeledAction("Create Category", Lists.newArrayList(new CreateNodeOperation(
ModelTypes.CATEGORY, lastMousePosition.orElse(point(0, 0)), "fa-plus-square")))));
new ArrayList<>(
List.of(new CreateNodeOperation(ModelTypes.MERGE_NODE, lastMousePosition.orElse(point(0, 0)),
"fa-plus-square")))),
new LabeledAction("Create Decision Node", new ArrayList<>(List.of(new CreateNodeOperation(
ModelTypes.DECISION_NODE, lastMousePosition.orElse(point(0, 0)), "fa-plus-square")))),
new LabeledAction("Create Category", new ArrayList<>(List.of(new CreateNodeOperation(
ModelTypes.CATEGORY, lastMousePosition.orElse(point(0, 0)), "fa-plus-square")))))));

// Create edge actions between two nodes
if (selectedElements.size() == 1) {
Expand All @@ -96,17 +99,19 @@ public List<LabeledAction> getActions(final EditorContext editorContext) {
// Delete action
if (selectedElements.size() == 1) {
actions
.add(new LabeledAction("Delete", Lists.newArrayList(new DeleteOperation(selectedIds)), "fa-minus-square"));
.add(new LabeledAction("Delete", new ArrayList<>(List.of(new DeleteOperation(selectedIds))),
"fa-minus-square"));
} else if (selectedElements.size() > 1) {
actions.add(
new LabeledAction("Delete All", Lists.newArrayList(new DeleteOperation(selectedIds)), "fa-minus-square"));
new LabeledAction("Delete All", new ArrayList<>(List.of(new DeleteOperation(selectedIds))),
"fa-minus-square"));
}

return actions;
}

private Set<LabeledAction> createEdgeActions(final GNode source, final Set<? extends GNode> targets) {
Set<LabeledAction> actions = Sets.newLinkedHashSet();
Set<LabeledAction> actions = new LinkedHashSet<>();
// add first all edge, then all weighted edge actions to keep a nice order
targets.forEach(node -> actions.add(createEdgeAction("Create Edge to " + getLabel(node), source, node)));
targets.forEach(node -> actions
Expand All @@ -115,13 +120,13 @@ private Set<LabeledAction> createEdgeActions(final GNode source, final Set<? ext
}

private LabeledAction createWeightedEdgeAction(final String label, final GNode source, final GNode node) {
return new LabeledAction(label, Lists.newArrayList(
new CreateEdgeOperation(ModelTypes.WEIGHTED_EDGE, source.getId(), node.getId())), "fa-plus-square");
return new LabeledAction(label, new ArrayList<>(List.of(
new CreateEdgeOperation(ModelTypes.WEIGHTED_EDGE, source.getId(), node.getId()))), "fa-plus-square");
}

private LabeledAction createEdgeAction(final String label, final GNode source, final GNode node) {
return new LabeledAction(label, Lists.newArrayList(
new CreateEdgeOperation(EDGE, source.getId(), node.getId())), "fa-plus-square");
return new LabeledAction(label, new ArrayList<>(List.of(
new CreateEdgeOperation(EDGE, source.getId(), node.getId()))), "fa-plus-square");
}

private String getLabel(final GNode node) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
import static org.eclipse.glsp.example.workflow.utils.ModelTypes.AUTOMATED_TASK;
import static org.eclipse.glsp.example.workflow.utils.ModelTypes.MANUAL_TASK;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
Expand All @@ -30,7 +31,6 @@
import org.eclipse.glsp.server.model.GModelState;
import org.eclipse.glsp.server.operations.CreateNodeOperation;

import com.google.common.collect.Lists;
import com.google.inject.Inject;

public class WorkflowContextMenuItemProvider implements ContextMenuItemProvider {
Expand All @@ -50,7 +50,7 @@ public List<MenuItem> getItems(final List<String> selectedElementIds, final GPoi
MenuItem newManTask = new MenuItem("newManualTask", "Manual Task",
Arrays.asList(new CreateNodeOperation(MANUAL_TASK, snappedPosition)), true);
MenuItem newChildMenu = new MenuItem("new", "New", Arrays.asList(newAutTask, newManTask), "add", "0_new");
return Lists.newArrayList(newChildMenu);
return new ArrayList<>(List.of(newChildMenu));
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
********************************************************************************/
package org.eclipse.glsp.example.workflow.taskedit;

import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Optional;
Expand All @@ -26,7 +27,6 @@
import org.eclipse.glsp.server.model.GModelState;
import org.eclipse.glsp.server.types.EditorContext;

import com.google.common.collect.Lists;
import com.google.inject.Inject;

public class TaskEditContextActionProvider implements ContextActionsProvider {
Expand All @@ -51,18 +51,20 @@ public List<? extends LabeledAction> getActions(final EditorContext editorContex
}
if (text.startsWith(TYPE_PREFIX)) {
String id = taskNode.get().getId();
return Lists.newArrayList(
new LabeledAction("type:automated", Lists.newArrayList(new EditTaskOperation(id, "taskType", "automated"))),
new LabeledAction("type:manual", Lists.newArrayList(new EditTaskOperation(id, "taskType", "manual"))));
return new ArrayList<>(List.of(
new LabeledAction("type:automated",
new ArrayList<>(List.of(new EditTaskOperation(id, "taskType", "automated")))),
new LabeledAction("type:manual",
new ArrayList<>(List.of(new EditTaskOperation(id, "taskType", "manual"))))));
}
if (text.startsWith(DURATION_PREFIX)) {
return Collections.emptyList();
}
String taskType = taskNode.get().getType().substring(TASK_PREFIX.length());
int duration = taskNode.get().getDuration();
return Lists.newArrayList(
return new ArrayList<>(List.of(
new SetAutoCompleteValueAction("type:", "", TYPE_PREFIX + taskType),
new SetAutoCompleteValueAction("duration:", "", DURATION_PREFIX + duration));
new SetAutoCompleteValueAction("duration:", "", DURATION_PREFIX + duration)));
}

}
3 changes: 1 addition & 2 deletions plugins/org.eclipse.glsp.graph/META-INF/MANIFEST.MF
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,7 @@ Automatic-Module-Name: org.eclipse.glsp.graph
Bundle-RequiredExecutionEnvironment: JavaSE-17
Require-Bundle: org.eclipse.emf.common;bundle-version="2.23.0",
com.google.gson;bundle-version="2.8.7",
org.eclipse.emf.ecore;bundle-version="2.25.0";visibility:=reexport,
com.google.guava;bundle-version="[30.1.0,33.0.0)";visibility:=reexport
org.eclipse.emf.ecore;bundle-version="2.25.0";visibility:=reexport
Export-Package: org.eclipse.glsp.graph,
org.eclipse.glsp.graph,
org.eclipse.glsp.graph.builder,
Expand Down
5 changes: 0 additions & 5 deletions plugins/org.eclipse.glsp.graph/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -42,11 +42,6 @@
</properties>

<dependencies>
<dependency>
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
<version>${google.guava.version}</version>
</dependency>
<dependency>
<groupId>org.eclipse.emf</groupId>
<artifactId>org.eclipse.emf.common</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
import java.io.IOException;
import java.lang.reflect.Field;
import java.lang.reflect.Modifier;
import java.util.ArrayList;
import java.util.Collection;
import java.util.HashSet;
import java.util.List;
Expand All @@ -33,7 +34,6 @@
import org.eclipse.emf.ecore.EStructuralFeature;
import org.eclipse.glsp.graph.GModelElement;

import com.google.common.collect.Lists;
import com.google.gson.Gson;
import com.google.gson.JsonElement;
import com.google.gson.TypeAdapter;
Expand Down Expand Up @@ -92,7 +92,7 @@ protected GModelElement createInstance(final String type) {
protected Optional<EClass> findEClassForType(final String type) {
EClass eClass = typeMap.get(type);
if (eClass == null) {
List<String> subtypes = Lists.newArrayList(type.split(delimiter));
List<String> subtypes = new ArrayList<>(List.of(type.split(delimiter)));
while (eClass == null && !subtypes.isEmpty()) {
subtypes.remove(subtypes.size() - 1);
eClass = typeMap.get(String.join(delimiter, subtypes));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,6 @@
import org.eclipse.glsp.graph.GModelIndex;
import org.eclipse.glsp.graph.GModelRoot;

import com.google.common.base.Preconditions;

/**
* Default implementation of {@link GModelIndex}. Registers itself as adapter of the {@link GModelRoot}
* to receive change notifications. This enables auto updating of the internal index if a child elements is
Expand All @@ -54,7 +52,9 @@ public class GModelIndexImpl extends ECrossReferenceAdapter implements GModelInd
protected final GModelElement root;

public GModelIndexImpl(final EObject target) {
Preconditions.checkArgument(target instanceof GModelElement);
if (!(target instanceof GModelElement)) {
throw new IllegalArgumentException();
}
this.root = (GModelElement) target;
addIfGModelElement(target);
}
Expand Down
Loading
Loading