diff --git a/org.eclipse.xtext.dev-bom/pom.xml b/org.eclipse.xtext.dev-bom/pom.xml
index 6c58ff7f4b9..c3289dfa932 100644
--- a/org.eclipse.xtext.dev-bom/pom.xml
+++ b/org.eclipse.xtext.dev-bom/pom.xml
@@ -287,37 +287,37 @@
org.eclipse.lsp4j
org.eclipse.lsp4j.debug
- 0.21.1
+ 0.21.2
org.eclipse.lsp4j
org.eclipse.lsp4j.generator
- 0.21.1
+ 0.21.2
org.eclipse.lsp4j
org.eclipse.lsp4j.jsonrpc.debug
- 0.21.1
+ 0.21.2
org.eclipse.lsp4j
org.eclipse.lsp4j.jsonrpc
- 0.21.1
+ 0.21.2
org.eclipse.lsp4j
org.eclipse.lsp4j.websocket.jakarta
- 0.21.1
+ 0.21.2
org.eclipse.lsp4j
org.eclipse.lsp4j.websocket
- 0.21.1
+ 0.21.2
org.eclipse.lsp4j
org.eclipse.lsp4j
- 0.21.1
+ 0.21.2
org.eclipse.platform
diff --git a/org.eclipse.xtext.ide.tests/META-INF/MANIFEST.MF b/org.eclipse.xtext.ide.tests/META-INF/MANIFEST.MF
index 4e73ac49847..8a367e552e3 100644
--- a/org.eclipse.xtext.ide.tests/META-INF/MANIFEST.MF
+++ b/org.eclipse.xtext.ide.tests/META-INF/MANIFEST.MF
@@ -14,8 +14,8 @@ Require-Bundle: org.eclipse.xtext;bundle-version="2.34.0";visibility:=reexport,
org.eclipse.core.runtime;bundle-version="3.24.100",
org.eclipse.xtext.ide;bundle-version="2.34.0",
org.junit;bundle-version="4.13.2",
- org.eclipse.lsp4j;bundle-version="[0.21.1,0.22.0)";resolution:=optional,
- org.eclipse.lsp4j.jsonrpc;bundle-version="[0.21.1,0.22.0)";resolution:=optional,
+ org.eclipse.lsp4j;bundle-version="[0.21.2,0.22.0)";resolution:=optional,
+ org.eclipse.lsp4j.jsonrpc;bundle-version="[0.21.2,0.22.0)";resolution:=optional,
org.eclipse.xtext.testlanguages;bundle-version="2.34.0",
org.eclipse.xtext.testlanguages.ide;bundle-version="2.34.0",
org.eclipse.emf.mwe2.lib;bundle-version="2.17.0",
diff --git a/org.eclipse.xtext.ide/META-INF/MANIFEST.MF b/org.eclipse.xtext.ide/META-INF/MANIFEST.MF
index 1e6d3cb3740..2fe9657fd41 100644
--- a/org.eclipse.xtext.ide/META-INF/MANIFEST.MF
+++ b/org.eclipse.xtext.ide/META-INF/MANIFEST.MF
@@ -11,8 +11,8 @@ Require-Bundle: org.eclipse.xtext;bundle-version="2.34.0";visibility:=reexport,
org.eclipse.xtend.lib;bundle-version="2.34.0",
org.eclipse.core.runtime;bundle-version="3.24.100";resolution:=optional;x-installation:=greedy,
org.eclipse.equinox.common;bundle-version="3.16.0",
- org.eclipse.lsp4j;bundle-version="[0.21.1,0.22.0)";resolution:=optional,
- org.eclipse.lsp4j.jsonrpc;bundle-version="[0.21.1,0.22.0)";resolution:=optional,
+ org.eclipse.lsp4j;bundle-version="[0.21.2,0.22.0)";resolution:=optional,
+ org.eclipse.lsp4j.jsonrpc;bundle-version="[0.21.2,0.22.0)";resolution:=optional,
org.eclipse.emf.ecore.change;bundle-version="[2.14.0,3)"
Import-Package: org.apache.log4j;version="1.2.24"
Export-Package: org.eclipse.xtext.ide;version="2.34.0";
diff --git a/org.eclipse.xtext.xbase/src/org/eclipse/xtext/xbase/compiler/XbaseCompiler.java b/org.eclipse.xtext.xbase/src/org/eclipse/xtext/xbase/compiler/XbaseCompiler.java
index 1136e0f73ae..6e15a44ed2e 100644
--- a/org.eclipse.xtext.xbase/src/org/eclipse/xtext/xbase/compiler/XbaseCompiler.java
+++ b/org.eclipse.xtext.xbase/src/org/eclipse/xtext/xbase/compiler/XbaseCompiler.java
@@ -99,7 +99,6 @@
import com.google.common.base.Objects;
import com.google.common.base.Preconditions;
-import com.google.common.collect.Iterables;
import com.google.common.collect.Lists;
import com.google.inject.Inject;
@@ -1106,7 +1105,9 @@ protected void constructorCallToJavaExpression(final XConstructorCall expr, ITre
}
ITreeAppendable typeAppendable = appendableWithNewKeyword.trace(expr, XbasePackage.Literals.XCONSTRUCTOR_CALL__CONSTRUCTOR, 0);
appendConstructedTypeName(expr, typeAppendable);
- if (hasTypeArguments || (expr.isAnonymousClassConstructorCall() && !explicitTypeArguments.isEmpty() && ((JvmGenericType) constructor.getDeclaringType()).isAnonymous())) {
+ if (hasTypeArguments ||
+ (!explicitTypeArguments.isEmpty() &&
+ canCompileToJavaAnonymousClass(expr))) {
if (typeArguments.isEmpty()) {
LightweightTypeReference createdType = resolvedTypes.getActualType(expr);
typeArguments = createdType.getNamedType().getTypeArguments();
@@ -1132,16 +1133,25 @@ protected void constructorCallToJavaExpression(final XConstructorCall expr, ITre
}
protected void appendConstructedTypeName(XConstructorCall constructorCall, ITreeAppendable typeAppendable) {
- JvmDeclaredType type = constructorCall.getConstructor().getDeclaringType();
- if (type instanceof JvmGenericType && ((JvmGenericType) type).isAnonymous()) {
- typeAppendable.append(Iterables.getLast(type.getSuperTypes()).getType());
+ IResolvedTypes resolvedTypes = batchTypeResolver.resolveTypes(constructorCall);
+ LightweightTypeReference actualType = resolvedTypes.getActualType(constructorCall);
+ if (canCompileToJavaAnonymousClass(constructorCall)) {
+ typeAppendable.append(actualType.getNamedType().getRawTypeReference());
} else {
- IResolvedTypes resolvedTypes = batchTypeResolver.resolveTypes(constructorCall);
- LightweightTypeReference actualType = resolvedTypes.getActualType(constructorCall).getRawTypeReference();
- typeAppendable.append(actualType);
+ typeAppendable.append(actualType.getRawTypeReference());
}
}
-
+
+ /**
+ * @since 2.34
+ */
+ protected boolean canCompileToJavaAnonymousClass(XConstructorCall constructorCall) {
+ if (!constructorCall.isAnonymousClassConstructorCall())
+ return false;
+ JvmDeclaredType type = constructorCall.getConstructor().getDeclaringType();
+ return type instanceof JvmGenericType && ((JvmGenericType) type).isAnonymous();
+ }
+
/* @Nullable */
protected ILocationData getLocationWithNewKeyword(XConstructorCall call) {
final ICompositeNode startNode = NodeModelUtils.getNode(call);
@@ -2167,6 +2177,13 @@ protected boolean isVariableDeclarationRequired(XExpression expr, ITreeAppendabl
}
}
}
+ if (expr instanceof XConstructorCall) {
+ XConstructorCall constructorCall = (XConstructorCall) expr;
+ if (constructorCall.isAnonymousClassConstructorCall()) {
+ return isVariableDeclarationRequired((XExpression) container, b, recursive) &&
+ !canCompileToJavaAnonymousClass(constructorCall);
+ }
+ }
return super.isVariableDeclarationRequired(expr, b, recursive);
}
diff --git a/xtext-latest.target b/xtext-latest.target
index 3395026f68a..ae35e5aecfe 100644
--- a/xtext-latest.target
+++ b/xtext-latest.target
@@ -1,6 +1,6 @@
-
+
@@ -29,7 +29,7 @@
-
+
diff --git a/xtext-r202203.target b/xtext-r202203.target
index 658dbf9bdf9..9e2de5835fe 100644
--- a/xtext-r202203.target
+++ b/xtext-r202203.target
@@ -1,6 +1,6 @@
-
+
@@ -27,7 +27,7 @@
-
+
diff --git a/xtext-r202206.target b/xtext-r202206.target
index cb5cc99d73a..2bb62fc1838 100644
--- a/xtext-r202206.target
+++ b/xtext-r202206.target
@@ -1,6 +1,6 @@
-
+
@@ -26,7 +26,7 @@
-
+
diff --git a/xtext-r202209.target b/xtext-r202209.target
index 7f7bde44359..7705ef42da4 100644
--- a/xtext-r202209.target
+++ b/xtext-r202209.target
@@ -1,6 +1,6 @@
-
+
@@ -31,7 +31,7 @@
-
+
diff --git a/xtext-r202212.target b/xtext-r202212.target
index 32d50492fae..6028a714a8d 100644
--- a/xtext-r202212.target
+++ b/xtext-r202212.target
@@ -1,6 +1,6 @@
-
+
@@ -31,7 +31,7 @@
-
+
diff --git a/xtext-r202303.target b/xtext-r202303.target
index e75ad54f304..bf5650a2a8b 100644
--- a/xtext-r202303.target
+++ b/xtext-r202303.target
@@ -1,6 +1,6 @@
-
+
@@ -31,7 +31,7 @@
-
+
diff --git a/xtext-r202306.target b/xtext-r202306.target
index 5f773fd6ad8..c1079ee0bed 100644
--- a/xtext-r202306.target
+++ b/xtext-r202306.target
@@ -1,6 +1,6 @@
-
+
@@ -31,7 +31,7 @@
-
+
diff --git a/xtext-r202309.target b/xtext-r202309.target
index 6b447704f88..a6ff1eb8f44 100644
--- a/xtext-r202309.target
+++ b/xtext-r202309.target
@@ -1,6 +1,6 @@
-
+
@@ -31,7 +31,7 @@
-
+
diff --git a/xtext-r202312.target b/xtext-r202312.target
index fe00119048f..ff64237daae 100644
--- a/xtext-r202312.target
+++ b/xtext-r202312.target
@@ -1,6 +1,6 @@
-
+
@@ -31,7 +31,7 @@
-
+