diff --git a/org.eclipse.xtext.ide.tests/xtend-gen/org/eclipse/xtext/ide/tests/server/AbstractTestLangLanguageServerTest.java b/org.eclipse.xtext.ide.tests/src/org/eclipse/xtext/ide/tests/server/AbstractTestLangLanguageServerTest.java
similarity index 60%
rename from org.eclipse.xtext.ide.tests/xtend-gen/org/eclipse/xtext/ide/tests/server/AbstractTestLangLanguageServerTest.java
rename to org.eclipse.xtext.ide.tests/src/org/eclipse/xtext/ide/tests/server/AbstractTestLangLanguageServerTest.java
index cf3388db7..6aeaf4318 100644
--- a/org.eclipse.xtext.ide.tests/xtend-gen/org/eclipse/xtext/ide/tests/server/AbstractTestLangLanguageServerTest.java
+++ b/org.eclipse.xtext.ide.tests/src/org/eclipse/xtext/ide/tests/server/AbstractTestLangLanguageServerTest.java
@@ -1,11 +1,11 @@
-/**
- * Copyright (c) 2016 TypeFox GmbH (http://www.typefox.io) and others.
+/*******************************************************************************
+ * Copyright (c) 2016, 2020 TypeFox GmbH (http://www.typefox.io) and others.
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License 2.0 which is available at
* http://www.eclipse.org/legal/epl-2.0.
- *
+ *
* SPDX-License-Identifier: EPL-2.0
- */
+ *******************************************************************************/
package org.eclipse.xtext.ide.tests.server;
import org.eclipse.xtext.testing.AbstractLanguageServerTest;
@@ -13,9 +13,10 @@ import org.eclipse.xtext.testing.AbstractLanguageServerTest;
/**
* @author akosyakov - Initial contribution and API
*/
-@SuppressWarnings("all")
public abstract class AbstractTestLangLanguageServerTest extends AbstractLanguageServerTest {
- public AbstractTestLangLanguageServerTest() {
- super("testlang");
- }
+
+ public AbstractTestLangLanguageServerTest() {
+ super("testlang");
+ }
+
}
diff --git a/org.eclipse.xtext.ide.tests/src/org/eclipse/xtext/ide/tests/server/AbstractTestLangLanguageServerTest.xtend b/org.eclipse.xtext.ide.tests/src/org/eclipse/xtext/ide/tests/server/AbstractTestLangLanguageServerTest.xtend
deleted file mode 100644
index 64b67f14f..000000000
--- a/org.eclipse.xtext.ide.tests/src/org/eclipse/xtext/ide/tests/server/AbstractTestLangLanguageServerTest.xtend
+++ /dev/null
@@ -1,22 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2016 TypeFox GmbH (http://www.typefox.io) and others.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License 2.0 which is available at
- * http://www.eclipse.org/legal/epl-2.0.
- *
- * SPDX-License-Identifier: EPL-2.0
- *******************************************************************************/
-package org.eclipse.xtext.ide.tests.server
-
-import org.eclipse.xtext.testing.AbstractLanguageServerTest
-
-/**
- * @author akosyakov - Initial contribution and API
- */
-abstract class AbstractTestLangLanguageServerTest extends AbstractLanguageServerTest {
-
- new() {
- super("testlang")
- }
-
-}
\ No newline at end of file
diff --git a/org.eclipse.xtext.ide/src/org/eclipse/xtext/ide/ExecutorServiceProvider.java b/org.eclipse.xtext.ide/src/org/eclipse/xtext/ide/ExecutorServiceProvider.java
new file mode 100644
index 000000000..6175cfd76
--- /dev/null
+++ b/org.eclipse.xtext.ide/src/org/eclipse/xtext/ide/ExecutorServiceProvider.java
@@ -0,0 +1,68 @@
+/**
+ * Copyright (c) 2016, 2020 TypeFox GmbH (http://www.typefox.io) and others.
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License 2.0 which is available at
+ * http://www.eclipse.org/legal/epl-2.0.
+ *
+ * SPDX-License-Identifier: EPL-2.0
+ */
+package org.eclipse.xtext.ide;
+
+import java.util.Map;
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.Executors;
+
+import org.eclipse.xtext.util.DisposableRegistry;
+import org.eclipse.xtext.util.IDisposable;
+
+import com.google.common.collect.Maps;
+import com.google.inject.Inject;
+import com.google.inject.Provider;
+import com.google.inject.Singleton;
+
+/**
+ * Provider for executor services. By calling {@link #dispose()} all created executor services are shut down.
+ *
+ * In some situations it is necessary to use multiple instances of executor services in order to avoid deadlocks. That
+ * can be achieved with the {@link #get(String)} method, which will return a different instance for each key.
+ */
+@Singleton
+public class ExecutorServiceProvider implements Provider, IDisposable {
+ @Inject
+ public void registerTo(DisposableRegistry disposableRegistry) {
+ disposableRegistry.register(this);
+ }
+
+ private final Map instanceCache = Maps.newHashMapWithExpectedSize(3);
+
+ @Override
+ public ExecutorService get() {
+ return get(null);
+ }
+
+ public ExecutorService get(String key) {
+ ExecutorService result = instanceCache.get(key);
+ if (result == null) {
+ synchronized (instanceCache) {
+ result = instanceCache.get(key);
+ if (result == null) {
+ result = createInstance(key);
+ instanceCache.put(key, result);
+ }
+ }
+ }
+ return result;
+ }
+
+ protected ExecutorService createInstance(String key) {
+ return Executors.newCachedThreadPool();
+ }
+
+ @Override
+ public void dispose() {
+ for (ExecutorService executorService : instanceCache.values()) {
+ executorService.shutdown();
+ }
+ instanceCache.clear();
+ }
+}
diff --git a/org.eclipse.xtext.ide/src/org/eclipse/xtext/ide/ExecutorServiceProvider.xtend b/org.eclipse.xtext.ide/src/org/eclipse/xtext/ide/ExecutorServiceProvider.xtend
deleted file mode 100644
index 88818471d..000000000
--- a/org.eclipse.xtext.ide/src/org/eclipse/xtext/ide/ExecutorServiceProvider.xtend
+++ /dev/null
@@ -1,66 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2016, 2017 TypeFox GmbH (http://www.typefox.io) and others.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License 2.0 which is available at
- * http://www.eclipse.org/legal/epl-2.0.
- *
- * SPDX-License-Identifier: EPL-2.0
- *******************************************************************************/
-package org.eclipse.xtext.ide
-
-import com.google.common.collect.Maps
-import com.google.inject.Inject
-import com.google.inject.Provider
-import com.google.inject.Singleton
-import java.util.Map
-import java.util.concurrent.ExecutorService
-import java.util.concurrent.Executors
-import org.eclipse.xtext.util.DisposableRegistry
-import org.eclipse.xtext.util.IDisposable
-
-/**
- * Provider for executor services. By calling {@link #dispose()} all created executor services are shut down.
- *
- * In some situations it is necessary to use multiple instances of executor services in order to avoid deadlocks.
- * That can be achieved with the {@link #get(String)} method, which will return a different instance for each key.
- */
-@Singleton
-class ExecutorServiceProvider implements Provider, IDisposable {
-
- @Inject
- def registerTo(DisposableRegistry disposableRegistry) {
- disposableRegistry.register(this)
- }
-
- val Map instanceCache = Maps.newHashMapWithExpectedSize(3)
-
- override get() {
- get(null)
- }
-
- def ExecutorService get(String key) {
- var result = instanceCache.get(key)
- if (result === null) {
- synchronized (instanceCache) {
- result = instanceCache.get(key)
- if (result === null) {
- result = createInstance(key)
- instanceCache.put(key, result)
- }
- }
- }
- return result
- }
-
- protected def ExecutorService createInstance(String key) {
- Executors.newCachedThreadPool
- }
-
- override dispose() {
- for (executorService : instanceCache.values) {
- executorService.shutdown()
- }
- instanceCache.clear()
- }
-
-}
diff --git a/org.eclipse.xtext.ide/src/org/eclipse/xtext/ide/labels/AlternativeImageDescription.java b/org.eclipse.xtext.ide/src/org/eclipse/xtext/ide/labels/AlternativeImageDescription.java
new file mode 100644
index 000000000..30cbc7ef4
--- /dev/null
+++ b/org.eclipse.xtext.ide/src/org/eclipse/xtext/ide/labels/AlternativeImageDescription.java
@@ -0,0 +1,58 @@
+/**
+ * Copyright (c) 2015, 2020 itemis AG (http://www.itemis.eu) and others.
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License 2.0 which is available at
+ * http://www.eclipse.org/legal/epl-2.0.
+ *
+ * SPDX-License-Identifier: EPL-2.0
+ */
+package org.eclipse.xtext.ide.labels;
+
+import com.google.common.collect.ImmutableList;
+import java.util.List;
+import org.eclipse.xtext.ide.labels.IImageDescription;
+import org.eclipse.xtext.xbase.lib.util.ToStringBuilder;
+
+public class AlternativeImageDescription implements IImageDescription {
+ private final List imageIDs;
+
+ public AlternativeImageDescription(Iterable imageIDs) {
+ this.imageIDs = ImmutableList.copyOf(imageIDs);
+ }
+
+ @Override
+ public int hashCode() {
+ final int prime = 31;
+ int result = 1;
+ result = prime * result + ((imageIDs == null) ? 0 : imageIDs.hashCode());
+ return result;
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj)
+ return true;
+ if (obj == null)
+ return false;
+ if (getClass() != obj.getClass())
+ return false;
+ AlternativeImageDescription other = (AlternativeImageDescription) obj;
+ if (imageIDs == null) {
+ if (other.imageIDs != null)
+ return false;
+ } else if (!imageIDs.equals(other.imageIDs))
+ return false;
+ return true;
+ }
+
+ @Override
+ public String toString() {
+ ToStringBuilder b = new ToStringBuilder(this);
+ b.add("imageIDs", imageIDs);
+ return b.toString();
+ }
+
+ public List getImageIDs() {
+ return imageIDs;
+ }
+}
diff --git a/org.eclipse.xtext.ide/src/org/eclipse/xtext/ide/labels/DecoratedImageDescription.java b/org.eclipse.xtext.ide/src/org/eclipse/xtext/ide/labels/DecoratedImageDescription.java
new file mode 100644
index 000000000..d4d40096d
--- /dev/null
+++ b/org.eclipse.xtext.ide/src/org/eclipse/xtext/ide/labels/DecoratedImageDescription.java
@@ -0,0 +1,73 @@
+/**
+ * Copyright (c) 2015, 2020 itemis AG (http://www.itemis.eu) and others.
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License 2.0 which is available at
+ * http://www.eclipse.org/legal/epl-2.0.
+ *
+ * SPDX-License-Identifier: EPL-2.0
+ */
+package org.eclipse.xtext.ide.labels;
+
+import java.util.List;
+
+import org.eclipse.xtext.xbase.lib.util.ToStringBuilder;
+
+import com.google.common.collect.ImmutableList;
+
+public class DecoratedImageDescription implements IImageDescription {
+ private final IImageDescription baseImage;
+
+ private final List decorators;
+
+ public DecoratedImageDescription(IImageDescription baseImage, IImageDescription... decorators) {
+ this.baseImage = baseImage;
+ this.decorators = ImmutableList.copyOf(decorators);
+ }
+
+ @Override
+ public int hashCode() {
+ final int prime = 31;
+ int result = 1;
+ result = prime * result + ((baseImage == null) ? 0 : baseImage.hashCode());
+ result = prime * result + ((decorators == null) ? 0 : decorators.hashCode());
+ return result;
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj)
+ return true;
+ if (obj == null)
+ return false;
+ if (getClass() != obj.getClass())
+ return false;
+ DecoratedImageDescription other = (DecoratedImageDescription) obj;
+ if (baseImage == null) {
+ if (other.baseImage != null)
+ return false;
+ } else if (!baseImage.equals(other.baseImage))
+ return false;
+ if (decorators == null) {
+ if (other.decorators != null)
+ return false;
+ } else if (!decorators.equals(other.decorators))
+ return false;
+ return true;
+ }
+
+ @Override
+ public String toString() {
+ ToStringBuilder b = new ToStringBuilder(this);
+ b.add("baseImage", baseImage);
+ b.add("decorators", decorators);
+ return b.toString();
+ }
+
+ public IImageDescription getBaseImage() {
+ return baseImage;
+ }
+
+ public List getDecorators() {
+ return decorators;
+ }
+}
diff --git a/org.eclipse.xtext.ide/src/org/eclipse/xtext/ide/labels/EClassImageDescriptionProvider.java b/org.eclipse.xtext.ide/src/org/eclipse/xtext/ide/labels/EClassImageDescriptionProvider.java
new file mode 100644
index 000000000..53e57a57e
--- /dev/null
+++ b/org.eclipse.xtext.ide/src/org/eclipse/xtext/ide/labels/EClassImageDescriptionProvider.java
@@ -0,0 +1,37 @@
+/**
+ * Copyright (c) 2015, 2020 itemis AG (http://www.itemis.eu) and others.
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License 2.0 which is available at
+ * http://www.eclipse.org/legal/epl-2.0.
+ *
+ * SPDX-License-Identifier: EPL-2.0
+ */
+package org.eclipse.xtext.ide.labels;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.eclipse.emf.ecore.EClass;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.xtext.resource.IEObjectDescription;
+
+public class EClassImageDescriptionProvider implements IImageDescriptionProvider {
+ @Override
+ public IImageDescription getImageDescription(Object element) {
+ if (element instanceof EClass) {
+ List images = new ArrayList<>();
+ images.add(((EClass) element).getName());
+ for (EClass superType : ((EClass) element).getEAllSuperTypes()) {
+ images.add(superType.getName());
+ }
+ images.add(IImageDescription.DEFAULT.getImageID());
+ return new AlternativeImageDescription(images);
+ } else if (element instanceof EObject) {
+ return getImageDescription(((EObject) element).eClass());
+ } else if (element instanceof IEObjectDescription) {
+ return getImageDescription(((IEObjectDescription) element).getEClass());
+ } else {
+ return IImageDescription.DEFAULT;
+ }
+ }
+}
diff --git a/org.eclipse.xtext.ide/xtend-gen/org/eclipse/xtext/ide/labels/IImageDescription.java b/org.eclipse.xtext.ide/src/org/eclipse/xtext/ide/labels/IImageDescription.java
similarity index 80%
rename from org.eclipse.xtext.ide/xtend-gen/org/eclipse/xtext/ide/labels/IImageDescription.java
rename to org.eclipse.xtext.ide/src/org/eclipse/xtext/ide/labels/IImageDescription.java
index 1d506a4a1..ba6e44475 100644
--- a/org.eclipse.xtext.ide/xtend-gen/org/eclipse/xtext/ide/labels/IImageDescription.java
+++ b/org.eclipse.xtext.ide/src/org/eclipse/xtext/ide/labels/IImageDescription.java
@@ -1,5 +1,5 @@
/**
- * Copyright (c) 2015 itemis AG (http://www.itemis.eu) and others.
+ * Copyright (c) 2015, 2020 itemis AG (http://www.itemis.eu) and others.
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License 2.0 which is available at
* http://www.eclipse.org/legal/epl-2.0.
@@ -8,8 +8,6 @@
*/
package org.eclipse.xtext.ide.labels;
-import org.eclipse.xtext.ide.labels.SimpleImageDescription;
-
/**
* Describes an image in a platform independent way.
* Subclasses should implement {@link Object#equals(Object)} and {@link Object#hashCode()}.
@@ -18,7 +16,6 @@ import org.eclipse.xtext.ide.labels.SimpleImageDescription;
* @noimplement
* @noextend
*/
-@SuppressWarnings("all")
public interface IImageDescription {
static final SimpleImageDescription DEFAULT = new SimpleImageDescription("default");
}
diff --git a/org.eclipse.xtext.ide/src/org/eclipse/xtext/ide/labels/IImageDescription.xtend b/org.eclipse.xtext.ide/src/org/eclipse/xtext/ide/labels/IImageDescription.xtend
deleted file mode 100644
index 5c72f1e89..000000000
--- a/org.eclipse.xtext.ide/src/org/eclipse/xtext/ide/labels/IImageDescription.xtend
+++ /dev/null
@@ -1,51 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2015 itemis AG (http://www.itemis.eu) and others.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License 2.0 which is available at
- * http://www.eclipse.org/legal/epl-2.0.
- *
- * SPDX-License-Identifier: EPL-2.0
- *******************************************************************************/
-package org.eclipse.xtext.ide.labels
-
-import org.eclipse.xtend.lib.annotations.Data
-import java.util.List
-import com.google.common.collect.ImmutableList
-
-/**
- * Describes an image in a platform independent way.
- * Subclasses should implement {@link Object#equals(Object)} and {@link Object#hashCode()}.
- *
- * @author Jan Koehnlein - Initial contribution and API
- * @noimplement
- * @noextend
- */
-interface IImageDescription {
- val DEFAULT = new SimpleImageDescription('default')
-}
-
-@Data
-class SimpleImageDescription implements IImageDescription {
- String imageID
-}
-
-@Data
-class AlternativeImageDescription implements IImageDescription {
- List imageIDs
-
- new(Iterable imageIDs) {
- this.imageIDs = ImmutableList.copyOf(imageIDs)
- }
-}
-
-@Data
-class DecoratedImageDescription implements IImageDescription {
- IImageDescription baseImage
-
- List decorators
-
- new(IImageDescription baseImage, IImageDescription... decorators) {
- this.baseImage = baseImage
- this.decorators = ImmutableList.copyOf(decorators)
- }
-}
\ No newline at end of file
diff --git a/org.eclipse.xtext.ide/xtend-gen/org/eclipse/xtext/ide/labels/IImageDescriptionProvider.java b/org.eclipse.xtext.ide/src/org/eclipse/xtext/ide/labels/IImageDescriptionProvider.java
similarity index 63%
rename from org.eclipse.xtext.ide/xtend-gen/org/eclipse/xtext/ide/labels/IImageDescriptionProvider.java
rename to org.eclipse.xtext.ide/src/org/eclipse/xtext/ide/labels/IImageDescriptionProvider.java
index 0619382f8..4e621dc46 100644
--- a/org.eclipse.xtext.ide/xtend-gen/org/eclipse/xtext/ide/labels/IImageDescriptionProvider.java
+++ b/org.eclipse.xtext.ide/src/org/eclipse/xtext/ide/labels/IImageDescriptionProvider.java
@@ -1,5 +1,5 @@
/**
- * Copyright (c) 2015 itemis AG (http://www.itemis.eu) and others.
+ * Copyright (c) 2015, 2020 itemis AG (http://www.itemis.eu) and others.
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License 2.0 which is available at
* http://www.eclipse.org/legal/epl-2.0.
@@ -9,14 +9,11 @@
package org.eclipse.xtext.ide.labels;
import com.google.inject.ImplementedBy;
-import org.eclipse.xtext.ide.labels.EClassImageDescriptionProvider;
-import org.eclipse.xtext.ide.labels.IImageDescription;
/**
* @author Jan Koehnlein - Initial contribution and API
*/
@ImplementedBy(EClassImageDescriptionProvider.class)
-@SuppressWarnings("all")
public interface IImageDescriptionProvider {
- IImageDescription getImageDescription(final Object element);
+ IImageDescription getImageDescription(Object element);
}
diff --git a/org.eclipse.xtext.ide/src/org/eclipse/xtext/ide/labels/IImageDescriptionProvider.xtend b/org.eclipse.xtext.ide/src/org/eclipse/xtext/ide/labels/IImageDescriptionProvider.xtend
deleted file mode 100644
index b92e9d430..000000000
--- a/org.eclipse.xtext.ide/src/org/eclipse/xtext/ide/labels/IImageDescriptionProvider.xtend
+++ /dev/null
@@ -1,39 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2015 itemis AG (http://www.itemis.eu) and others.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License 2.0 which is available at
- * http://www.eclipse.org/legal/epl-2.0.
- *
- * SPDX-License-Identifier: EPL-2.0
- *******************************************************************************/
-package org.eclipse.xtext.ide.labels
-
-import org.eclipse.emf.ecore.EObject
-import com.google.inject.ImplementedBy
-import org.eclipse.xtext.resource.IEObjectDescription
-import org.eclipse.emf.ecore.EClass
-
-/**
- * @author Jan Koehnlein - Initial contribution and API
- */
-@ImplementedBy(EClassImageDescriptionProvider)
-interface IImageDescriptionProvider {
- def IImageDescription getImageDescription(Object element)
-}
-
-
-class EClassImageDescriptionProvider implements IImageDescriptionProvider {
-
- override getImageDescription(Object element) {
- switch element {
- EClass:
- new AlternativeImageDescription(#[element.name] + element.EAllSuperTypes.map[name] + #[IImageDescription.DEFAULT.imageID])
- EObject:
- element.eClass.imageDescription
- IEObjectDescription:
- element.EClass.imageDescription
- default:
- IImageDescription.DEFAULT
- }
- }
-}
\ No newline at end of file
diff --git a/org.eclipse.xtext.ide/xtend-gen/org/eclipse/xtext/ide/labels/INameLabelProvider.java b/org.eclipse.xtext.ide/src/org/eclipse/xtext/ide/labels/INameLabelProvider.java
similarity index 69%
rename from org.eclipse.xtext.ide/xtend-gen/org/eclipse/xtext/ide/labels/INameLabelProvider.java
rename to org.eclipse.xtext.ide/src/org/eclipse/xtext/ide/labels/INameLabelProvider.java
index 425ac1ea9..2041e6fb4 100644
--- a/org.eclipse.xtext.ide/xtend-gen/org/eclipse/xtext/ide/labels/INameLabelProvider.java
+++ b/org.eclipse.xtext.ide/src/org/eclipse/xtext/ide/labels/INameLabelProvider.java
@@ -1,5 +1,5 @@
/**
- * Copyright (c) 2015 itemis AG (http://www.itemis.eu) and others.
+ * Copyright (c) 2015, 2020 itemis AG (http://www.itemis.eu) and others.
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License 2.0 which is available at
* http://www.eclipse.org/legal/epl-2.0.
@@ -9,13 +9,11 @@
package org.eclipse.xtext.ide.labels;
import com.google.inject.ImplementedBy;
-import org.eclipse.xtext.ide.labels.SimpleNameLabelProvider;
/**
* @author Jan Koehnlein - Initial contribution and API
*/
@ImplementedBy(SimpleNameLabelProvider.class)
-@SuppressWarnings("all")
public interface INameLabelProvider {
- String getNameLabel(final Object element);
+ String getNameLabel(Object element);
}
diff --git a/org.eclipse.xtext.ide/src/org/eclipse/xtext/ide/labels/INameLabelProvider.xtend b/org.eclipse.xtext.ide/src/org/eclipse/xtext/ide/labels/INameLabelProvider.xtend
deleted file mode 100644
index cfc8aab59..000000000
--- a/org.eclipse.xtext.ide/src/org/eclipse/xtext/ide/labels/INameLabelProvider.xtend
+++ /dev/null
@@ -1,36 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2015 itemis AG (http://www.itemis.eu) and others.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License 2.0 which is available at
- * http://www.eclipse.org/legal/epl-2.0.
- *
- * SPDX-License-Identifier: EPL-2.0
- *******************************************************************************/
-package org.eclipse.xtext.ide.labels
-
-import com.google.inject.ImplementedBy
-import org.eclipse.xtext.util.SimpleAttributeResolver
-import org.eclipse.emf.ecore.EObject
-import org.eclipse.xtext.resource.IEObjectDescription
-
-/**
- * @author Jan Koehnlein - Initial contribution and API
- */
-@ImplementedBy(SimpleNameLabelProvider)
-interface INameLabelProvider {
- def String getNameLabel(Object element)
-}
-
-class SimpleNameLabelProvider implements INameLabelProvider {
-
- override getNameLabel(Object element) {
- switch element {
- EObject:
- SimpleAttributeResolver.NAME_RESOLVER.apply(element)
- IEObjectDescription:
- element.name.lastSegment
- default:
- null
- }
- }
-}
\ No newline at end of file
diff --git a/org.eclipse.xtext.ide/src/org/eclipse/xtext/ide/labels/SimpleImageDescription.java b/org.eclipse.xtext.ide/src/org/eclipse/xtext/ide/labels/SimpleImageDescription.java
new file mode 100644
index 000000000..0d3e7a69f
--- /dev/null
+++ b/org.eclipse.xtext.ide/src/org/eclipse/xtext/ide/labels/SimpleImageDescription.java
@@ -0,0 +1,55 @@
+/**
+ * Copyright (c) 2015, 2020 itemis AG (http://www.itemis.eu) and others.
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License 2.0 which is available at
+ * http://www.eclipse.org/legal/epl-2.0.
+ *
+ * SPDX-License-Identifier: EPL-2.0
+ */
+package org.eclipse.xtext.ide.labels;
+
+import org.eclipse.xtext.xbase.lib.util.ToStringBuilder;
+
+public class SimpleImageDescription implements IImageDescription {
+ private final String imageID;
+
+ public SimpleImageDescription(String imageID) {
+ this.imageID = imageID;
+ }
+
+ @Override
+ public int hashCode() {
+ final int prime = 31;
+ int result = 1;
+ result = prime * result + ((imageID == null) ? 0 : imageID.hashCode());
+ return result;
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj)
+ return true;
+ if (obj == null)
+ return false;
+ if (getClass() != obj.getClass())
+ return false;
+ SimpleImageDescription other = (SimpleImageDescription) obj;
+ if (imageID == null) {
+ if (other.imageID != null)
+ return false;
+ } else if (!imageID.equals(other.imageID))
+ return false;
+ return true;
+ }
+
+ @Override
+ public String toString() {
+ ToStringBuilder b = new ToStringBuilder(this);
+ b.add("imageID", imageID);
+ return b.toString();
+ }
+
+ public String getImageID() {
+ return imageID;
+ }
+}
diff --git a/org.eclipse.xtext.ide/src/org/eclipse/xtext/ide/labels/SimpleNameLabelProvider.java b/org.eclipse.xtext.ide/src/org/eclipse/xtext/ide/labels/SimpleNameLabelProvider.java
new file mode 100644
index 000000000..13f8a4595
--- /dev/null
+++ b/org.eclipse.xtext.ide/src/org/eclipse/xtext/ide/labels/SimpleNameLabelProvider.java
@@ -0,0 +1,33 @@
+/**
+ * Copyright (c) 2015, 2020 itemis AG (http://www.itemis.eu) and others.
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License 2.0 which is available at
+ * http://www.eclipse.org/legal/epl-2.0.
+ *
+ * SPDX-License-Identifier: EPL-2.0
+ */
+package org.eclipse.xtext.ide.labels;
+
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.xtext.ide.labels.INameLabelProvider;
+import org.eclipse.xtext.resource.IEObjectDescription;
+import org.eclipse.xtext.util.SimpleAttributeResolver;
+
+public class SimpleNameLabelProvider implements INameLabelProvider {
+
+ /**
+ * Calculates the simple-name based on the type of the passed {@code element}. If the {@code element} is an instance
+ * of {@code EObject}, the value of the {@code name} attribute is returned. If the {@code element} is an instance of
+ * {@code IEObjectDescription}, the value of the {@link QualifiedName#getLastSegment()} is returned. A {@code null}
+ * value is returned otherwise.
+ */
+ @Override
+ public String getNameLabel(Object element) {
+ if (element instanceof EObject) {
+ return SimpleAttributeResolver.NAME_RESOLVER.apply(((EObject) element));
+ } else if (element instanceof IEObjectDescription) {
+ return ((IEObjectDescription) element).getName().getLastSegment();
+ }
+ return null;
+ }
+}
diff --git a/org.eclipse.xtext.ide/src/org/eclipse/xtext/ide/refactoring/IRenameNameValidator.java b/org.eclipse.xtext.ide/src/org/eclipse/xtext/ide/refactoring/IRenameNameValidator.java
new file mode 100644
index 000000000..2cdb66227
--- /dev/null
+++ b/org.eclipse.xtext.ide/src/org/eclipse/xtext/ide/refactoring/IRenameNameValidator.java
@@ -0,0 +1,53 @@
+/*******************************************************************************
+ * Copyright (c) 2017, 2020 TypeFox GmbH (http://www.typefox.io) and others.
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License 2.0 which is available at
+ * http://www.eclipse.org/legal/epl-2.0.
+ *
+ * SPDX-License-Identifier: EPL-2.0
+ *******************************************************************************/
+package org.eclipse.xtext.ide.refactoring;
+
+import com.google.inject.ImplementedBy;
+import com.google.inject.Inject;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.xtext.conversion.IValueConverterService;
+import org.eclipse.xtext.conversion.ValueConverterException;
+
+import static org.eclipse.xtext.ide.refactoring.RefactoringIssueAcceptor.Severity.*;
+
+/**
+ * @author koehnlein - Initial contribution and API
+ * @since 2.13
+ */
+@ImplementedBy(IRenameNameValidator.RuleBasedNameValidator.class)
+public interface IRenameNameValidator {
+
+ void validate(EObject target, String newName, RefactoringIssueAcceptor issues);
+
+ class RuleBasedNameValidator implements IRenameNameValidator {
+
+ @Inject private IValueConverterService valueConverterService;
+
+ @Override
+ public void validate(EObject target, String newName, RefactoringIssueAcceptor issues) {
+ try {
+ getNameAsValue(newName);
+ } catch (ValueConverterException e) {
+ issues.add(FATAL, "Illegal name: " + e.getMessage());
+ }
+ }
+
+ protected String getNameAsText(String nameAsValue) {
+ return valueConverterService.toString(nameAsValue, getRuleName());
+ }
+
+ protected String getNameAsValue(String nameAsText) {
+ return valueConverterService.toValue(nameAsText, getRuleName(), null).toString();
+ }
+
+ protected String getRuleName() {
+ return "ID";
+ }
+ }
+}
diff --git a/org.eclipse.xtext.ide/src/org/eclipse/xtext/ide/refactoring/IRenameNameValidator.xtend b/org.eclipse.xtext.ide/src/org/eclipse/xtext/ide/refactoring/IRenameNameValidator.xtend
deleted file mode 100644
index 30cd04d28..000000000
--- a/org.eclipse.xtext.ide/src/org/eclipse/xtext/ide/refactoring/IRenameNameValidator.xtend
+++ /dev/null
@@ -1,52 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2017 TypeFox GmbH (http://www.typefox.io) and others.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License 2.0 which is available at
- * http://www.eclipse.org/legal/epl-2.0.
- *
- * SPDX-License-Identifier: EPL-2.0
- *******************************************************************************/
-package org.eclipse.xtext.ide.refactoring
-
-import com.google.inject.ImplementedBy
-import com.google.inject.Inject
-import org.eclipse.emf.ecore.EObject
-import org.eclipse.xtext.conversion.IValueConverterService
-import org.eclipse.xtext.conversion.ValueConverterException
-
-import static org.eclipse.xtext.ide.refactoring.RefactoringIssueAcceptor.Severity.*
-
-/**
- * @author koehnlein - Initial contribution and API
- * @since 2.13
- */
-@ImplementedBy(RuleBasedNameValidator)
-interface IRenameNameValidator {
-
- def void validate(EObject target, String newName, RefactoringIssueAcceptor issues)
-
- class RuleBasedNameValidator implements IRenameNameValidator {
-
- @Inject IValueConverterService valueConverterService
-
- override validate(EObject target, String newName, RefactoringIssueAcceptor issues) {
- try {
- getNameAsValue(newName)
- } catch (ValueConverterException e) {
- issues.add(FATAL, '''Illegal name: «e.message»''')
- }
- }
-
- protected def String getNameAsText(String nameAsValue) {
- valueConverterService.toString(nameAsValue, ruleName)
- }
-
- protected def String getNameAsValue(String nameAsText) {
- return valueConverterService.toValue(nameAsText, ruleName, null).toString()
- }
-
- protected def getRuleName() {
- 'ID'
- }
- }
-}
diff --git a/org.eclipse.xtext.ide/src/org/eclipse/xtext/ide/refactoring/IRenameStrategy2.java b/org.eclipse.xtext.ide/src/org/eclipse/xtext/ide/refactoring/IRenameStrategy2.java
new file mode 100644
index 000000000..64cb3bd0a
--- /dev/null
+++ b/org.eclipse.xtext.ide/src/org/eclipse/xtext/ide/refactoring/IRenameStrategy2.java
@@ -0,0 +1,67 @@
+/**
+ * Copyright (c) 2017, 2020 TypeFox GmbH (http://www.typefox.io) and others.
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License 2.0 which is available at
+ * http://www.eclipse.org/legal/epl-2.0.
+ *
+ * SPDX-License-Identifier: EPL-2.0
+ */
+package org.eclipse.xtext.ide.refactoring;
+
+import org.eclipse.emf.ecore.EAttribute;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.ecore.EcorePackage;
+import org.eclipse.xtext.ide.serializer.IChangeSerializer;
+import org.eclipse.xtext.resource.IResourceServiceProvider;
+
+import com.google.inject.Inject;
+
+/**
+ * Called to rename an element in the {@link IChangeSerializer} based refactoring.
+ *
+ * Clients may extend the {@link DefaultImpl} to customize the behavior or implement this interface directly.
+ *
+ * Changes are usually performed in the The {@link RenameContext}
+ *
+ * @author koehnlein - Initial contribution and API
+ * @since 2.13
+ */
+public interface IRenameStrategy2 {
+ class DefaultImpl implements IRenameStrategy2 {
+ @Inject
+ private IResourceServiceProvider resourceServiceProvider;
+
+ public boolean canHandle(RenameChange change) {
+ return resourceServiceProvider.canHandle(change.getTargetURI());
+ }
+
+ @Override
+ public void applyRename(RenameContext context) {
+ for (RenameChange change : context.getChanges()) {
+ if (canHandle(change)) {
+ context.addModification(change, (EObject o) -> doRename(o, change, context));
+ }
+ }
+ }
+
+ protected void doRename(EObject target, RenameChange change, RenameContext context) {
+ EAttribute nameAttribute = getNameEAttribute(target);
+ if (nameAttribute != null) {
+ target.eSet(nameAttribute, change.getNewName());
+ } else {
+ context.getIssues().add(RefactoringIssueAcceptor.Severity.WARNING, "Element of class " + target.eClass().getName() + " cannot be renamed.");
+ }
+ }
+
+ protected EAttribute getNameEAttribute(EObject target) {
+ for (EAttribute attribute : target.eClass().getEAllAttributes()) {
+ if ("name".equals(attribute.getName()) && EcorePackage.Literals.ESTRING == attribute.getEType()) {
+ return attribute;
+ }
+ }
+ return null;
+ }
+ }
+
+ void applyRename(RenameContext context);
+}
diff --git a/org.eclipse.xtext.ide/src/org/eclipse/xtext/ide/refactoring/IRenameStrategy2.xtend b/org.eclipse.xtext.ide/src/org/eclipse/xtext/ide/refactoring/IRenameStrategy2.xtend
deleted file mode 100644
index 1fca9f768..000000000
--- a/org.eclipse.xtext.ide/src/org/eclipse/xtext/ide/refactoring/IRenameStrategy2.xtend
+++ /dev/null
@@ -1,62 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2017 TypeFox GmbH (http://www.typefox.io) and others.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License 2.0 which is available at
- * http://www.eclipse.org/legal/epl-2.0.
- *
- * SPDX-License-Identifier: EPL-2.0
- *******************************************************************************/
-package org.eclipse.xtext.ide.refactoring
-
-import com.google.inject.Inject
-import org.eclipse.emf.ecore.EAttribute
-import org.eclipse.emf.ecore.EObject
-import org.eclipse.emf.ecore.EcorePackage
-import org.eclipse.xtext.ide.refactoring.RefactoringIssueAcceptor.Severity
-import org.eclipse.xtext.ide.serializer.IChangeSerializer
-import org.eclipse.xtext.resource.IResourceServiceProvider
-
-/**
- * Called to rename an element in the {@link IChangeSerializer} based refactoring.
- *
- * Clients may extend the {@link DefaultImpl} to customize the behavior or implement
- * this interface directly.
- *
- * Changes are usually performed in the The {@link RenameContext}
- *
- * @author koehnlein - Initial contribution and API
- * @since 2.13
- */
-interface IRenameStrategy2 {
-
- def void applyRename(RenameContext context)
-
- class DefaultImpl implements IRenameStrategy2 {
-
- @Inject IResourceServiceProvider resourceServiceProvider
-
- def boolean canHandle(RenameChange change) {
- resourceServiceProvider.canHandle(change.targetURI)
- }
-
- override applyRename(RenameContext context) {
- context.changes.filter[ canHandle ].forEach [ change |
- context.addModification(change) [ doRename(change, context) ]
- ]
- }
-
- protected def void doRename(EObject target, RenameChange change, RenameContext context) {
- val nameAttribute = getNameEAttribute(target)
- if (nameAttribute !== null)
- target.eSet(nameAttribute, change.newName)
- else
- context.issues.add(Severity.WARNING, 'Element of class ' + target.eClass.name + ' cannot be renamed.')
- }
-
- protected def EAttribute getNameEAttribute(EObject target) {
- target.eClass.EAllAttributes.filter[name == 'name' && EType == EcorePackage.Literals.ESTRING].head
- }
- }
-}
-
-
diff --git a/org.eclipse.xtext.ide/src/org/eclipse/xtext/ide/refactoring/IResourceRelocationStrategy.xtend b/org.eclipse.xtext.ide/src/org/eclipse/xtext/ide/refactoring/IResourceRelocationStrategy.java
similarity index 88%
rename from org.eclipse.xtext.ide/src/org/eclipse/xtext/ide/refactoring/IResourceRelocationStrategy.xtend
rename to org.eclipse.xtext.ide/src/org/eclipse/xtext/ide/refactoring/IResourceRelocationStrategy.java
index 434db8101..258563953 100644
--- a/org.eclipse.xtext.ide/src/org/eclipse/xtext/ide/refactoring/IResourceRelocationStrategy.xtend
+++ b/org.eclipse.xtext.ide/src/org/eclipse/xtext/ide/refactoring/IResourceRelocationStrategy.java
@@ -1,12 +1,12 @@
/*******************************************************************************
- * Copyright (c) 2017 TypeFox GmbH (http://www.typefox.io) and others.
+ * Copyright (c) 2017, 2020 TypeFox GmbH (http://www.typefox.io) and others.
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License 2.0 which is available at
* http://www.eclipse.org/legal/epl-2.0.
*
* SPDX-License-Identifier: EPL-2.0
*******************************************************************************/
-package org.eclipse.xtext.ide.refactoring
+package org.eclipse.xtext.ide.refactoring;
/**
* Allows a language to execute side-effects when the URI of a resource changes.
@@ -26,9 +26,9 @@ package org.eclipse.xtext.ide.refactoring
* @author koehnlein - Initial contribution and API
* @since 2.13
*/
-interface IResourceRelocationStrategy {
+public interface IResourceRelocationStrategy {
- def void applyChange(ResourceRelocationContext context)
+ void applyChange(ResourceRelocationContext context);
/**
* By overriding this method client implementations may explicitly demand for relying
@@ -50,7 +50,7 @@ interface IResourceRelocationStrategy {
*
* @since 2.18
*/
- def boolean requiresUsageOfPersistedIndex(ResourceRelocationContext context) {
+ default boolean requiresUsageOfPersistedIndex(ResourceRelocationContext context) {
return false;
}
}
diff --git a/org.eclipse.xtext.ide/src/org/eclipse/xtext/ide/refactoring/RefactoringIssueAcceptor.java b/org.eclipse.xtext.ide/src/org/eclipse/xtext/ide/refactoring/RefactoringIssueAcceptor.java
new file mode 100644
index 000000000..5b32ff692
--- /dev/null
+++ b/org.eclipse.xtext.ide/src/org/eclipse/xtext/ide/refactoring/RefactoringIssueAcceptor.java
@@ -0,0 +1,37 @@
+/**
+ * Copyright (c) 2017, 2020 TypeFox GmbH (http://www.typefox.io) and others.
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License 2.0 which is available at
+ * http://www.eclipse.org/legal/epl-2.0.
+ *
+ * SPDX-License-Identifier: EPL-2.0
+ */
+package org.eclipse.xtext.ide.refactoring;
+
+import org.apache.log4j.Logger;
+import org.eclipse.emf.common.util.URI;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.ecore.resource.ResourceSet;
+import org.eclipse.xtext.util.ITextRegion;
+
+/**
+ * @author koehnlein - Initial contribution and API
+ * @since 2.13
+ */
+public interface RefactoringIssueAcceptor {
+ enum Severity {
+ FATAL, ERROR, WARNING, INFO, OK;
+ }
+
+ void add(Severity severity, String message, URI uri, ResourceSet resourceSet);
+
+ void add(Severity severity, String message, URI resourceUri);
+
+ void add(Severity severity, String message, EObject element);
+
+ void add(Severity severity, String message, EObject element, ITextRegion region);
+
+ void add(Severity severity, String message, Exception exc, Logger log);
+
+ void add(Severity severity, String message, Object... params);
+}
diff --git a/org.eclipse.xtext.ide/src/org/eclipse/xtext/ide/refactoring/RefactoringIssueAcceptor.xtend b/org.eclipse.xtext.ide/src/org/eclipse/xtext/ide/refactoring/RefactoringIssueAcceptor.xtend
deleted file mode 100644
index de7898240..000000000
--- a/org.eclipse.xtext.ide/src/org/eclipse/xtext/ide/refactoring/RefactoringIssueAcceptor.xtend
+++ /dev/null
@@ -1,39 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2017, 2018 TypeFox GmbH (http://www.typefox.io) and others.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License 2.0 which is available at
- * http://www.eclipse.org/legal/epl-2.0.
- *
- * SPDX-License-Identifier: EPL-2.0
- *******************************************************************************/
-package org.eclipse.xtext.ide.refactoring
-
-import org.apache.log4j.Logger
-import org.eclipse.emf.common.util.URI
-import org.eclipse.emf.ecore.EObject
-import org.eclipse.emf.ecore.resource.ResourceSet
-import org.eclipse.xtext.util.ITextRegion
-
-/**
- * @author koehnlein - Initial contribution and API
- * @since 2.13
- */
-interface RefactoringIssueAcceptor {
-
- enum Severity {
- FATAL, ERROR, WARNING, INFO, OK
- }
-
- def void add(Severity severity, String message, URI uri, ResourceSet resourceSet)
-
- def void add(Severity severity, String message, URI resourceUri)
-
- def void add(Severity severity, String message, EObject element)
-
- def void add(Severity severity, String message, EObject element, ITextRegion region)
-
- def void add(Severity severity, String message, Exception exc, Logger log)
-
- def void add(Severity severity, String message, Object... params)
-
-}
diff --git a/org.eclipse.xtext.ide/src/org/eclipse/xtext/ide/refactoring/RenameChange.java b/org.eclipse.xtext.ide/src/org/eclipse/xtext/ide/refactoring/RenameChange.java
new file mode 100644
index 000000000..36eac3668
--- /dev/null
+++ b/org.eclipse.xtext.ide/src/org/eclipse/xtext/ide/refactoring/RenameChange.java
@@ -0,0 +1,74 @@
+/**
+ * Copyright (c) 2017, 2020 TypeFox GmbH (http://www.typefox.io) and others.
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License 2.0 which is available at
+ * http://www.eclipse.org/legal/epl-2.0.
+ *
+ * SPDX-License-Identifier: EPL-2.0
+ */
+package org.eclipse.xtext.ide.refactoring;
+
+import org.eclipse.emf.common.util.URI;
+import org.eclipse.xtext.xbase.lib.util.ToStringBuilder;
+
+/**
+ * @author koehnlein - Initial contribution and API
+ * @since 2.13
+ */
+public class RenameChange {
+ private final String newName;
+
+ private final URI targetURI;
+
+ public RenameChange(String newName, URI targetURI) {
+ this.newName = newName;
+ this.targetURI = targetURI;
+ }
+
+ @Override
+ public int hashCode() {
+ final int prime = 31;
+ int result = 1;
+ result = prime * result + ((newName == null) ? 0 : newName.hashCode());
+ result = prime * result + ((targetURI == null) ? 0 : targetURI.hashCode());
+ return result;
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj)
+ return true;
+ if (obj == null)
+ return false;
+ if (getClass() != obj.getClass())
+ return false;
+ RenameChange other = (RenameChange) obj;
+ if (newName == null) {
+ if (other.newName != null)
+ return false;
+ } else if (!newName.equals(other.newName))
+ return false;
+ if (targetURI == null) {
+ if (other.targetURI != null)
+ return false;
+ } else if (!targetURI.equals(other.targetURI))
+ return false;
+ return true;
+ }
+
+ @Override
+ public String toString() {
+ ToStringBuilder b = new ToStringBuilder(this);
+ b.add("newName", newName);
+ b.add("targetURI", targetURI);
+ return b.toString();
+ }
+
+ public String getNewName() {
+ return newName;
+ }
+
+ public URI getTargetURI() {
+ return targetURI;
+ }
+}
diff --git a/org.eclipse.xtext.ide/src/org/eclipse/xtext/ide/refactoring/RenameChange.xtend b/org.eclipse.xtext.ide/src/org/eclipse/xtext/ide/refactoring/RenameChange.xtend
deleted file mode 100644
index f6847c94a..000000000
--- a/org.eclipse.xtext.ide/src/org/eclipse/xtext/ide/refactoring/RenameChange.xtend
+++ /dev/null
@@ -1,22 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2017 TypeFox GmbH (http://www.typefox.io) and others.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License 2.0 which is available at
- * http://www.eclipse.org/legal/epl-2.0.
- *
- * SPDX-License-Identifier: EPL-2.0
- *******************************************************************************/
-package org.eclipse.xtext.ide.refactoring
-
-import org.eclipse.emf.common.util.URI
-import org.eclipse.xtend.lib.annotations.Data
-
-/**
- * @author koehnlein - Initial contribution and API
- * @since 2.13
- */
-@Data
-class RenameChange {
- String newName
- URI targetURI
-}
\ No newline at end of file
diff --git a/org.eclipse.xtext.ide/src/org/eclipse/xtext/ide/refactoring/RenameContext.java b/org.eclipse.xtext.ide/src/org/eclipse/xtext/ide/refactoring/RenameContext.java
new file mode 100644
index 000000000..64a3b417d
--- /dev/null
+++ b/org.eclipse.xtext.ide/src/org/eclipse/xtext/ide/refactoring/RenameContext.java
@@ -0,0 +1,64 @@
+/**
+ * Copyright (c) 2017, 2020 TypeFox GmbH (http://www.typefox.io) and others.
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License 2.0 which is available at
+ * http://www.eclipse.org/legal/epl-2.0.
+ *
+ * SPDX-License-Identifier: EPL-2.0
+ */
+package org.eclipse.xtext.ide.refactoring;
+
+import java.util.List;
+
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.ecore.resource.ResourceSet;
+import org.eclipse.emf.ecore.util.EcoreUtil;
+import org.eclipse.xtext.ide.serializer.IChangeSerializer;
+
+/**
+ * @author koehnlein - Initial contribution and API
+ * @since 2.13
+ */
+public class RenameContext {
+ private final List extends RenameChange> changes;
+
+ private final ResourceSet resourceSet;
+
+ private final IChangeSerializer changeSerializer;
+
+ private final RefactoringIssueAcceptor issues;
+
+ public RenameContext(List extends RenameChange> changes, ResourceSet resourceSet,
+ IChangeSerializer changeSerializer, RefactoringIssueAcceptor issues) {
+ this.changes = changes;
+ this.resourceSet = resourceSet;
+ this.changeSerializer = changeSerializer;
+ this.issues = issues;
+ }
+
+ public void addModification(RenameChange change, IChangeSerializer.IModification modification) {
+ EObject target = resourceSet.getEObject(change.getTargetURI(), true);
+ if (target != null) {
+ EcoreUtil.resolveAll(target.eResource());
+ changeSerializer.addModification(target, modification);
+ } else {
+ issues.add(RefactoringIssueAcceptor.Severity.ERROR, "Element cannot be found", change.getTargetURI());
+ }
+ }
+
+ public List extends RenameChange> getChanges() {
+ return changes;
+ }
+
+ public ResourceSet getResourceSet() {
+ return resourceSet;
+ }
+
+ public IChangeSerializer getChangeSerializer() {
+ return changeSerializer;
+ }
+
+ public RefactoringIssueAcceptor getIssues() {
+ return issues;
+ }
+}
diff --git a/org.eclipse.xtext.ide/src/org/eclipse/xtext/ide/refactoring/RenameContext.xtend b/org.eclipse.xtext.ide/src/org/eclipse/xtext/ide/refactoring/RenameContext.xtend
deleted file mode 100644
index e820bcba3..000000000
--- a/org.eclipse.xtext.ide/src/org/eclipse/xtext/ide/refactoring/RenameContext.xtend
+++ /dev/null
@@ -1,41 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2017 TypeFox GmbH (http://www.typefox.io) and others.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License 2.0 which is available at
- * http://www.eclipse.org/legal/epl-2.0.
- *
- * SPDX-License-Identifier: EPL-2.0
- *******************************************************************************/
-package org.eclipse.xtext.ide.refactoring
-
-import java.util.List
-import org.eclipse.emf.ecore.EObject
-import org.eclipse.emf.ecore.resource.ResourceSet
-import org.eclipse.emf.ecore.util.EcoreUtil
-import org.eclipse.xtend.lib.annotations.Accessors
-import org.eclipse.xtend.lib.annotations.FinalFieldsConstructor
-import org.eclipse.xtext.ide.refactoring.RefactoringIssueAcceptor.Severity
-import org.eclipse.xtext.ide.serializer.IChangeSerializer
-
-/**
- * @author koehnlein - Initial contribution and API
- * @since 2.13
- */
-@FinalFieldsConstructor
-@Accessors(PUBLIC_GETTER)
-class RenameContext {
- val List extends RenameChange> changes
- val ResourceSet resourceSet
- val IChangeSerializer changeSerializer
- val RefactoringIssueAcceptor issues
-
- def void addModification(RenameChange change, IChangeSerializer.IModification modification) {
- val target = resourceSet.getEObject(change.targetURI, true)
- if (target !== null) {
- EcoreUtil.resolveAll(target.eResource)
- changeSerializer.addModification(target, modification)
- } else {
- issues.add(Severity.ERROR, 'Element cannot be found', change.targetURI)
- }
- }
-}
diff --git a/org.eclipse.xtext.ide/src/org/eclipse/xtext/ide/refactoring/ResourceRelocationChange.java b/org.eclipse.xtext.ide/src/org/eclipse/xtext/ide/refactoring/ResourceRelocationChange.java
new file mode 100644
index 000000000..9c8b5f812
--- /dev/null
+++ b/org.eclipse.xtext.ide/src/org/eclipse/xtext/ide/refactoring/ResourceRelocationChange.java
@@ -0,0 +1,87 @@
+/**
+ * Copyright (c) 2017, 2020 TypeFox GmbH (http://www.typefox.io) and others.
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License 2.0 which is available at
+ * http://www.eclipse.org/legal/epl-2.0.
+ *
+ * SPDX-License-Identifier: EPL-2.0
+ */
+package org.eclipse.xtext.ide.refactoring;
+
+import org.eclipse.emf.common.util.URI;
+import org.eclipse.xtext.xbase.lib.util.ToStringBuilder;
+
+/**
+ * URIs can also refer to folders and non-Xtext resources.
+ *
+ * @author koehnlein - Initial contribution and API
+ * @since 2.13
+ */
+public class ResourceRelocationChange {
+ private final URI fromURI;
+
+ private final URI toURI;
+
+ private final boolean isFile;
+
+ public ResourceRelocationChange(URI fromURI, URI toURI, boolean isFile) {
+ this.fromURI = fromURI;
+ this.toURI = toURI;
+ this.isFile = isFile;
+ }
+
+ @Override
+ public int hashCode() {
+ final int prime = 31;
+ int result = 1;
+ result = prime * result + ((fromURI == null) ? 0 : fromURI.hashCode());
+ result = prime * result + (isFile ? 1231 : 1237);
+ result = prime * result + ((toURI == null) ? 0 : toURI.hashCode());
+ return result;
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj)
+ return true;
+ if (obj == null)
+ return false;
+ if (getClass() != obj.getClass())
+ return false;
+ ResourceRelocationChange other = (ResourceRelocationChange) obj;
+ if (fromURI == null) {
+ if (other.fromURI != null)
+ return false;
+ } else if (!fromURI.equals(other.fromURI))
+ return false;
+ if (isFile != other.isFile)
+ return false;
+ if (toURI == null) {
+ if (other.toURI != null)
+ return false;
+ } else if (!toURI.equals(other.toURI))
+ return false;
+ return true;
+ }
+
+ @Override
+ public String toString() {
+ ToStringBuilder b = new ToStringBuilder(this);
+ b.add("fromURI", fromURI);
+ b.add("toURI", toURI);
+ b.add("isFile", isFile);
+ return b.toString();
+ }
+
+ public URI getFromURI() {
+ return fromURI;
+ }
+
+ public URI getToURI() {
+ return toURI;
+ }
+
+ public boolean isFile() {
+ return isFile;
+ }
+}
diff --git a/org.eclipse.xtext.ide/src/org/eclipse/xtext/ide/refactoring/ResourceRelocationChange.xtend b/org.eclipse.xtext.ide/src/org/eclipse/xtext/ide/refactoring/ResourceRelocationChange.xtend
deleted file mode 100644
index 81e0d596b..000000000
--- a/org.eclipse.xtext.ide/src/org/eclipse/xtext/ide/refactoring/ResourceRelocationChange.xtend
+++ /dev/null
@@ -1,25 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2017 TypeFox GmbH (http://www.typefox.io) and others.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License 2.0 which is available at
- * http://www.eclipse.org/legal/epl-2.0.
- *
- * SPDX-License-Identifier: EPL-2.0
- *******************************************************************************/
-package org.eclipse.xtext.ide.refactoring
-
-import org.eclipse.emf.common.util.URI
-import org.eclipse.xtend.lib.annotations.Data
-
-/**
- * URIs can also refer to folders and non-Xtext resources.
- *
- * @author koehnlein - Initial contribution and API
- * @since 2.13
- */
-@Data
-class ResourceRelocationChange {
- URI fromURI
- URI toURI
- boolean isFile
-}
\ No newline at end of file
diff --git a/org.eclipse.xtext.ide/src/org/eclipse/xtext/ide/server/BuildListener.xtend b/org.eclipse.xtext.ide/src/org/eclipse/xtext/ide/server/BuildListener.java
similarity index 60%
rename from org.eclipse.xtext.ide/src/org/eclipse/xtext/ide/server/BuildListener.xtend
rename to org.eclipse.xtext.ide/src/org/eclipse/xtext/ide/server/BuildListener.java
index 3160300b0..dca814cb1 100644
--- a/org.eclipse.xtext.ide/src/org/eclipse/xtext/ide/server/BuildListener.xtend
+++ b/org.eclipse.xtext.ide/src/org/eclipse/xtext/ide/server/BuildListener.java
@@ -1,21 +1,21 @@
/*******************************************************************************
- * Copyright (c) 2016 TypeFox GmbH (http://www.typefox.io) and others.
+ * Copyright (c) 2016, 2020 TypeFox GmbH (http://www.typefox.io) and others.
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License 2.0 which is available at
* http://www.eclipse.org/legal/epl-2.0.
*
* SPDX-License-Identifier: EPL-2.0
*******************************************************************************/
-package org.eclipse.xtext.ide.server
+package org.eclipse.xtext.ide.server;
-import org.eclipse.xtext.resource.IResourceDescription
-import java.util.List
+import org.eclipse.xtext.resource.IResourceDescription;
+import java.util.List;
/**
* @author Sven Efftinge - Initial contribution and API
*/
-interface BuildListener {
-
- def void afterBuild(List deltas)
-
-}
\ No newline at end of file
+public interface BuildListener {
+
+ void afterBuild(List deltas);
+
+}
diff --git a/org.eclipse.xtext.ide/src/org/eclipse/xtext/ide/server/DocumentExtensions.java b/org.eclipse.xtext.ide/src/org/eclipse/xtext/ide/server/DocumentExtensions.java
new file mode 100644
index 000000000..6275a09c4
--- /dev/null
+++ b/org.eclipse.xtext.ide/src/org/eclipse/xtext/ide/server/DocumentExtensions.java
@@ -0,0 +1,100 @@
+/*******************************************************************************
+ * Copyright (c) 2016, 2020 TypeFox GmbH (http://www.typefox.io) and others.
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License 2.0 which is available at
+ * http://www.eclipse.org/legal/epl-2.0.
+ *
+ * SPDX-License-Identifier: EPL-2.0
+ *******************************************************************************/
+package org.eclipse.xtext.ide.server;
+
+import com.google.inject.Inject;
+import com.google.inject.Singleton;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.ecore.EStructuralFeature;
+import org.eclipse.emf.ecore.resource.Resource;
+import org.eclipse.lsp4j.Location;
+import org.eclipse.lsp4j.Position;
+import org.eclipse.lsp4j.Range;
+import org.eclipse.xtext.resource.ILocationInFileProvider;
+import org.eclipse.xtext.resource.XtextResource;
+import org.eclipse.xtext.util.ITextRegion;
+import org.eclipse.xtext.util.LineAndColumn;
+
+import static org.eclipse.xtext.nodemodel.util.NodeModelUtils.*;
+import org.eclipse.xtext.nodemodel.ICompositeNode;
+
+/**
+ * @author kosyakov - Initial contribution and API
+ * @since 2.11
+ */
+@Singleton
+public class DocumentExtensions {
+
+ @Inject
+ private UriExtensions uriExtensions;
+
+ @Inject
+ private ILocationInFileProvider locationInFileProvider;
+
+ public Position newPosition(Resource resource, int offset) {
+ if (resource instanceof XtextResource) {
+ ICompositeNode rootNode = ((XtextResource) resource).getParseResult().getRootNode();
+ LineAndColumn lineAndColumn = getLineAndColumn(rootNode, offset);
+ return new Position(lineAndColumn.getLine() - 1, lineAndColumn.getColumn() - 1);
+ }
+ return null;
+ }
+
+ public Range newRange(Resource resource, int startOffset, int endOffset) {
+ Position startPosition = newPosition(resource, startOffset);
+ if (startPosition == null) {
+ return null;
+ }
+ Position endPosition = newPosition(resource, endOffset);
+ if (endPosition == null) {
+ return null;
+ }
+ return new Range(startPosition, endPosition);
+ }
+
+ public Range newRange(Resource resource, ITextRegion region) {
+ if (region == null)
+ return null;
+ return newRange(resource, region.getOffset(), region.getOffset() + region.getLength());
+ }
+
+ public Location newLocation(Resource resource, ITextRegion textRegion) {
+ Range range = newRange(resource, textRegion);
+ if (range == null) {
+ return null;
+ }
+ String uri = uriExtensions.toUriString(resource.getURI());
+ return new Location(uri, range);
+ }
+
+ public Location newLocation(EObject object) {
+ Resource resource = object.eResource();
+ ITextRegion textRegion = locationInFileProvider.getSignificantTextRegion(object);
+ return newLocation(resource, textRegion);
+ }
+
+ /**
+ * Returns with the {@link Location location} that represents the {@link ILocationInFileProvider#getFullTextRegion
+ * full text region} of the argument.
+ *
+ * @since 2.16
+ */
+ public Location newFullLocation(EObject object) {
+ Resource resource = object.eResource();
+ ITextRegion textRegion = locationInFileProvider.getFullTextRegion(object);
+ return newLocation(resource, textRegion);
+ }
+
+ public Location newLocation(EObject owner, EStructuralFeature feature, int indexInList) {
+ Resource resource = owner.eResource();
+ ITextRegion textRegion = locationInFileProvider.getSignificantTextRegion(owner, feature, indexInList);
+ return newLocation(resource, textRegion);
+ }
+
+}
diff --git a/org.eclipse.xtext.ide/src/org/eclipse/xtext/ide/server/DocumentExtensions.xtend b/org.eclipse.xtext.ide/src/org/eclipse/xtext/ide/server/DocumentExtensions.xtend
deleted file mode 100644
index d2fd3c4d5..000000000
--- a/org.eclipse.xtext.ide/src/org/eclipse/xtext/ide/server/DocumentExtensions.xtend
+++ /dev/null
@@ -1,97 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2016, 2017 TypeFox GmbH (http://www.typefox.io) and others.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License 2.0 which is available at
- * http://www.eclipse.org/legal/epl-2.0.
- *
- * SPDX-License-Identifier: EPL-2.0
- *******************************************************************************/
-package org.eclipse.xtext.ide.server
-
-import com.google.inject.Inject
-import com.google.inject.Singleton
-import org.eclipse.emf.ecore.EObject
-import org.eclipse.emf.ecore.EStructuralFeature
-import org.eclipse.emf.ecore.resource.Resource
-import org.eclipse.lsp4j.Location
-import org.eclipse.lsp4j.Position
-import org.eclipse.lsp4j.Range
-import org.eclipse.xtext.resource.ILocationInFileProvider
-import org.eclipse.xtext.resource.XtextResource
-import org.eclipse.xtext.util.ITextRegion
-
-import static extension org.eclipse.xtext.nodemodel.util.NodeModelUtils.*
-
-/**
- * @author kosyakov - Initial contribution and API
- * @since 2.11
- */
-@Singleton
-class DocumentExtensions {
-
- @Inject
- extension UriExtensions
-
- @Inject
- ILocationInFileProvider locationInFileProvider
-
- def Position newPosition(Resource resource, int offset) {
- if (resource instanceof XtextResource) {
- val rootNode = resource.parseResult.rootNode
- val lineAndColumn = rootNode.getLineAndColumn(offset)
- return new Position(lineAndColumn.line - 1, lineAndColumn.column - 1)
- }
- return null
- }
-
- def Range newRange(Resource resource, int startOffset, int endOffset) {
- val startPosition = resource.newPosition(startOffset)
- if (startPosition === null) {
- return null
- }
- val endPosition = resource.newPosition(endOffset)
- if (endPosition === null) {
- return null
- }
- return new Range(startPosition, endPosition)
- }
-
- def Range newRange(Resource resource, ITextRegion region) {
- if (region === null) return null
- return resource.newRange(region.offset, region.offset + region.length)
- }
-
- def Location newLocation(Resource resource, ITextRegion textRegion) {
- val range = resource.newRange(textRegion)
- if (range === null) {
- return null
- }
- val uri = resource.URI.toUriString
- return new Location(uri, range)
- }
-
- def Location newLocation(EObject object) {
- val resource = object.eResource
- val textRegion = locationInFileProvider.getSignificantTextRegion(object)
- return resource.newLocation(textRegion)
- }
-
- /**
- * Returns with the {@link Location location} that represents the {@link ILocationInFileProvider#getFullTextRegion full text region}
- * of the argument.
- *
- * @since 2.16
- */
- def Location newFullLocation(EObject object) {
- val resource = object.eResource
- val textRegion = locationInFileProvider.getFullTextRegion(object)
- return resource.newLocation(textRegion)
- }
-
- def Location newLocation(EObject owner, EStructuralFeature feature, int indexInList) {
- val resource = owner.eResource
- val textRegion = locationInFileProvider.getSignificantTextRegion(owner, feature, indexInList)
- return resource.newLocation(textRegion)
- }
-
-}
diff --git a/org.eclipse.xtext.ide/src/org/eclipse/xtext/ide/server/UriExtensions.xtend b/org.eclipse.xtext.ide/src/org/eclipse/xtext/ide/server/UriExtensions.java
similarity index 66%
rename from org.eclipse.xtext.ide/src/org/eclipse/xtext/ide/server/UriExtensions.xtend
rename to org.eclipse.xtext.ide/src/org/eclipse/xtext/ide/server/UriExtensions.java
index 4d11986f4..8c8bc3b8e 100644
--- a/org.eclipse.xtext.ide/src/org/eclipse/xtext/ide/server/UriExtensions.xtend
+++ b/org.eclipse.xtext.ide/src/org/eclipse/xtext/ide/server/UriExtensions.java
@@ -1,15 +1,15 @@
/*******************************************************************************
- * Copyright (c) 2016, 2017 TypeFox GmbH (http://www.typefox.io) and others.
+ * Copyright (c) 2016, 2020 TypeFox GmbH (http://www.typefox.io) and others.
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License 2.0 which is available at
* http://www.eclipse.org/legal/epl-2.0.
*
* SPDX-License-Identifier: EPL-2.0
*******************************************************************************/
-package org.eclipse.xtext.ide.server
+package org.eclipse.xtext.ide.server;
-import com.google.inject.Singleton
-import org.eclipse.emf.common.util.URI
+import com.google.inject.Singleton;
+import org.eclipse.emf.common.util.URI;
/**
* Normalizes file uris without authorities (file:/path...
) to contain an empty authority (i.e. starts with three slashes:file:///path...
).
@@ -18,20 +18,20 @@ import org.eclipse.emf.common.util.URI
* @since 2.11
*/
@Singleton
-class UriExtensions extends org.eclipse.xtext.util.UriExtensions {
+public class UriExtensions extends org.eclipse.xtext.util.UriExtensions {
/**
* returns the string representation of the given URI (with empty authority, if absent and has file scheme).
*/
- def String toUriString(URI uri) {
- return uri.withEmptyAuthority.toString
+ public String toUriString(URI uri) {
+ return withEmptyAuthority(uri).toString();
}
/**
* converts a java.net.URI into a string representation with empty authority, if absent and has file scheme.
*/
- def String toUriString(java.net.URI uri) {
- return toUriString(URI.createURI(uri.normalize.toString))
+ public String toUriString(java.net.URI uri) {
+ return toUriString(URI.createURI(uri.normalize().toString()));
}
}
diff --git a/org.eclipse.xtext.ide/src/org/eclipse/xtext/ide/server/formatting/FormattingService.java b/org.eclipse.xtext.ide/src/org/eclipse/xtext/ide/server/formatting/FormattingService.java
new file mode 100644
index 000000000..5c3c064ea
--- /dev/null
+++ b/org.eclipse.xtext.ide/src/org/eclipse/xtext/ide/server/formatting/FormattingService.java
@@ -0,0 +1,122 @@
+/**
+ * Copyright (c) 2016, 2020 itemis AG (http://www.itemis.com) and others.
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License 2.0 which is available at
+ * http://www.eclipse.org/legal/epl-2.0.
+ *
+ * SPDX-License-Identifier: EPL-2.0
+ */
+package org.eclipse.xtext.ide.server.formatting;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+
+import org.eclipse.lsp4j.DocumentFormattingParams;
+import org.eclipse.lsp4j.DocumentRangeFormattingParams;
+import org.eclipse.lsp4j.FormattingOptions;
+import org.eclipse.lsp4j.Range;
+import org.eclipse.lsp4j.TextEdit;
+import org.eclipse.xtext.formatting.IIndentationInformation;
+import org.eclipse.xtext.formatting2.FormatterRequest;
+import org.eclipse.xtext.formatting2.IFormatter2;
+import org.eclipse.xtext.formatting2.regionaccess.ITextRegionAccess;
+import org.eclipse.xtext.formatting2.regionaccess.ITextReplacement;
+import org.eclipse.xtext.formatting2.regionaccess.TextRegionAccessBuilder;
+import org.eclipse.xtext.ide.server.Document;
+import org.eclipse.xtext.preferences.ITypedPreferenceValues;
+import org.eclipse.xtext.preferences.MapBasedPreferenceValues;
+import org.eclipse.xtext.resource.XtextResource;
+import org.eclipse.xtext.util.CancelIndicator;
+import org.eclipse.xtext.util.ITextRegion;
+import org.eclipse.xtext.util.TextRegion;
+
+import com.google.common.base.Strings;
+import com.google.inject.Inject;
+import com.google.inject.Provider;
+
+/**
+ * Language Service Implementation for Formatting and Range-Formatting
+ *
+ * @author Christian Dietrich - Initial contribution and API
+ * @since 2.11
+ */
+public class FormattingService {
+ @Inject(optional = true)
+ private Provider formatter2Provider;
+
+ @Inject
+ private Provider formatterRequestProvider;
+
+ @Inject
+ private TextRegionAccessBuilder regionBuilder;
+
+ @Inject
+ private IIndentationInformation indentationInformation;
+
+ public List extends TextEdit> format(Document document, XtextResource resource, DocumentFormattingParams params,
+ CancelIndicator cancelIndicator) {
+ int offset = 0;
+ int length = document.getContents().length();
+ if (length == 0 || resource.getContents().isEmpty()) {
+ return Collections.emptyList();
+ }
+ return format(resource, document, offset, length, params.getOptions());
+ }
+
+ public List extends TextEdit> format(Document document, XtextResource resource,
+ DocumentRangeFormattingParams params, CancelIndicator cancelIndicator) {
+ int startOffset = document.getOffSet(params.getRange().getStart());
+ int endOffset = document.getOffSet(params.getRange().getEnd());
+ int length = endOffset - startOffset;
+ return format(resource, document, startOffset, length, params.getOptions());
+ }
+
+ /**
+ * @since 2.14
+ */
+ public List format(XtextResource resource, Document document, int offset, int length,
+ FormattingOptions options) {
+ String indent = indentationInformation.getIndentString();
+ if (options != null) {
+ if (options.isInsertSpaces()) {
+ indent = Strings.padEnd("", options.getTabSize(), ' ');
+ }
+ }
+ List result = new ArrayList<>();
+ if (this.formatter2Provider != null) {
+ MapBasedPreferenceValues preferences = new MapBasedPreferenceValues();
+ preferences.put("indentation", indent);
+ List replacements = format2(resource, new TextRegion(offset, length), preferences);
+ for (ITextReplacement r : replacements) {
+ result.add(toTextEdit(document, r.getReplacementText(), r.getOffset(), r.getLength()));
+ }
+ }
+ return result;
+ }
+
+ protected TextEdit toTextEdit(Document document, String formattedText, int startOffset, int length) {
+ TextEdit textEdit = new TextEdit();
+ textEdit.setNewText(formattedText);
+ textEdit.setRange(new Range(document.getPosition(startOffset), document.getPosition((startOffset + length))));
+ return textEdit;
+ }
+
+ protected List format2(XtextResource resource, ITextRegion selection,
+ ITypedPreferenceValues preferences) {
+ FormatterRequest request = formatterRequestProvider.get();
+ request.setAllowIdentityEdits(false);
+ request.setFormatUndefinedHiddenRegionsOnly(false);
+ if (selection != null) {
+ request.setRegions(Collections.singletonList(selection));
+ }
+ if (preferences != null) {
+ request.setPreferences(preferences);
+ }
+ ITextRegionAccess regionAccess = regionBuilder.forNodeModel(resource).create();
+ request.setTextRegionAccess(regionAccess);
+ IFormatter2 formatter2 = formatter2Provider.get();
+ List replacements = formatter2.format(request);
+ return replacements;
+ }
+}
diff --git a/org.eclipse.xtext.ide/src/org/eclipse/xtext/ide/server/formatting/FormattingService.xtend b/org.eclipse.xtext.ide/src/org/eclipse/xtext/ide/server/formatting/FormattingService.xtend
deleted file mode 100644
index 2a6b6e18a..000000000
--- a/org.eclipse.xtext.ide/src/org/eclipse/xtext/ide/server/formatting/FormattingService.xtend
+++ /dev/null
@@ -1,122 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2016, 2018 itemis AG (http://www.itemis.com) and others.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License 2.0 which is available at
- * http://www.eclipse.org/legal/epl-2.0.
- *
- * SPDX-License-Identifier: EPL-2.0
- *******************************************************************************/
-package org.eclipse.xtext.ide.server.formatting
-
-import com.google.common.base.Strings
-import com.google.inject.Inject
-import com.google.inject.Provider
-import java.util.List
-import org.eclipse.lsp4j.DocumentFormattingParams
-import org.eclipse.lsp4j.DocumentRangeFormattingParams
-import org.eclipse.lsp4j.FormattingOptions
-import org.eclipse.lsp4j.Range
-import org.eclipse.lsp4j.TextEdit
-import org.eclipse.xtext.formatting.IIndentationInformation
-import org.eclipse.xtext.formatting2.FormatterRequest
-import org.eclipse.xtext.formatting2.IFormatter2
-import org.eclipse.xtext.formatting2.regionaccess.TextRegionAccessBuilder
-import org.eclipse.xtext.ide.server.Document
-import org.eclipse.xtext.preferences.ITypedPreferenceValues
-import org.eclipse.xtext.preferences.MapBasedPreferenceValues
-import org.eclipse.xtext.resource.XtextResource
-import org.eclipse.xtext.util.CancelIndicator
-import org.eclipse.xtext.util.ITextRegion
-import org.eclipse.xtext.util.TextRegion
-
-/**
- * Language Service Implementation for Formatting and Range-Formatting
- *
- * @author Christian Dietrich - Initial contribution and API
- * @since 2.11
- */
-class FormattingService {
-
- @Inject(optional=true) Provider formatter2Provider
-
- @Inject Provider formatterRequestProvider
-
- @Inject TextRegionAccessBuilder regionBuilder
-
- @Inject IIndentationInformation indentationInformation
-
- def List extends TextEdit> format(
- Document document,
- XtextResource resource,
- DocumentFormattingParams params,
- CancelIndicator cancelIndicator
- ) {
- val offset = 0
- val length = document.contents.length
- if (length === 0 || resource.contents.isEmpty) {
- return emptyList
- }
- return format(resource, document, offset, length, params.options)
- }
-
- def List extends TextEdit> format(
- Document document,
- XtextResource resource,
- DocumentRangeFormattingParams params,
- CancelIndicator cancelIndicator
- ) {
- val offset = document.getOffSet(params.range.start)
- val length = document.getOffSet(params.range.end) - offset
- return format(resource, document, offset, length, params.options)
- }
-
- /**
- * @since 2.14
- */
- def List format(XtextResource resource, Document document, int offset, int length, FormattingOptions options) {
- var indent = indentationInformation.indentString
- if (options !== null) {
- if (options.insertSpaces) {
- indent = Strings.padEnd("", options.tabSize," ")
- }
- }
- if (formatter2Provider !== null) {
- val preferences = new MapBasedPreferenceValues()
- preferences.put("indentation", indent)
- val replacements = format2(resource, new TextRegion(offset, length), preferences)
- return replacements.map [ r |
- document.toTextEdit(r.replacementText, r.offset, r.length)
- ].toList
- } else {
- return newArrayList
- }
-
- }
-
- protected def TextEdit toTextEdit(Document document, String formattedText, int startOffset, int length) {
- new TextEdit => [
- newText = formattedText
- range = new Range => [
- start = document.getPosition(startOffset)
- end = document.getPosition(startOffset + length)
- ]
- ]
- }
-
- protected def format2(XtextResource resource, ITextRegion selection, ITypedPreferenceValues preferences) {
- val request = formatterRequestProvider.get()
- request.allowIdentityEdits = false
- request.formatUndefinedHiddenRegionsOnly = false
- if (selection !== null)
- request.regions = #[selection]
- if (preferences !== null) {
- request.preferences = preferences
- }
- val regionAccess = regionBuilder.forNodeModel(resource).create()
- request.textRegionAccess = regionAccess
- val formatter2 = formatter2Provider.get();
- val replacements = formatter2.format(request)
- return replacements
- }
-
-}
diff --git a/org.eclipse.xtext.ide/src/org/eclipse/xtext/ide/server/hover/HoverService.java b/org.eclipse.xtext.ide/src/org/eclipse/xtext/ide/server/hover/HoverService.java
new file mode 100644
index 000000000..81e5fd59c
--- /dev/null
+++ b/org.eclipse.xtext.ide/src/org/eclipse/xtext/ide/server/hover/HoverService.java
@@ -0,0 +1,130 @@
+/**
+ * Copyright (c) 2016, 2020 TypeFox GmbH (http://www.typefox.io) and others.
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License 2.0 which is available at
+ * http://www.eclipse.org/legal/epl-2.0.
+ *
+ * SPDX-License-Identifier: EPL-2.0
+ */
+package org.eclipse.xtext.ide.server.hover;
+
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.lsp4j.Hover;
+import org.eclipse.lsp4j.HoverParams;
+import org.eclipse.lsp4j.MarkupContent;
+import org.eclipse.lsp4j.Range;
+import org.eclipse.xtext.documentation.IEObjectDocumentationProvider;
+import org.eclipse.xtext.ide.server.Document;
+import org.eclipse.xtext.ide.server.DocumentExtensions;
+import org.eclipse.xtext.nodemodel.ILeafNode;
+import org.eclipse.xtext.nodemodel.util.NodeModelUtils;
+import org.eclipse.xtext.parser.IParseResult;
+import org.eclipse.xtext.resource.EObjectAtOffsetHelper;
+import org.eclipse.xtext.resource.ILocationInFileProvider;
+import org.eclipse.xtext.resource.XtextResource;
+import org.eclipse.xtext.util.CancelIndicator;
+import org.eclipse.xtext.util.ITextRegion;
+
+import com.google.common.annotations.Beta;
+import com.google.inject.Inject;
+import com.google.inject.Singleton;
+
+/**
+ * @author kosyakov - Initial contribution and API
+ * @since 2.11
+ */
+@Singleton
+@Beta
+public class HoverService implements IHoverService {
+ @Inject
+ private DocumentExtensions documentExtensions;
+
+ @Inject
+ private EObjectAtOffsetHelper eObjectAtOffsetHelper;
+
+ @Inject
+ private ILocationInFileProvider locationInFileProvider;
+
+ @Inject
+ private IEObjectDocumentationProvider eObjectDocumentationProvider;
+
+ @Override
+ public Hover hover(Document document, XtextResource resource, HoverParams params, CancelIndicator cancelIndicator) {
+ int offset = document.getOffSet(params.getPosition());
+ HoverContext context = createContext(document, resource, offset);
+ return hover(context);
+ }
+
+ protected HoverContext createContext(Document document, XtextResource resource, int offset) {
+ EObject crossLinkedEObject = eObjectAtOffsetHelper.resolveCrossReferencedElementAt(resource, offset);
+ if (crossLinkedEObject != null) {
+ if (crossLinkedEObject.eIsProxy()) {
+ return null;
+ }
+ IParseResult parseResult = resource.getParseResult();
+ if (parseResult == null) {
+ return null;
+ }
+ ILeafNode leafNode = NodeModelUtils.findLeafNodeAtOffset(parseResult.getRootNode(), offset);
+ if (leafNode != null && leafNode.isHidden() && leafNode.getOffset() == offset) {
+ leafNode = NodeModelUtils.findLeafNodeAtOffset(parseResult.getRootNode(), offset - 1);
+ }
+ if (leafNode == null) {
+ return null;
+ }
+ ITextRegion leafRegion = leafNode.getTextRegion();
+ return new HoverContext(document, resource, offset, leafRegion, crossLinkedEObject);
+ }
+ EObject element = eObjectAtOffsetHelper.resolveElementAt(resource, offset);
+ if (element == null) {
+ return null;
+ }
+ ITextRegion region = locationInFileProvider.getSignificantTextRegion(element);
+ return new HoverContext(document, resource, offset, region, element);
+ }
+
+ protected Hover hover(HoverContext context) {
+ if (context == null) {
+ return IHoverService.EMPTY_HOVER;
+ }
+ MarkupContent contents = getMarkupContent(context);
+ if (contents == null) {
+ return IHoverService.EMPTY_HOVER;
+ }
+ Range range = getRange(context);
+ if (range == null) {
+ return IHoverService.EMPTY_HOVER;
+ }
+ return new Hover(contents, range);
+ }
+
+ protected Range getRange(HoverContext ctx) {
+ if (!ctx.getRegion().contains(ctx.getOffset())) {
+ return null;
+ }
+ return documentExtensions.newRange(ctx.getResource(), ctx.getRegion());
+ }
+
+ protected MarkupContent getMarkupContent(HoverContext ctx) {
+ return toMarkupContent(getKind(ctx), getContents(ctx.getElement()));
+ }
+
+ protected String getKind(HoverContext it) {
+ return "markdown";
+ }
+
+ protected MarkupContent toMarkupContent(String kind, String value) {
+ return new MarkupContent(kind, value);
+ }
+
+ public String getContents(EObject element) {
+ if (element == null) {
+ return "";
+ }
+ String documentation = eObjectDocumentationProvider.getDocumentation(element);
+ if (documentation == null) {
+ return "";
+ }
+ return documentation;
+ }
+}
diff --git a/org.eclipse.xtext.ide/src/org/eclipse/xtext/ide/server/hover/HoverService.xtend b/org.eclipse.xtext.ide/src/org/eclipse/xtext/ide/server/hover/HoverService.xtend
deleted file mode 100644
index 53069938a..000000000
--- a/org.eclipse.xtext.ide/src/org/eclipse/xtext/ide/server/hover/HoverService.xtend
+++ /dev/null
@@ -1,123 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2016, 2020 TypeFox GmbH (http://www.typefox.io) and others.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License 2.0 which is available at
- * http://www.eclipse.org/legal/epl-2.0.
- *
- * SPDX-License-Identifier: EPL-2.0
- *******************************************************************************/
-package org.eclipse.xtext.ide.server.hover
-
-import com.google.common.annotations.Beta
-import com.google.inject.Inject
-import com.google.inject.Singleton
-import org.eclipse.emf.ecore.EObject
-import org.eclipse.lsp4j.Hover
-import org.eclipse.lsp4j.HoverParams
-import org.eclipse.lsp4j.MarkupContent
-import org.eclipse.lsp4j.Range
-import org.eclipse.xtext.documentation.IEObjectDocumentationProvider
-import org.eclipse.xtext.ide.server.Document
-import org.eclipse.xtext.ide.server.DocumentExtensions
-import org.eclipse.xtext.resource.EObjectAtOffsetHelper
-import org.eclipse.xtext.resource.ILocationInFileProvider
-import org.eclipse.xtext.resource.XtextResource
-import org.eclipse.xtext.util.CancelIndicator
-
-import static extension org.eclipse.xtext.nodemodel.util.NodeModelUtils.*
-
-/**
- * @author kosyakov - Initial contribution and API
- * @since 2.11
- */
-@Singleton
-@Beta
-class HoverService implements IHoverService {
-
- @Inject
- extension DocumentExtensions
-
- @Inject
- extension EObjectAtOffsetHelper
-
- @Inject
- extension ILocationInFileProvider
-
- @Inject
- extension IEObjectDocumentationProvider
-
- override Hover hover(
- Document document,
- XtextResource resource,
- HoverParams params,
- CancelIndicator cancelIndicator
- ) {
- val offset = document.getOffSet(params.position)
- val context = createContext(document, resource, offset)
- return context.hover
- }
-
- protected def HoverContext createContext(Document document, XtextResource resource, int offset) {
- val crossLinkedEObject = resource.resolveCrossReferencedElementAt(offset)
- if (crossLinkedEObject !== null) {
- if(crossLinkedEObject.eIsProxy) return null
-
- val parseResult = resource.parseResult
- if(parseResult === null) return null
-
- var leafNode = parseResult.rootNode.findLeafNodeAtOffset(offset)
- if (leafNode !== null && leafNode.hidden && leafNode.offset == offset) {
- leafNode = parseResult.rootNode.findLeafNodeAtOffset(offset - 1)
- }
- if(leafNode === null) return null
-
- val leafRegion = leafNode.textRegion
- return new HoverContext(document, resource, offset, leafRegion, crossLinkedEObject)
- }
- val element = resource.resolveElementAt(offset);
- if(element === null) return null
-
- val region = element.significantTextRegion
- return new HoverContext(document, resource, offset, region, element)
- }
-
- protected def Hover hover(HoverContext context) {
- if (context === null) return EMPTY_HOVER
-
- val contents = context.markupContent
- if(contents === null) return EMPTY_HOVER
-
- val range = context.range
- if(range === null) return EMPTY_HOVER
-
- return new Hover(contents, range)
- }
-
- protected def Range getRange(HoverContext it) {
- if(!region.contains(offset)) return null
-
- return resource.newRange(region)
- }
-
- protected def MarkupContent getMarkupContent(HoverContext it) {
- return toMarkupContent(kind, element.contents)
- }
-
- protected def String getKind(HoverContext it) {
- return "markdown"
- }
-
- protected def MarkupContent toMarkupContent(String kind, String value) {
- return new MarkupContent(kind, value)
- }
-
- def String getContents(EObject element) {
- if(element === null) return ""
-
- val documentation = element.documentation
- if(documentation === null) return ""
-
- return documentation
- }
-
-}
diff --git a/org.eclipse.xtext.ide/src/org/eclipse/xtext/ide/server/rename/ServerRefactoringIssueAcceptor.java b/org.eclipse.xtext.ide/src/org/eclipse/xtext/ide/server/rename/ServerRefactoringIssueAcceptor.java
new file mode 100644
index 000000000..88374af19
--- /dev/null
+++ b/org.eclipse.xtext.ide/src/org/eclipse/xtext/ide/server/rename/ServerRefactoringIssueAcceptor.java
@@ -0,0 +1,154 @@
+/**
+ * Copyright (c) 2017, 2020 TypeFox GmbH (http://www.typefox.io) and others.
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License 2.0 which is available at
+ * http://www.eclipse.org/legal/epl-2.0.
+ *
+ * SPDX-License-Identifier: EPL-2.0
+ */
+package org.eclipse.xtext.ide.server.rename;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.log4j.Logger;
+import org.eclipse.emf.common.util.URI;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.ecore.resource.ResourceSet;
+import org.eclipse.lsp4j.jsonrpc.ResponseErrorException;
+import org.eclipse.lsp4j.jsonrpc.messages.ResponseError;
+import org.eclipse.lsp4j.jsonrpc.messages.ResponseErrorCode;
+import org.eclipse.xtext.ide.refactoring.RefactoringIssueAcceptor;
+import org.eclipse.xtext.util.ITextRegion;
+import org.eclipse.xtext.xbase.lib.IterableExtensions;
+import org.eclipse.xtext.xbase.lib.ListExtensions;
+
+/**
+ * @author koehnlein - Initial contribution and API
+ * @since 2.13
+ */
+public class ServerRefactoringIssueAcceptor implements RefactoringIssueAcceptor {
+ public static class Issue {
+ private Severity severity;
+
+ private String message;
+ }
+
+ private List issues = new ArrayList<>();
+
+ @Override
+ public void add(Severity severity, String message, URI uri, ResourceSet resourceSet) {
+ addIssue(severity, message);
+ }
+
+ @Override
+ public void add(Severity severity, String message, URI resourceUri) {
+ addIssue(severity, message);
+ }
+
+ @Override
+ public void add(Severity severity, String message, EObject element) {
+ addIssue(severity, message);
+ }
+
+ @Override
+ public void add(Severity severity, String message, EObject element, ITextRegion region) {
+ addIssue(severity, message);
+ }
+
+ @Override
+ public void add(Severity severity, String message, Exception exc, Logger log) {
+ addIssue(severity, message);
+ }
+
+ @Override
+ public void add(Severity severity, String message, Object... params) {
+ Issue issue = new Issue();
+ issue.severity = severity;
+ issue.message = message;
+ issues.add(issue);
+ }
+
+ protected boolean addIssue(Severity severity, String message) {
+ Issue issue = new Issue();
+ issue.severity = severity;
+ issue.message = message;
+ return issues.add(issue);
+ }
+
+ public Severity getMaximumSeverity() {
+ if (issues.size() > 0) {
+ Issue minBySeverity = IterableExtensions.minBy(issues, (i) -> i.severity);
+ Severity severity = null;
+ if (minBySeverity != null) {
+ severity = minBySeverity.severity;
+ }
+ return severity;
+ } else {
+ return Severity.OK;
+ }
+ }
+
+ public ResponseError toResponseError() {
+ Severity maxSeverity = getMaximumSeverity();
+ ResponseError responseError = new ResponseError();
+ responseError.setMessage(getMessageBySeverity(maxSeverity));
+ responseError.setCode(getCodeBySeverity(maxSeverity));
+ List bySeverity = IterableExtensions.sortBy(issues, (i) -> i.severity);
+ List messages = ListExtensions.map(ListExtensions.reverse(bySeverity), (i) -> i.message);
+ responseError.setData(IterableExtensions.join(messages, "\n"));
+ return responseError;
+ }
+
+ /**
+ * @since 2.22
+ */
+ protected int getCodeBySeverity(Severity maxSeverity) {
+ if (maxSeverity != null) {
+ switch (maxSeverity) {
+ case OK:
+ return 0;
+ case INFO:
+ return 0;
+ case WARNING:
+ return 0;
+ case ERROR:
+ return ResponseErrorCode.UnknownErrorCode.getValue();
+ case FATAL:
+ return ResponseErrorCode.UnknownErrorCode.getValue();
+ default:
+ return 0;
+ }
+ }
+ return 0;
+ }
+
+ /**
+ * @since 2.22
+ */
+ protected String getMessageBySeverity(Severity maxSeverity) {
+ if (maxSeverity != null) {
+ switch (maxSeverity) {
+ case OK:
+ return "Refactoring is possible";
+ case INFO:
+ return "Refactoring is possible";
+ case WARNING:
+ return "Refactoring could cause issues";
+ case ERROR:
+ return "Refactoring has errors";
+ case FATAL:
+ return "Refactoring cannot be performed";
+ default:
+ return null;
+ }
+ }
+ return null;
+ }
+
+ public void checkSeverity() {
+ if (getMaximumSeverity().compareTo(Severity.WARNING) < 0) {
+ throw new ResponseErrorException(toResponseError());
+ }
+ }
+}
diff --git a/org.eclipse.xtext.ide/src/org/eclipse/xtext/ide/server/rename/ServerRefactoringIssueAcceptor.xtend b/org.eclipse.xtext.ide/src/org/eclipse/xtext/ide/server/rename/ServerRefactoringIssueAcceptor.xtend
deleted file mode 100644
index 18f6d752a..000000000
--- a/org.eclipse.xtext.ide/src/org/eclipse/xtext/ide/server/rename/ServerRefactoringIssueAcceptor.xtend
+++ /dev/null
@@ -1,102 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2017 TypeFox GmbH (http://www.typefox.io) and others.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License 2.0 which is available at
- * http://www.eclipse.org/legal/epl-2.0.
- *
- * SPDX-License-Identifier: EPL-2.0
- *******************************************************************************/
-package org.eclipse.xtext.ide.server.rename
-
-import java.util.List
-import org.apache.log4j.Logger
-import org.eclipse.emf.common.util.URI
-import org.eclipse.emf.ecore.EObject
-import org.eclipse.emf.ecore.resource.ResourceSet
-import org.eclipse.lsp4j.jsonrpc.ResponseErrorException
-import org.eclipse.lsp4j.jsonrpc.messages.ResponseError
-import org.eclipse.lsp4j.jsonrpc.messages.ResponseErrorCode
-import org.eclipse.xtext.ide.refactoring.RefactoringIssueAcceptor
-import org.eclipse.xtext.ide.refactoring.RefactoringIssueAcceptor.Severity
-import org.eclipse.xtext.util.ITextRegion
-
-/**
- * @author koehnlein - Initial contribution and API
- * @since 2.13
- */
-class ServerRefactoringIssueAcceptor implements RefactoringIssueAcceptor {
-
- static class Issue {
- Severity severity
- String message
- }
-
- List issues = newArrayList
-
- override add(Severity severity, String message, URI uri, ResourceSet resourceSet) {
- addIssue(severity, message)
- }
-
- override add(Severity severity, String message, URI resourceUri) {
- addIssue(severity, message)
- }
-
- override add(Severity severity, String message, EObject element) {
- addIssue(severity, message)
- }
-
- override add(Severity severity, String message, EObject element, ITextRegion region) {
- addIssue(severity, message)
- }
-
- override add(Severity severity, String message, Exception exc, Logger log) {
- addIssue(severity, message)
- }
-
- override add(Severity severity, String message, Object... params) {
- issues += new Issue => [
- it.severity = severity
- it.message = message
- ]
- }
-
- protected def boolean addIssue(Severity severity, String message) {
- issues += new Issue => [
- it.severity = severity
- it.message = message
- ]
- }
-
- def Severity getMaximumSeverity() {
- if (issues.size > 0 )
- issues.minBy[severity]?.severity
- else
- Severity.OK
- }
-
- def ResponseError toResponseError() {
- val maxSeverity = maximumSeverity
- new ResponseError => [
- message = switch (maxSeverity) {
- case OK: 'Refactoring is possible'
- case INFO: 'Refactoring is possible'
- case WARNING: 'Refactoring could cause issues'
- case ERROR: 'Refactoring has errors'
- case FATAL: 'Refactoring cannot be performed'
- }
- data = issues.sortBy[severity].reverse.map[message].join('\n')
- code = switch (maxSeverity) {
- case OK: 0
- case INFO: 0
- case WARNING: 0
- case ERROR: ResponseErrorCode.UnknownErrorCode.value
- case FATAL: ResponseErrorCode.UnknownErrorCode.value
- }
- ]
- }
-
- def checkSeverity() {
- if(maximumSeverity < Severity.WARNING)
- throw new ResponseErrorException(toResponseError)
- }
-}
\ No newline at end of file
diff --git a/org.eclipse.xtext.ide/xtend-gen/org/eclipse/xtext/ide/ExecutorServiceProvider.java b/org.eclipse.xtext.ide/xtend-gen/org/eclipse/xtext/ide/ExecutorServiceProvider.java
deleted file mode 100644
index 0bec1f865..000000000
--- a/org.eclipse.xtext.ide/xtend-gen/org/eclipse/xtext/ide/ExecutorServiceProvider.java
+++ /dev/null
@@ -1,69 +0,0 @@
-/**
- * Copyright (c) 2016, 2017 TypeFox GmbH (http://www.typefox.io) and others.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License 2.0 which is available at
- * http://www.eclipse.org/legal/epl-2.0.
- *
- * SPDX-License-Identifier: EPL-2.0
- */
-package org.eclipse.xtext.ide;
-
-import com.google.common.collect.Maps;
-import com.google.inject.Inject;
-import com.google.inject.Provider;
-import com.google.inject.Singleton;
-import java.util.Collection;
-import java.util.Map;
-import java.util.concurrent.ExecutorService;
-import java.util.concurrent.Executors;
-import org.eclipse.xtext.util.DisposableRegistry;
-import org.eclipse.xtext.util.IDisposable;
-
-/**
- * Provider for executor services. By calling {@link #dispose()} all created executor services are shut down.
- *
- * In some situations it is necessary to use multiple instances of executor services in order to avoid deadlocks.
- * That can be achieved with the {@link #get(String)} method, which will return a different instance for each key.
- */
-@Singleton
-@SuppressWarnings("all")
-public class ExecutorServiceProvider implements Provider, IDisposable {
- @Inject
- public void registerTo(final DisposableRegistry disposableRegistry) {
- disposableRegistry.register(this);
- }
-
- private final Map instanceCache = Maps.newHashMapWithExpectedSize(3);
-
- @Override
- public ExecutorService get() {
- return this.get(null);
- }
-
- public ExecutorService get(final String key) {
- ExecutorService result = this.instanceCache.get(key);
- if ((result == null)) {
- synchronized (this.instanceCache) {
- result = this.instanceCache.get(key);
- if ((result == null)) {
- result = this.createInstance(key);
- this.instanceCache.put(key, result);
- }
- }
- }
- return result;
- }
-
- protected ExecutorService createInstance(final String key) {
- return Executors.newCachedThreadPool();
- }
-
- @Override
- public void dispose() {
- Collection _values = this.instanceCache.values();
- for (final ExecutorService executorService : _values) {
- executorService.shutdown();
- }
- this.instanceCache.clear();
- }
-}
diff --git a/org.eclipse.xtext.ide/xtend-gen/org/eclipse/xtext/ide/labels/AlternativeImageDescription.java b/org.eclipse.xtext.ide/xtend-gen/org/eclipse/xtext/ide/labels/AlternativeImageDescription.java
deleted file mode 100644
index ee013355b..000000000
--- a/org.eclipse.xtext.ide/xtend-gen/org/eclipse/xtext/ide/labels/AlternativeImageDescription.java
+++ /dev/null
@@ -1,63 +0,0 @@
-/**
- * Copyright (c) 2015 itemis AG (http://www.itemis.eu) and others.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License 2.0 which is available at
- * http://www.eclipse.org/legal/epl-2.0.
- *
- * SPDX-License-Identifier: EPL-2.0
- */
-package org.eclipse.xtext.ide.labels;
-
-import com.google.common.collect.ImmutableList;
-import java.util.List;
-import org.eclipse.xtend.lib.annotations.Data;
-import org.eclipse.xtext.ide.labels.IImageDescription;
-import org.eclipse.xtext.xbase.lib.Pure;
-import org.eclipse.xtext.xbase.lib.util.ToStringBuilder;
-
-@Data
-@SuppressWarnings("all")
-public class AlternativeImageDescription implements IImageDescription {
- private final List imageIDs;
-
- public AlternativeImageDescription(final Iterable imageIDs) {
- this.imageIDs = ImmutableList.copyOf(imageIDs);
- }
-
- @Override
- @Pure
- public int hashCode() {
- return 31 * 1 + ((this.imageIDs== null) ? 0 : this.imageIDs.hashCode());
- }
-
- @Override
- @Pure
- public boolean equals(final Object obj) {
- if (this == obj)
- return true;
- if (obj == null)
- return false;
- if (getClass() != obj.getClass())
- return false;
- AlternativeImageDescription other = (AlternativeImageDescription) obj;
- if (this.imageIDs == null) {
- if (other.imageIDs != null)
- return false;
- } else if (!this.imageIDs.equals(other.imageIDs))
- return false;
- return true;
- }
-
- @Override
- @Pure
- public String toString() {
- ToStringBuilder b = new ToStringBuilder(this);
- b.add("imageIDs", this.imageIDs);
- return b.toString();
- }
-
- @Pure
- public List getImageIDs() {
- return this.imageIDs;
- }
-}
diff --git a/org.eclipse.xtext.ide/xtend-gen/org/eclipse/xtext/ide/labels/DecoratedImageDescription.java b/org.eclipse.xtext.ide/xtend-gen/org/eclipse/xtext/ide/labels/DecoratedImageDescription.java
deleted file mode 100644
index dc4aa1ef2..000000000
--- a/org.eclipse.xtext.ide/xtend-gen/org/eclipse/xtext/ide/labels/DecoratedImageDescription.java
+++ /dev/null
@@ -1,80 +0,0 @@
-/**
- * Copyright (c) 2015 itemis AG (http://www.itemis.eu) and others.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License 2.0 which is available at
- * http://www.eclipse.org/legal/epl-2.0.
- *
- * SPDX-License-Identifier: EPL-2.0
- */
-package org.eclipse.xtext.ide.labels;
-
-import com.google.common.collect.ImmutableList;
-import java.util.List;
-import org.eclipse.xtend.lib.annotations.Data;
-import org.eclipse.xtext.ide.labels.IImageDescription;
-import org.eclipse.xtext.xbase.lib.Pure;
-import org.eclipse.xtext.xbase.lib.util.ToStringBuilder;
-
-@Data
-@SuppressWarnings("all")
-public class DecoratedImageDescription implements IImageDescription {
- private final IImageDescription baseImage;
-
- private final List decorators;
-
- public DecoratedImageDescription(final IImageDescription baseImage, final IImageDescription... decorators) {
- this.baseImage = baseImage;
- this.decorators = ImmutableList.copyOf(decorators);
- }
-
- @Override
- @Pure
- public int hashCode() {
- final int prime = 31;
- int result = 1;
- result = prime * result + ((this.baseImage== null) ? 0 : this.baseImage.hashCode());
- return prime * result + ((this.decorators== null) ? 0 : this.decorators.hashCode());
- }
-
- @Override
- @Pure
- public boolean equals(final Object obj) {
- if (this == obj)
- return true;
- if (obj == null)
- return false;
- if (getClass() != obj.getClass())
- return false;
- DecoratedImageDescription other = (DecoratedImageDescription) obj;
- if (this.baseImage == null) {
- if (other.baseImage != null)
- return false;
- } else if (!this.baseImage.equals(other.baseImage))
- return false;
- if (this.decorators == null) {
- if (other.decorators != null)
- return false;
- } else if (!this.decorators.equals(other.decorators))
- return false;
- return true;
- }
-
- @Override
- @Pure
- public String toString() {
- ToStringBuilder b = new ToStringBuilder(this);
- b.add("baseImage", this.baseImage);
- b.add("decorators", this.decorators);
- return b.toString();
- }
-
- @Pure
- public IImageDescription getBaseImage() {
- return this.baseImage;
- }
-
- @Pure
- public List getDecorators() {
- return this.decorators;
- }
-}
diff --git a/org.eclipse.xtext.ide/xtend-gen/org/eclipse/xtext/ide/labels/EClassImageDescriptionProvider.java b/org.eclipse.xtext.ide/xtend-gen/org/eclipse/xtext/ide/labels/EClassImageDescriptionProvider.java
deleted file mode 100644
index 986761cc2..000000000
--- a/org.eclipse.xtext.ide/xtend-gen/org/eclipse/xtext/ide/labels/EClassImageDescriptionProvider.java
+++ /dev/null
@@ -1,59 +0,0 @@
-/**
- * Copyright (c) 2015 itemis AG (http://www.itemis.eu) and others.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License 2.0 which is available at
- * http://www.eclipse.org/legal/epl-2.0.
- *
- * SPDX-License-Identifier: EPL-2.0
- */
-package org.eclipse.xtext.ide.labels;
-
-import com.google.common.collect.Iterables;
-import java.util.Collections;
-import java.util.List;
-import org.eclipse.emf.ecore.EClass;
-import org.eclipse.emf.ecore.EObject;
-import org.eclipse.xtext.ide.labels.AlternativeImageDescription;
-import org.eclipse.xtext.ide.labels.IImageDescription;
-import org.eclipse.xtext.ide.labels.IImageDescriptionProvider;
-import org.eclipse.xtext.resource.IEObjectDescription;
-import org.eclipse.xtext.xbase.lib.CollectionLiterals;
-import org.eclipse.xtext.xbase.lib.Functions.Function1;
-import org.eclipse.xtext.xbase.lib.ListExtensions;
-
-@SuppressWarnings("all")
-public class EClassImageDescriptionProvider implements IImageDescriptionProvider {
- @Override
- public IImageDescription getImageDescription(final Object element) {
- IImageDescription _switchResult = null;
- boolean _matched = false;
- if (element instanceof EClass) {
- _matched=true;
- String _name = ((EClass)element).getName();
- final Function1 _function = (EClass it) -> {
- return it.getName();
- };
- List _map = ListExtensions.map(((EClass)element).getEAllSuperTypes(), _function);
- Iterable _plus = Iterables.concat(Collections.unmodifiableList(CollectionLiterals.newArrayList(_name)), _map);
- String _imageID = IImageDescription.DEFAULT.getImageID();
- Iterable _plus_1 = Iterables.concat(_plus, Collections.unmodifiableList(CollectionLiterals.newArrayList(_imageID)));
- _switchResult = new AlternativeImageDescription(_plus_1);
- }
- if (!_matched) {
- if (element instanceof EObject) {
- _matched=true;
- _switchResult = this.getImageDescription(((EObject)element).eClass());
- }
- }
- if (!_matched) {
- if (element instanceof IEObjectDescription) {
- _matched=true;
- _switchResult = this.getImageDescription(((IEObjectDescription)element).getEClass());
- }
- }
- if (!_matched) {
- _switchResult = IImageDescription.DEFAULT;
- }
- return _switchResult;
- }
-}
diff --git a/org.eclipse.xtext.ide/xtend-gen/org/eclipse/xtext/ide/labels/SimpleImageDescription.java b/org.eclipse.xtext.ide/xtend-gen/org/eclipse/xtext/ide/labels/SimpleImageDescription.java
deleted file mode 100644
index 74914a161..000000000
--- a/org.eclipse.xtext.ide/xtend-gen/org/eclipse/xtext/ide/labels/SimpleImageDescription.java
+++ /dev/null
@@ -1,62 +0,0 @@
-/**
- * Copyright (c) 2015 itemis AG (http://www.itemis.eu) and others.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License 2.0 which is available at
- * http://www.eclipse.org/legal/epl-2.0.
- *
- * SPDX-License-Identifier: EPL-2.0
- */
-package org.eclipse.xtext.ide.labels;
-
-import org.eclipse.xtend.lib.annotations.Data;
-import org.eclipse.xtext.ide.labels.IImageDescription;
-import org.eclipse.xtext.xbase.lib.Pure;
-import org.eclipse.xtext.xbase.lib.util.ToStringBuilder;
-
-@Data
-@SuppressWarnings("all")
-public class SimpleImageDescription implements IImageDescription {
- private final String imageID;
-
- public SimpleImageDescription(final String imageID) {
- super();
- this.imageID = imageID;
- }
-
- @Override
- @Pure
- public int hashCode() {
- return 31 * 1 + ((this.imageID== null) ? 0 : this.imageID.hashCode());
- }
-
- @Override
- @Pure
- public boolean equals(final Object obj) {
- if (this == obj)
- return true;
- if (obj == null)
- return false;
- if (getClass() != obj.getClass())
- return false;
- SimpleImageDescription other = (SimpleImageDescription) obj;
- if (this.imageID == null) {
- if (other.imageID != null)
- return false;
- } else if (!this.imageID.equals(other.imageID))
- return false;
- return true;
- }
-
- @Override
- @Pure
- public String toString() {
- ToStringBuilder b = new ToStringBuilder(this);
- b.add("imageID", this.imageID);
- return b.toString();
- }
-
- @Pure
- public String getImageID() {
- return this.imageID;
- }
-}
diff --git a/org.eclipse.xtext.ide/xtend-gen/org/eclipse/xtext/ide/labels/SimpleNameLabelProvider.java b/org.eclipse.xtext.ide/xtend-gen/org/eclipse/xtext/ide/labels/SimpleNameLabelProvider.java
deleted file mode 100644
index 031616444..000000000
--- a/org.eclipse.xtext.ide/xtend-gen/org/eclipse/xtext/ide/labels/SimpleNameLabelProvider.java
+++ /dev/null
@@ -1,37 +0,0 @@
-/**
- * Copyright (c) 2015 itemis AG (http://www.itemis.eu) and others.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License 2.0 which is available at
- * http://www.eclipse.org/legal/epl-2.0.
- *
- * SPDX-License-Identifier: EPL-2.0
- */
-package org.eclipse.xtext.ide.labels;
-
-import org.eclipse.emf.ecore.EObject;
-import org.eclipse.xtext.ide.labels.INameLabelProvider;
-import org.eclipse.xtext.resource.IEObjectDescription;
-import org.eclipse.xtext.util.SimpleAttributeResolver;
-
-@SuppressWarnings("all")
-public class SimpleNameLabelProvider implements INameLabelProvider {
- @Override
- public String getNameLabel(final Object element) {
- String _switchResult = null;
- boolean _matched = false;
- if (element instanceof EObject) {
- _matched=true;
- _switchResult = SimpleAttributeResolver.NAME_RESOLVER.apply(((EObject)element));
- }
- if (!_matched) {
- if (element instanceof IEObjectDescription) {
- _matched=true;
- _switchResult = ((IEObjectDescription)element).getName().getLastSegment();
- }
- }
- if (!_matched) {
- _switchResult = null;
- }
- return _switchResult;
- }
-}
diff --git a/org.eclipse.xtext.ide/xtend-gen/org/eclipse/xtext/ide/refactoring/IRenameNameValidator.java b/org.eclipse.xtext.ide/xtend-gen/org/eclipse/xtext/ide/refactoring/IRenameNameValidator.java
deleted file mode 100644
index 72b2a51c0..000000000
--- a/org.eclipse.xtext.ide/xtend-gen/org/eclipse/xtext/ide/refactoring/IRenameNameValidator.java
+++ /dev/null
@@ -1,63 +0,0 @@
-/**
- * Copyright (c) 2017 TypeFox GmbH (http://www.typefox.io) and others.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License 2.0 which is available at
- * http://www.eclipse.org/legal/epl-2.0.
- *
- * SPDX-License-Identifier: EPL-2.0
- */
-package org.eclipse.xtext.ide.refactoring;
-
-import com.google.inject.ImplementedBy;
-import com.google.inject.Inject;
-import org.eclipse.emf.ecore.EObject;
-import org.eclipse.xtend2.lib.StringConcatenation;
-import org.eclipse.xtext.conversion.IValueConverterService;
-import org.eclipse.xtext.conversion.ValueConverterException;
-import org.eclipse.xtext.ide.refactoring.RefactoringIssueAcceptor;
-import org.eclipse.xtext.xbase.lib.Exceptions;
-
-/**
- * @author koehnlein - Initial contribution and API
- * @since 2.13
- */
-@ImplementedBy(IRenameNameValidator.RuleBasedNameValidator.class)
-@SuppressWarnings("all")
-public interface IRenameNameValidator {
- class RuleBasedNameValidator implements IRenameNameValidator {
- @Inject
- private IValueConverterService valueConverterService;
-
- @Override
- public void validate(final EObject target, final String newName, final RefactoringIssueAcceptor issues) {
- try {
- this.getNameAsValue(newName);
- } catch (final Throwable _t) {
- if (_t instanceof ValueConverterException) {
- final ValueConverterException e = (ValueConverterException)_t;
- StringConcatenation _builder = new StringConcatenation();
- _builder.append("Illegal name: ");
- String _message = e.getMessage();
- _builder.append(_message);
- issues.add(RefactoringIssueAcceptor.Severity.FATAL, _builder.toString());
- } else {
- throw Exceptions.sneakyThrow(_t);
- }
- }
- }
-
- protected String getNameAsText(final String nameAsValue) {
- return this.valueConverterService.toString(nameAsValue, this.getRuleName());
- }
-
- protected String getNameAsValue(final String nameAsText) {
- return this.valueConverterService.toValue(nameAsText, this.getRuleName(), null).toString();
- }
-
- protected String getRuleName() {
- return "ID";
- }
- }
-
- void validate(final EObject target, final String newName, final RefactoringIssueAcceptor issues);
-}
diff --git a/org.eclipse.xtext.ide/xtend-gen/org/eclipse/xtext/ide/refactoring/IRenameStrategy2.java b/org.eclipse.xtext.ide/xtend-gen/org/eclipse/xtext/ide/refactoring/IRenameStrategy2.java
deleted file mode 100644
index b091d5fb8..000000000
--- a/org.eclipse.xtext.ide/xtend-gen/org/eclipse/xtext/ide/refactoring/IRenameStrategy2.java
+++ /dev/null
@@ -1,81 +0,0 @@
-/**
- * Copyright (c) 2017 TypeFox GmbH (http://www.typefox.io) and others.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License 2.0 which is available at
- * http://www.eclipse.org/legal/epl-2.0.
- *
- * SPDX-License-Identifier: EPL-2.0
- */
-package org.eclipse.xtext.ide.refactoring;
-
-import com.google.common.base.Objects;
-import com.google.inject.Inject;
-import java.util.function.Consumer;
-import org.eclipse.emf.ecore.EAttribute;
-import org.eclipse.emf.ecore.EObject;
-import org.eclipse.emf.ecore.EcorePackage;
-import org.eclipse.xtext.ide.refactoring.RefactoringIssueAcceptor;
-import org.eclipse.xtext.ide.refactoring.RenameChange;
-import org.eclipse.xtext.ide.refactoring.RenameContext;
-import org.eclipse.xtext.ide.serializer.IChangeSerializer;
-import org.eclipse.xtext.resource.IResourceServiceProvider;
-import org.eclipse.xtext.xbase.lib.Functions.Function1;
-import org.eclipse.xtext.xbase.lib.IterableExtensions;
-
-/**
- * Called to rename an element in the {@link IChangeSerializer} based refactoring.
- *
- * Clients may extend the {@link DefaultImpl} to customize the behavior or implement
- * this interface directly.
- *
- * Changes are usually performed in the The {@link RenameContext}
- *
- * @author koehnlein - Initial contribution and API
- * @since 2.13
- */
-@SuppressWarnings("all")
-public interface IRenameStrategy2 {
- class DefaultImpl implements IRenameStrategy2 {
- @Inject
- private IResourceServiceProvider resourceServiceProvider;
-
- public boolean canHandle(final RenameChange change) {
- return this.resourceServiceProvider.canHandle(change.getTargetURI());
- }
-
- @Override
- public void applyRename(final RenameContext context) {
- final Function1 _function = (RenameChange it) -> {
- return Boolean.valueOf(this.canHandle(it));
- };
- final Consumer _function_1 = (RenameChange change) -> {
- final IChangeSerializer.IModification _function_2 = (EObject it) -> {
- this.doRename(it, change, context);
- };
- context.addModification(change, _function_2);
- };
- IterableExtensions.filter(context.getChanges(), _function).forEach(_function_1);
- }
-
- protected void doRename(final EObject target, final RenameChange change, final RenameContext context) {
- final EAttribute nameAttribute = this.getNameEAttribute(target);
- if ((nameAttribute != null)) {
- target.eSet(nameAttribute, change.getNewName());
- } else {
- String _name = target.eClass().getName();
- String _plus = ("Element of class " + _name);
- String _plus_1 = (_plus + " cannot be renamed.");
- context.getIssues().add(RefactoringIssueAcceptor.Severity.WARNING, _plus_1);
- }
- }
-
- protected EAttribute getNameEAttribute(final EObject target) {
- final Function1 _function = (EAttribute it) -> {
- return Boolean.valueOf((Objects.equal(it.getName(), "name") && Objects.equal(it.getEType(), EcorePackage.Literals.ESTRING)));
- };
- return IterableExtensions.head(IterableExtensions.filter(target.eClass().getEAllAttributes(), _function));
- }
- }
-
- void applyRename(final RenameContext context);
-}
diff --git a/org.eclipse.xtext.ide/xtend-gen/org/eclipse/xtext/ide/refactoring/IResourceRelocationStrategy.java b/org.eclipse.xtext.ide/xtend-gen/org/eclipse/xtext/ide/refactoring/IResourceRelocationStrategy.java
deleted file mode 100644
index 8c1c62c7f..000000000
--- a/org.eclipse.xtext.ide/xtend-gen/org/eclipse/xtext/ide/refactoring/IResourceRelocationStrategy.java
+++ /dev/null
@@ -1,58 +0,0 @@
-/**
- * Copyright (c) 2017 TypeFox GmbH (http://www.typefox.io) and others.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License 2.0 which is available at
- * http://www.eclipse.org/legal/epl-2.0.
- *
- * SPDX-License-Identifier: EPL-2.0
- */
-package org.eclipse.xtext.ide.refactoring;
-
-import org.eclipse.xtext.ide.refactoring.ResourceRelocationContext;
-
-/**
- * Allows a language to execute side-effects when the URI of a resource changes.
- *
- * Such changes can be move, rename and copy operations, e.g. triggered by the
- * user in a file browser. An example for a language in which such side-effects
- * would make sense is Java, where the package name and the name of the first
- * public top-level class must match the resource's path.
- *
- * Clients usually call {@link ResourceRelocationContext#addModification} to
- * register their side effects. This way it is ensured that the resource is
- * properly loaded and watched for changes.
- *
- * In Eclipse, {@link IResourceRelocationStrategy} are registered to an extension
- * point.
- *
- * @author koehnlein - Initial contribution and API
- * @since 2.13
- */
-@SuppressWarnings("all")
-public interface IResourceRelocationStrategy {
- void applyChange(final ResourceRelocationContext context);
-
- /**
- * By overriding this method client implementations may explicitly demand for relying
- * on the persisted index during a refactoring.
- *
- * Refactoring operations usually rely on a lively created resource index. However,
- * in case of refactorings affecting a large amounts of files live resource indexing
- * may lead to heap pollution and resultant performance decreases.
- *
- * If a persisted index is supported by the runtime environment and if at least one of the
- * registered implementations of {@link IResourceRelocationStrategy} demands for relying
- * on the persisted index and if, furthermore, required preconditions are satisfied,
- * like no open editor is dirty and the persisted index is up-to-date, the refactoring
- * operation will rely entirely on the persisted index for, e.g., determining incoming
- * references of affected objects, and skip the creation of a live resource index.
- *
- * If some of the additional required preconditions are not met the runtime may execute
- * actions to make the conditions satisfied or reject the refactoring.
- *
- * @since 2.18
- */
- default boolean requiresUsageOfPersistedIndex(final ResourceRelocationContext context) {
- return false;
- }
-}
diff --git a/org.eclipse.xtext.ide/xtend-gen/org/eclipse/xtext/ide/refactoring/RefactoringIssueAcceptor.java b/org.eclipse.xtext.ide/xtend-gen/org/eclipse/xtext/ide/refactoring/RefactoringIssueAcceptor.java
deleted file mode 100644
index c0dc9252b..000000000
--- a/org.eclipse.xtext.ide/xtend-gen/org/eclipse/xtext/ide/refactoring/RefactoringIssueAcceptor.java
+++ /dev/null
@@ -1,46 +0,0 @@
-/**
- * Copyright (c) 2017, 2018 TypeFox GmbH (http://www.typefox.io) and others.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License 2.0 which is available at
- * http://www.eclipse.org/legal/epl-2.0.
- *
- * SPDX-License-Identifier: EPL-2.0
- */
-package org.eclipse.xtext.ide.refactoring;
-
-import org.apache.log4j.Logger;
-import org.eclipse.emf.common.util.URI;
-import org.eclipse.emf.ecore.EObject;
-import org.eclipse.emf.ecore.resource.ResourceSet;
-import org.eclipse.xtext.util.ITextRegion;
-
-/**
- * @author koehnlein - Initial contribution and API
- * @since 2.13
- */
-@SuppressWarnings("all")
-public interface RefactoringIssueAcceptor {
- enum Severity {
- FATAL,
-
- ERROR,
-
- WARNING,
-
- INFO,
-
- OK;
- }
-
- void add(final RefactoringIssueAcceptor.Severity severity, final String message, final URI uri, final ResourceSet resourceSet);
-
- void add(final RefactoringIssueAcceptor.Severity severity, final String message, final URI resourceUri);
-
- void add(final RefactoringIssueAcceptor.Severity severity, final String message, final EObject element);
-
- void add(final RefactoringIssueAcceptor.Severity severity, final String message, final EObject element, final ITextRegion region);
-
- void add(final RefactoringIssueAcceptor.Severity severity, final String message, final Exception exc, final Logger log);
-
- void add(final RefactoringIssueAcceptor.Severity severity, final String message, final Object... params);
-}
diff --git a/org.eclipse.xtext.ide/xtend-gen/org/eclipse/xtext/ide/refactoring/RenameChange.java b/org.eclipse.xtext.ide/xtend-gen/org/eclipse/xtext/ide/refactoring/RenameChange.java
deleted file mode 100644
index 8eced9a32..000000000
--- a/org.eclipse.xtext.ide/xtend-gen/org/eclipse/xtext/ide/refactoring/RenameChange.java
+++ /dev/null
@@ -1,83 +0,0 @@
-/**
- * Copyright (c) 2017 TypeFox GmbH (http://www.typefox.io) and others.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License 2.0 which is available at
- * http://www.eclipse.org/legal/epl-2.0.
- *
- * SPDX-License-Identifier: EPL-2.0
- */
-package org.eclipse.xtext.ide.refactoring;
-
-import org.eclipse.emf.common.util.URI;
-import org.eclipse.xtend.lib.annotations.Data;
-import org.eclipse.xtext.xbase.lib.Pure;
-import org.eclipse.xtext.xbase.lib.util.ToStringBuilder;
-
-/**
- * @author koehnlein - Initial contribution and API
- * @since 2.13
- */
-@Data
-@SuppressWarnings("all")
-public class RenameChange {
- private final String newName;
-
- private final URI targetURI;
-
- public RenameChange(final String newName, final URI targetURI) {
- super();
- this.newName = newName;
- this.targetURI = targetURI;
- }
-
- @Override
- @Pure
- public int hashCode() {
- final int prime = 31;
- int result = 1;
- result = prime * result + ((this.newName== null) ? 0 : this.newName.hashCode());
- return prime * result + ((this.targetURI== null) ? 0 : this.targetURI.hashCode());
- }
-
- @Override
- @Pure
- public boolean equals(final Object obj) {
- if (this == obj)
- return true;
- if (obj == null)
- return false;
- if (getClass() != obj.getClass())
- return false;
- RenameChange other = (RenameChange) obj;
- if (this.newName == null) {
- if (other.newName != null)
- return false;
- } else if (!this.newName.equals(other.newName))
- return false;
- if (this.targetURI == null) {
- if (other.targetURI != null)
- return false;
- } else if (!this.targetURI.equals(other.targetURI))
- return false;
- return true;
- }
-
- @Override
- @Pure
- public String toString() {
- ToStringBuilder b = new ToStringBuilder(this);
- b.add("newName", this.newName);
- b.add("targetURI", this.targetURI);
- return b.toString();
- }
-
- @Pure
- public String getNewName() {
- return this.newName;
- }
-
- @Pure
- public URI getTargetURI() {
- return this.targetURI;
- }
-}
diff --git a/org.eclipse.xtext.ide/xtend-gen/org/eclipse/xtext/ide/refactoring/RenameContext.java b/org.eclipse.xtext.ide/xtend-gen/org/eclipse/xtext/ide/refactoring/RenameContext.java
deleted file mode 100644
index 92fddf691..000000000
--- a/org.eclipse.xtext.ide/xtend-gen/org/eclipse/xtext/ide/refactoring/RenameContext.java
+++ /dev/null
@@ -1,76 +0,0 @@
-/**
- * Copyright (c) 2017 TypeFox GmbH (http://www.typefox.io) and others.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License 2.0 which is available at
- * http://www.eclipse.org/legal/epl-2.0.
- *
- * SPDX-License-Identifier: EPL-2.0
- */
-package org.eclipse.xtext.ide.refactoring;
-
-import java.util.List;
-import org.eclipse.emf.ecore.EObject;
-import org.eclipse.emf.ecore.resource.ResourceSet;
-import org.eclipse.emf.ecore.util.EcoreUtil;
-import org.eclipse.xtend.lib.annotations.AccessorType;
-import org.eclipse.xtend.lib.annotations.Accessors;
-import org.eclipse.xtend.lib.annotations.FinalFieldsConstructor;
-import org.eclipse.xtext.ide.refactoring.RefactoringIssueAcceptor;
-import org.eclipse.xtext.ide.refactoring.RenameChange;
-import org.eclipse.xtext.ide.serializer.IChangeSerializer;
-import org.eclipse.xtext.xbase.lib.Pure;
-
-/**
- * @author koehnlein - Initial contribution and API
- * @since 2.13
- */
-@FinalFieldsConstructor
-@Accessors(AccessorType.PUBLIC_GETTER)
-@SuppressWarnings("all")
-public class RenameContext {
- private final List extends RenameChange> changes;
-
- private final ResourceSet resourceSet;
-
- private final IChangeSerializer changeSerializer;
-
- private final RefactoringIssueAcceptor issues;
-
- public void addModification(final RenameChange change, final IChangeSerializer.IModification modification) {
- final EObject target = this.resourceSet.getEObject(change.getTargetURI(), true);
- if ((target != null)) {
- EcoreUtil.resolveAll(target.eResource());
- this.changeSerializer.addModification(target, modification);
- } else {
- this.issues.add(RefactoringIssueAcceptor.Severity.ERROR, "Element cannot be found", change.getTargetURI());
- }
- }
-
- public RenameContext(final List extends RenameChange> changes, final ResourceSet resourceSet, final IChangeSerializer changeSerializer, final RefactoringIssueAcceptor issues) {
- super();
- this.changes = changes;
- this.resourceSet = resourceSet;
- this.changeSerializer = changeSerializer;
- this.issues = issues;
- }
-
- @Pure
- public List extends RenameChange> getChanges() {
- return this.changes;
- }
-
- @Pure
- public ResourceSet getResourceSet() {
- return this.resourceSet;
- }
-
- @Pure
- public IChangeSerializer getChangeSerializer() {
- return this.changeSerializer;
- }
-
- @Pure
- public RefactoringIssueAcceptor getIssues() {
- return this.issues;
- }
-}
diff --git a/org.eclipse.xtext.ide/xtend-gen/org/eclipse/xtext/ide/refactoring/ResourceRelocationChange.java b/org.eclipse.xtext.ide/xtend-gen/org/eclipse/xtext/ide/refactoring/ResourceRelocationChange.java
deleted file mode 100644
index f879fecda..000000000
--- a/org.eclipse.xtext.ide/xtend-gen/org/eclipse/xtext/ide/refactoring/ResourceRelocationChange.java
+++ /dev/null
@@ -1,97 +0,0 @@
-/**
- * Copyright (c) 2017 TypeFox GmbH (http://www.typefox.io) and others.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License 2.0 which is available at
- * http://www.eclipse.org/legal/epl-2.0.
- *
- * SPDX-License-Identifier: EPL-2.0
- */
-package org.eclipse.xtext.ide.refactoring;
-
-import org.eclipse.emf.common.util.URI;
-import org.eclipse.xtend.lib.annotations.Data;
-import org.eclipse.xtext.xbase.lib.Pure;
-import org.eclipse.xtext.xbase.lib.util.ToStringBuilder;
-
-/**
- * URIs can also refer to folders and non-Xtext resources.
- *
- * @author koehnlein - Initial contribution and API
- * @since 2.13
- */
-@Data
-@SuppressWarnings("all")
-public class ResourceRelocationChange {
- private final URI fromURI;
-
- private final URI toURI;
-
- private final boolean isFile;
-
- public ResourceRelocationChange(final URI fromURI, final URI toURI, final boolean isFile) {
- super();
- this.fromURI = fromURI;
- this.toURI = toURI;
- this.isFile = isFile;
- }
-
- @Override
- @Pure
- public int hashCode() {
- final int prime = 31;
- int result = 1;
- result = prime * result + ((this.fromURI== null) ? 0 : this.fromURI.hashCode());
- result = prime * result + ((this.toURI== null) ? 0 : this.toURI.hashCode());
- return prime * result + (this.isFile ? 1231 : 1237);
- }
-
- @Override
- @Pure
- public boolean equals(final Object obj) {
- if (this == obj)
- return true;
- if (obj == null)
- return false;
- if (getClass() != obj.getClass())
- return false;
- ResourceRelocationChange other = (ResourceRelocationChange) obj;
- if (this.fromURI == null) {
- if (other.fromURI != null)
- return false;
- } else if (!this.fromURI.equals(other.fromURI))
- return false;
- if (this.toURI == null) {
- if (other.toURI != null)
- return false;
- } else if (!this.toURI.equals(other.toURI))
- return false;
- if (other.isFile != this.isFile)
- return false;
- return true;
- }
-
- @Override
- @Pure
- public String toString() {
- ToStringBuilder b = new ToStringBuilder(this);
- b.add("fromURI", this.fromURI);
- b.add("toURI", this.toURI);
- b.add("isFile", this.isFile);
- return b.toString();
- }
-
- @Pure
- public URI getFromURI() {
- return this.fromURI;
- }
-
- @Pure
- public URI getToURI() {
- return this.toURI;
- }
-
- @Pure
- public boolean isFile() {
- return this.isFile;
- }
-}
diff --git a/org.eclipse.xtext.ide/xtend-gen/org/eclipse/xtext/ide/server/BuildListener.java b/org.eclipse.xtext.ide/xtend-gen/org/eclipse/xtext/ide/server/BuildListener.java
deleted file mode 100644
index eb8fb9592..000000000
--- a/org.eclipse.xtext.ide/xtend-gen/org/eclipse/xtext/ide/server/BuildListener.java
+++ /dev/null
@@ -1,20 +0,0 @@
-/**
- * Copyright (c) 2016 TypeFox GmbH (http://www.typefox.io) and others.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License 2.0 which is available at
- * http://www.eclipse.org/legal/epl-2.0.
- *
- * SPDX-License-Identifier: EPL-2.0
- */
-package org.eclipse.xtext.ide.server;
-
-import java.util.List;
-import org.eclipse.xtext.resource.IResourceDescription;
-
-/**
- * @author Sven Efftinge - Initial contribution and API
- */
-@SuppressWarnings("all")
-public interface BuildListener {
- void afterBuild(final List deltas);
-}
diff --git a/org.eclipse.xtext.ide/xtend-gen/org/eclipse/xtext/ide/server/DocumentExtensions.java b/org.eclipse.xtext.ide/xtend-gen/org/eclipse/xtext/ide/server/DocumentExtensions.java
deleted file mode 100644
index d37cb2b00..000000000
--- a/org.eclipse.xtext.ide/xtend-gen/org/eclipse/xtext/ide/server/DocumentExtensions.java
+++ /dev/null
@@ -1,110 +0,0 @@
-/**
- * Copyright (c) 2016, 2017 TypeFox GmbH (http://www.typefox.io) and others.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License 2.0 which is available at
- * http://www.eclipse.org/legal/epl-2.0.
- *
- * SPDX-License-Identifier: EPL-2.0
- */
-package org.eclipse.xtext.ide.server;
-
-import com.google.inject.Inject;
-import com.google.inject.Singleton;
-import org.eclipse.emf.ecore.EObject;
-import org.eclipse.emf.ecore.EStructuralFeature;
-import org.eclipse.emf.ecore.resource.Resource;
-import org.eclipse.lsp4j.Location;
-import org.eclipse.lsp4j.Position;
-import org.eclipse.lsp4j.Range;
-import org.eclipse.xtext.ide.server.UriExtensions;
-import org.eclipse.xtext.nodemodel.ICompositeNode;
-import org.eclipse.xtext.nodemodel.util.NodeModelUtils;
-import org.eclipse.xtext.resource.ILocationInFileProvider;
-import org.eclipse.xtext.resource.XtextResource;
-import org.eclipse.xtext.util.ITextRegion;
-import org.eclipse.xtext.util.LineAndColumn;
-import org.eclipse.xtext.xbase.lib.Extension;
-
-/**
- * @author kosyakov - Initial contribution and API
- * @since 2.11
- */
-@Singleton
-@SuppressWarnings("all")
-public class DocumentExtensions {
- @Inject
- @Extension
- private UriExtensions _uriExtensions;
-
- @Inject
- private ILocationInFileProvider locationInFileProvider;
-
- public Position newPosition(final Resource resource, final int offset) {
- if ((resource instanceof XtextResource)) {
- final ICompositeNode rootNode = ((XtextResource)resource).getParseResult().getRootNode();
- final LineAndColumn lineAndColumn = NodeModelUtils.getLineAndColumn(rootNode, offset);
- int _line = lineAndColumn.getLine();
- int _minus = (_line - 1);
- int _column = lineAndColumn.getColumn();
- int _minus_1 = (_column - 1);
- return new Position(_minus, _minus_1);
- }
- return null;
- }
-
- public Range newRange(final Resource resource, final int startOffset, final int endOffset) {
- final Position startPosition = this.newPosition(resource, startOffset);
- if ((startPosition == null)) {
- return null;
- }
- final Position endPosition = this.newPosition(resource, endOffset);
- if ((endPosition == null)) {
- return null;
- }
- return new Range(startPosition, endPosition);
- }
-
- public Range newRange(final Resource resource, final ITextRegion region) {
- if ((region == null)) {
- return null;
- }
- int _offset = region.getOffset();
- int _offset_1 = region.getOffset();
- int _length = region.getLength();
- int _plus = (_offset_1 + _length);
- return this.newRange(resource, _offset, _plus);
- }
-
- public Location newLocation(final Resource resource, final ITextRegion textRegion) {
- final Range range = this.newRange(resource, textRegion);
- if ((range == null)) {
- return null;
- }
- final String uri = this._uriExtensions.toUriString(resource.getURI());
- return new Location(uri, range);
- }
-
- public Location newLocation(final EObject object) {
- final Resource resource = object.eResource();
- final ITextRegion textRegion = this.locationInFileProvider.getSignificantTextRegion(object);
- return this.newLocation(resource, textRegion);
- }
-
- /**
- * Returns with the {@link Location location} that represents the {@link ILocationInFileProvider#getFullTextRegion full text region}
- * of the argument.
- *
- * @since 2.16
- */
- public Location newFullLocation(final EObject object) {
- final Resource resource = object.eResource();
- final ITextRegion textRegion = this.locationInFileProvider.getFullTextRegion(object);
- return this.newLocation(resource, textRegion);
- }
-
- public Location newLocation(final EObject owner, final EStructuralFeature feature, final int indexInList) {
- final Resource resource = owner.eResource();
- final ITextRegion textRegion = this.locationInFileProvider.getSignificantTextRegion(owner, feature, indexInList);
- return this.newLocation(resource, textRegion);
- }
-}
diff --git a/org.eclipse.xtext.ide/xtend-gen/org/eclipse/xtext/ide/server/UriExtensions.java b/org.eclipse.xtext.ide/xtend-gen/org/eclipse/xtext/ide/server/UriExtensions.java
deleted file mode 100644
index 5d82b3c82..000000000
--- a/org.eclipse.xtext.ide/xtend-gen/org/eclipse/xtext/ide/server/UriExtensions.java
+++ /dev/null
@@ -1,36 +0,0 @@
-/**
- * Copyright (c) 2016, 2017 TypeFox GmbH (http://www.typefox.io) and others.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License 2.0 which is available at
- * http://www.eclipse.org/legal/epl-2.0.
- *
- * SPDX-License-Identifier: EPL-2.0
- */
-package org.eclipse.xtext.ide.server;
-
-import com.google.inject.Singleton;
-import org.eclipse.emf.common.util.URI;
-
-/**
- * Normalizes file uris without authorities (file:/path...
) to contain an empty authority (i.e. starts with three slashes:file:///path...
).
- *
- * @author kosyakov - Initial contribution and API
- * @since 2.11
- */
-@Singleton
-@SuppressWarnings("all")
-public class UriExtensions extends org.eclipse.xtext.util.UriExtensions {
- /**
- * returns the string representation of the given URI (with empty authority, if absent and has file scheme).
- */
- public String toUriString(final URI uri) {
- return this.withEmptyAuthority(uri).toString();
- }
-
- /**
- * converts a java.net.URI into a string representation with empty authority, if absent and has file scheme.
- */
- public String toUriString(final java.net.URI uri) {
- return this.toUriString(URI.createURI(uri.normalize().toString()));
- }
-}
diff --git a/org.eclipse.xtext.ide/xtend-gen/org/eclipse/xtext/ide/server/formatting/FormattingService.java b/org.eclipse.xtext.ide/xtend-gen/org/eclipse/xtext/ide/server/formatting/FormattingService.java
deleted file mode 100644
index f573807f7..000000000
--- a/org.eclipse.xtext.ide/xtend-gen/org/eclipse/xtext/ide/server/formatting/FormattingService.java
+++ /dev/null
@@ -1,133 +0,0 @@
-/**
- * Copyright (c) 2016, 2018 itemis AG (http://www.itemis.com) and others.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License 2.0 which is available at
- * http://www.eclipse.org/legal/epl-2.0.
- *
- * SPDX-License-Identifier: EPL-2.0
- */
-package org.eclipse.xtext.ide.server.formatting;
-
-import com.google.common.base.Strings;
-import com.google.inject.Inject;
-import com.google.inject.Provider;
-import java.util.Collections;
-import java.util.List;
-import org.eclipse.lsp4j.DocumentFormattingParams;
-import org.eclipse.lsp4j.DocumentRangeFormattingParams;
-import org.eclipse.lsp4j.FormattingOptions;
-import org.eclipse.lsp4j.Range;
-import org.eclipse.lsp4j.TextEdit;
-import org.eclipse.xtext.formatting.IIndentationInformation;
-import org.eclipse.xtext.formatting2.FormatterRequest;
-import org.eclipse.xtext.formatting2.IFormatter2;
-import org.eclipse.xtext.formatting2.regionaccess.ITextRegionAccess;
-import org.eclipse.xtext.formatting2.regionaccess.ITextReplacement;
-import org.eclipse.xtext.formatting2.regionaccess.TextRegionAccessBuilder;
-import org.eclipse.xtext.ide.server.Document;
-import org.eclipse.xtext.preferences.ITypedPreferenceValues;
-import org.eclipse.xtext.preferences.MapBasedPreferenceValues;
-import org.eclipse.xtext.resource.XtextResource;
-import org.eclipse.xtext.util.CancelIndicator;
-import org.eclipse.xtext.util.ITextRegion;
-import org.eclipse.xtext.util.TextRegion;
-import org.eclipse.xtext.xbase.lib.CollectionLiterals;
-import org.eclipse.xtext.xbase.lib.Functions.Function1;
-import org.eclipse.xtext.xbase.lib.IterableExtensions;
-import org.eclipse.xtext.xbase.lib.ListExtensions;
-import org.eclipse.xtext.xbase.lib.ObjectExtensions;
-import org.eclipse.xtext.xbase.lib.Procedures.Procedure1;
-
-/**
- * Language Service Implementation for Formatting and Range-Formatting
- *
- * @author Christian Dietrich - Initial contribution and API
- * @since 2.11
- */
-@SuppressWarnings("all")
-public class FormattingService {
- @Inject(optional = true)
- private Provider formatter2Provider;
-
- @Inject
- private Provider formatterRequestProvider;
-
- @Inject
- private TextRegionAccessBuilder regionBuilder;
-
- @Inject
- private IIndentationInformation indentationInformation;
-
- public List extends TextEdit> format(final Document document, final XtextResource resource, final DocumentFormattingParams params, final CancelIndicator cancelIndicator) {
- final int offset = 0;
- final int length = document.getContents().length();
- if (((length == 0) || resource.getContents().isEmpty())) {
- return CollectionLiterals.emptyList();
- }
- return this.format(resource, document, offset, length, params.getOptions());
- }
-
- public List extends TextEdit> format(final Document document, final XtextResource resource, final DocumentRangeFormattingParams params, final CancelIndicator cancelIndicator) {
- final int offset = document.getOffSet(params.getRange().getStart());
- int _offSet = document.getOffSet(params.getRange().getEnd());
- final int length = (_offSet - offset);
- return this.format(resource, document, offset, length, params.getOptions());
- }
-
- /**
- * @since 2.14
- */
- public List format(final XtextResource resource, final Document document, final int offset, final int length, final FormattingOptions options) {
- String indent = this.indentationInformation.getIndentString();
- if ((options != null)) {
- boolean _isInsertSpaces = options.isInsertSpaces();
- if (_isInsertSpaces) {
- indent = Strings.padEnd("", options.getTabSize(), ' ');
- }
- }
- if ((this.formatter2Provider != null)) {
- final MapBasedPreferenceValues preferences = new MapBasedPreferenceValues();
- preferences.put("indentation", indent);
- TextRegion _textRegion = new TextRegion(offset, length);
- final List replacements = this.format2(resource, _textRegion, preferences);
- final Function1 _function = (ITextReplacement r) -> {
- return this.toTextEdit(document, r.getReplacementText(), r.getOffset(), r.getLength());
- };
- return IterableExtensions.toList(ListExtensions.map(replacements, _function));
- } else {
- return CollectionLiterals.newArrayList();
- }
- }
-
- protected TextEdit toTextEdit(final Document document, final String formattedText, final int startOffset, final int length) {
- TextEdit _textEdit = new TextEdit();
- final Procedure1 _function = (TextEdit it) -> {
- it.setNewText(formattedText);
- Range _range = new Range();
- final Procedure1 _function_1 = (Range it_1) -> {
- it_1.setStart(document.getPosition(startOffset));
- it_1.setEnd(document.getPosition((startOffset + length)));
- };
- Range _doubleArrow = ObjectExtensions.operator_doubleArrow(_range, _function_1);
- it.setRange(_doubleArrow);
- };
- return ObjectExtensions.operator_doubleArrow(_textEdit, _function);
- }
-
- protected List format2(final XtextResource resource, final ITextRegion selection, final ITypedPreferenceValues preferences) {
- final FormatterRequest request = this.formatterRequestProvider.get();
- request.setAllowIdentityEdits(false);
- request.setFormatUndefinedHiddenRegionsOnly(false);
- if ((selection != null)) {
- request.setRegions(Collections.unmodifiableList(CollectionLiterals.newArrayList(selection)));
- }
- if ((preferences != null)) {
- request.setPreferences(preferences);
- }
- final ITextRegionAccess regionAccess = this.regionBuilder.forNodeModel(resource).create();
- request.setTextRegionAccess(regionAccess);
- final IFormatter2 formatter2 = this.formatter2Provider.get();
- final List replacements = formatter2.format(request);
- return replacements;
- }
-}
diff --git a/org.eclipse.xtext.ide/xtend-gen/org/eclipse/xtext/ide/server/hover/HoverService.java b/org.eclipse.xtext.ide/xtend-gen/org/eclipse/xtext/ide/server/hover/HoverService.java
deleted file mode 100644
index 29c712899..000000000
--- a/org.eclipse.xtext.ide/xtend-gen/org/eclipse/xtext/ide/server/hover/HoverService.java
+++ /dev/null
@@ -1,140 +0,0 @@
-/**
- * Copyright (c) 2016, 2020 TypeFox GmbH (http://www.typefox.io) and others.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License 2.0 which is available at
- * http://www.eclipse.org/legal/epl-2.0.
- *
- * SPDX-License-Identifier: EPL-2.0
- */
-package org.eclipse.xtext.ide.server.hover;
-
-import com.google.common.annotations.Beta;
-import com.google.inject.Inject;
-import com.google.inject.Singleton;
-import org.eclipse.emf.ecore.EObject;
-import org.eclipse.lsp4j.Hover;
-import org.eclipse.lsp4j.HoverParams;
-import org.eclipse.lsp4j.MarkupContent;
-import org.eclipse.lsp4j.Range;
-import org.eclipse.xtext.documentation.IEObjectDocumentationProvider;
-import org.eclipse.xtext.ide.server.Document;
-import org.eclipse.xtext.ide.server.DocumentExtensions;
-import org.eclipse.xtext.ide.server.hover.HoverContext;
-import org.eclipse.xtext.ide.server.hover.IHoverService;
-import org.eclipse.xtext.nodemodel.ILeafNode;
-import org.eclipse.xtext.nodemodel.util.NodeModelUtils;
-import org.eclipse.xtext.parser.IParseResult;
-import org.eclipse.xtext.resource.EObjectAtOffsetHelper;
-import org.eclipse.xtext.resource.ILocationInFileProvider;
-import org.eclipse.xtext.resource.XtextResource;
-import org.eclipse.xtext.util.CancelIndicator;
-import org.eclipse.xtext.util.ITextRegion;
-import org.eclipse.xtext.xbase.lib.Extension;
-
-/**
- * @author kosyakov - Initial contribution and API
- * @since 2.11
- */
-@Singleton
-@Beta
-@SuppressWarnings("all")
-public class HoverService implements IHoverService {
- @Inject
- @Extension
- private DocumentExtensions _documentExtensions;
-
- @Inject
- @Extension
- private EObjectAtOffsetHelper _eObjectAtOffsetHelper;
-
- @Inject
- @Extension
- private ILocationInFileProvider _iLocationInFileProvider;
-
- @Inject
- @Extension
- private IEObjectDocumentationProvider _iEObjectDocumentationProvider;
-
- @Override
- public Hover hover(final Document document, final XtextResource resource, final HoverParams params, final CancelIndicator cancelIndicator) {
- final int offset = document.getOffSet(params.getPosition());
- final HoverContext context = this.createContext(document, resource, offset);
- return this.hover(context);
- }
-
- protected HoverContext createContext(final Document document, final XtextResource resource, final int offset) {
- final EObject crossLinkedEObject = this._eObjectAtOffsetHelper.resolveCrossReferencedElementAt(resource, offset);
- if ((crossLinkedEObject != null)) {
- boolean _eIsProxy = crossLinkedEObject.eIsProxy();
- if (_eIsProxy) {
- return null;
- }
- final IParseResult parseResult = resource.getParseResult();
- if ((parseResult == null)) {
- return null;
- }
- ILeafNode leafNode = NodeModelUtils.findLeafNodeAtOffset(parseResult.getRootNode(), offset);
- if ((((leafNode != null) && leafNode.isHidden()) && (leafNode.getOffset() == offset))) {
- leafNode = NodeModelUtils.findLeafNodeAtOffset(parseResult.getRootNode(), (offset - 1));
- }
- if ((leafNode == null)) {
- return null;
- }
- final ITextRegion leafRegion = leafNode.getTextRegion();
- return new HoverContext(document, resource, offset, leafRegion, crossLinkedEObject);
- }
- final EObject element = this._eObjectAtOffsetHelper.resolveElementAt(resource, offset);
- if ((element == null)) {
- return null;
- }
- final ITextRegion region = this._iLocationInFileProvider.getSignificantTextRegion(element);
- return new HoverContext(document, resource, offset, region, element);
- }
-
- protected Hover hover(final HoverContext context) {
- if ((context == null)) {
- return IHoverService.EMPTY_HOVER;
- }
- final MarkupContent contents = this.getMarkupContent(context);
- if ((contents == null)) {
- return IHoverService.EMPTY_HOVER;
- }
- final Range range = this.getRange(context);
- if ((range == null)) {
- return IHoverService.EMPTY_HOVER;
- }
- return new Hover(contents, range);
- }
-
- protected Range getRange(final HoverContext it) {
- boolean _contains = it.getRegion().contains(it.getOffset());
- boolean _not = (!_contains);
- if (_not) {
- return null;
- }
- return this._documentExtensions.newRange(it.getResource(), it.getRegion());
- }
-
- protected MarkupContent getMarkupContent(final HoverContext it) {
- return this.toMarkupContent(this.getKind(it), this.getContents(it.getElement()));
- }
-
- protected String getKind(final HoverContext it) {
- return "markdown";
- }
-
- protected MarkupContent toMarkupContent(final String kind, final String value) {
- return new MarkupContent(kind, value);
- }
-
- public String getContents(final EObject element) {
- if ((element == null)) {
- return "";
- }
- final String documentation = this._iEObjectDocumentationProvider.getDocumentation(element);
- if ((documentation == null)) {
- return "";
- }
- return documentation;
- }
-}
diff --git a/org.eclipse.xtext.ide/xtend-gen/org/eclipse/xtext/ide/server/rename/ServerRefactoringIssueAcceptor.java b/org.eclipse.xtext.ide/xtend-gen/org/eclipse/xtext/ide/server/rename/ServerRefactoringIssueAcceptor.java
deleted file mode 100644
index 84de898d1..000000000
--- a/org.eclipse.xtext.ide/xtend-gen/org/eclipse/xtext/ide/server/rename/ServerRefactoringIssueAcceptor.java
+++ /dev/null
@@ -1,181 +0,0 @@
-/**
- * Copyright (c) 2017 TypeFox GmbH (http://www.typefox.io) and others.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License 2.0 which is available at
- * http://www.eclipse.org/legal/epl-2.0.
- *
- * SPDX-License-Identifier: EPL-2.0
- */
-package org.eclipse.xtext.ide.server.rename;
-
-import java.util.List;
-import org.apache.log4j.Logger;
-import org.eclipse.emf.common.util.URI;
-import org.eclipse.emf.ecore.EObject;
-import org.eclipse.emf.ecore.resource.ResourceSet;
-import org.eclipse.lsp4j.jsonrpc.ResponseErrorException;
-import org.eclipse.lsp4j.jsonrpc.messages.ResponseError;
-import org.eclipse.lsp4j.jsonrpc.messages.ResponseErrorCode;
-import org.eclipse.xtext.ide.refactoring.RefactoringIssueAcceptor;
-import org.eclipse.xtext.util.ITextRegion;
-import org.eclipse.xtext.xbase.lib.CollectionLiterals;
-import org.eclipse.xtext.xbase.lib.Functions.Function1;
-import org.eclipse.xtext.xbase.lib.IterableExtensions;
-import org.eclipse.xtext.xbase.lib.ListExtensions;
-import org.eclipse.xtext.xbase.lib.ObjectExtensions;
-import org.eclipse.xtext.xbase.lib.Procedures.Procedure1;
-
-/**
- * @author koehnlein - Initial contribution and API
- * @since 2.13
- */
-@SuppressWarnings("all")
-public class ServerRefactoringIssueAcceptor implements RefactoringIssueAcceptor {
- public static class Issue {
- private RefactoringIssueAcceptor.Severity severity;
-
- private String message;
- }
-
- private List issues = CollectionLiterals.newArrayList();
-
- @Override
- public void add(final RefactoringIssueAcceptor.Severity severity, final String message, final URI uri, final ResourceSet resourceSet) {
- this.addIssue(severity, message);
- }
-
- @Override
- public void add(final RefactoringIssueAcceptor.Severity severity, final String message, final URI resourceUri) {
- this.addIssue(severity, message);
- }
-
- @Override
- public void add(final RefactoringIssueAcceptor.Severity severity, final String message, final EObject element) {
- this.addIssue(severity, message);
- }
-
- @Override
- public void add(final RefactoringIssueAcceptor.Severity severity, final String message, final EObject element, final ITextRegion region) {
- this.addIssue(severity, message);
- }
-
- @Override
- public void add(final RefactoringIssueAcceptor.Severity severity, final String message, final Exception exc, final Logger log) {
- this.addIssue(severity, message);
- }
-
- @Override
- public void add(final RefactoringIssueAcceptor.Severity severity, final String message, final Object... params) {
- ServerRefactoringIssueAcceptor.Issue _issue = new ServerRefactoringIssueAcceptor.Issue();
- final Procedure1 _function = (ServerRefactoringIssueAcceptor.Issue it) -> {
- it.severity = severity;
- it.message = message;
- };
- ServerRefactoringIssueAcceptor.Issue _doubleArrow = ObjectExtensions.operator_doubleArrow(_issue, _function);
- this.issues.add(_doubleArrow);
- }
-
- protected boolean addIssue(final RefactoringIssueAcceptor.Severity severity, final String message) {
- ServerRefactoringIssueAcceptor.Issue _issue = new ServerRefactoringIssueAcceptor.Issue();
- final Procedure1 _function = (ServerRefactoringIssueAcceptor.Issue it) -> {
- it.severity = severity;
- it.message = message;
- };
- ServerRefactoringIssueAcceptor.Issue _doubleArrow = ObjectExtensions.operator_doubleArrow(_issue, _function);
- return this.issues.add(_doubleArrow);
- }
-
- public RefactoringIssueAcceptor.Severity getMaximumSeverity() {
- RefactoringIssueAcceptor.Severity _xifexpression = null;
- int _size = this.issues.size();
- boolean _greaterThan = (_size > 0);
- if (_greaterThan) {
- final Function1 _function = (ServerRefactoringIssueAcceptor.Issue it) -> {
- return it.severity;
- };
- ServerRefactoringIssueAcceptor.Issue _minBy = IterableExtensions.minBy(this.issues, _function);
- RefactoringIssueAcceptor.Severity _severity = null;
- if (_minBy!=null) {
- _severity=_minBy.severity;
- }
- _xifexpression = _severity;
- } else {
- _xifexpression = RefactoringIssueAcceptor.Severity.OK;
- }
- return _xifexpression;
- }
-
- public ResponseError toResponseError() {
- ResponseError _xblockexpression = null;
- {
- final RefactoringIssueAcceptor.Severity maxSeverity = this.getMaximumSeverity();
- ResponseError _responseError = new ResponseError();
- final Procedure1 _function = (ResponseError it) -> {
- String _switchResult = null;
- if (maxSeverity != null) {
- switch (maxSeverity) {
- case OK:
- _switchResult = "Refactoring is possible";
- break;
- case INFO:
- _switchResult = "Refactoring is possible";
- break;
- case WARNING:
- _switchResult = "Refactoring could cause issues";
- break;
- case ERROR:
- _switchResult = "Refactoring has errors";
- break;
- case FATAL:
- _switchResult = "Refactoring cannot be performed";
- break;
- default:
- break;
- }
- }
- it.setMessage(_switchResult);
- final Function1 _function_1 = (ServerRefactoringIssueAcceptor.Issue it_1) -> {
- return it_1.severity;
- };
- final Function1 _function_2 = (ServerRefactoringIssueAcceptor.Issue it_1) -> {
- return it_1.message;
- };
- it.setData(IterableExtensions.join(ListExtensions.map(ListExtensions.reverse(IterableExtensions.sortBy(this.issues, _function_1)), _function_2), "\n"));
- int _switchResult_1 = (int) 0;
- if (maxSeverity != null) {
- switch (maxSeverity) {
- case OK:
- _switchResult_1 = 0;
- break;
- case INFO:
- _switchResult_1 = 0;
- break;
- case WARNING:
- _switchResult_1 = 0;
- break;
- case ERROR:
- _switchResult_1 = ResponseErrorCode.UnknownErrorCode.getValue();
- break;
- case FATAL:
- _switchResult_1 = ResponseErrorCode.UnknownErrorCode.getValue();
- break;
- default:
- break;
- }
- }
- it.setCode(_switchResult_1);
- };
- _xblockexpression = ObjectExtensions.operator_doubleArrow(_responseError, _function);
- }
- return _xblockexpression;
- }
-
- public void checkSeverity() {
- RefactoringIssueAcceptor.Severity _maximumSeverity = this.getMaximumSeverity();
- boolean _lessThan = (_maximumSeverity.compareTo(RefactoringIssueAcceptor.Severity.WARNING) < 0);
- if (_lessThan) {
- ResponseError _responseError = this.toResponseError();
- throw new ResponseErrorException(_responseError);
- }
- }
-}