From 04808b6e63cac0d8e9b805c3e5536f52ab6d330f Mon Sep 17 00:00:00 2001 From: Lorenzo Bettini Date: Tue, 2 Jan 2024 07:57:34 +0100 Subject: [PATCH 01/10] simplified appendConstructedTypeName use getNamedType instead of manually retrieving the last element of supertypes --- .../org/eclipse/xtext/xbase/compiler/XbaseCompiler.java | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) 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..ceb705876a6 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; @@ -1133,12 +1132,12 @@ protected void constructorCallToJavaExpression(final XConstructorCall expr, ITre protected void appendConstructedTypeName(XConstructorCall constructorCall, ITreeAppendable typeAppendable) { JvmDeclaredType type = constructorCall.getConstructor().getDeclaringType(); + IResolvedTypes resolvedTypes = batchTypeResolver.resolveTypes(constructorCall); + LightweightTypeReference actualType = resolvedTypes.getActualType(constructorCall); if (type instanceof JvmGenericType && ((JvmGenericType) type).isAnonymous()) { - typeAppendable.append(Iterables.getLast(type.getSuperTypes()).getType()); + typeAppendable.append(actualType.getNamedType().getRawTypeReference()); } else { - IResolvedTypes resolvedTypes = batchTypeResolver.resolveTypes(constructorCall); - LightweightTypeReference actualType = resolvedTypes.getActualType(constructorCall).getRawTypeReference(); - typeAppendable.append(actualType); + typeAppendable.append(actualType.getRawTypeReference()); } } From ee568cad30a4532e07cafc278a30e94bf250709d Mon Sep 17 00:00:00 2001 From: Lorenzo Bettini Date: Tue, 2 Jan 2024 08:15:35 +0100 Subject: [PATCH 02/10] canCompileToJavaAnonymousClass --- .../xtext/xbase/compiler/XbaseCompiler.java | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) 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 ceb705876a6..df409254bfe 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 @@ -1105,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(); @@ -1131,16 +1133,23 @@ protected void constructorCallToJavaExpression(final XConstructorCall expr, ITre } protected void appendConstructedTypeName(XConstructorCall constructorCall, ITreeAppendable typeAppendable) { - JvmDeclaredType type = constructorCall.getConstructor().getDeclaringType(); IResolvedTypes resolvedTypes = batchTypeResolver.resolveTypes(constructorCall); LightweightTypeReference actualType = resolvedTypes.getActualType(constructorCall); - if (type instanceof JvmGenericType && ((JvmGenericType) type).isAnonymous()) { + if (canCompileToJavaAnonymousClass(constructorCall)) { typeAppendable.append(actualType.getNamedType().getRawTypeReference()); } else { typeAppendable.append(actualType.getRawTypeReference()); } } - + + /** + * @since 2.34 + */ + protected boolean canCompileToJavaAnonymousClass(XConstructorCall constructorCall) { + JvmDeclaredType type = constructorCall.getConstructor().getDeclaringType(); + return type instanceof JvmGenericType && ((JvmGenericType) type).isAnonymous(); + } + /* @Nullable */ protected ILocationData getLocationWithNewKeyword(XConstructorCall call) { final ICompositeNode startNode = NodeModelUtils.getNode(call); From d4cb54f3f71b4be7ff39dcd91dddd7d6b08c4894 Mon Sep 17 00:00:00 2001 From: Lorenzo Bettini Date: Tue, 2 Jan 2024 10:10:06 +0100 Subject: [PATCH 03/10] check isAnonymousClassConstructorCall --- .../src/org/eclipse/xtext/xbase/compiler/XbaseCompiler.java | 2 ++ 1 file changed, 2 insertions(+) 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 df409254bfe..5402e8299a3 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 @@ -1146,6 +1146,8 @@ protected void appendConstructedTypeName(XConstructorCall constructorCall, ITree * @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(); } From e00373397b6b2863ba68a68f51e681470258fe35 Mon Sep 17 00:00:00 2001 From: Lorenzo Bettini Date: Tue, 2 Jan 2024 10:10:25 +0100 Subject: [PATCH 04/10] Xtend uses canCompileToJavaAnonymousClass --- .../eclipse/xtend/core/compiler/XtendCompiler.java | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/org.eclipse.xtend.core/src/org/eclipse/xtend/core/compiler/XtendCompiler.java b/org.eclipse.xtend.core/src/org/eclipse/xtend/core/compiler/XtendCompiler.java index d2273937db8..2993d680c1a 100644 --- a/org.eclipse.xtend.core/src/org/eclipse/xtend/core/compiler/XtendCompiler.java +++ b/org.eclipse.xtend.core/src/org/eclipse/xtend/core/compiler/XtendCompiler.java @@ -581,16 +581,12 @@ protected boolean internalCanCompileToJavaExpression(XExpression expression, ITr protected boolean isVariableDeclarationRequired(XExpression expr, ITreeAppendable b, boolean recursive) { boolean result = super.isVariableDeclarationRequired(expr, b, recursive); if (result && expr instanceof XConstructorCall) { - EObject container = expr.eContainer(); - if (container instanceof AnonymousClass) { - AnonymousClass anonymousClass = (AnonymousClass) container; - result = isVariableDeclarationRequired(anonymousClass, b, recursive); + XConstructorCall constructorCall = (XConstructorCall) expr; + if (constructorCall.isAnonymousClassConstructorCall()) { + EObject container = expr.eContainer(); + result = isVariableDeclarationRequired((XExpression) container, b, recursive); if (result) { - JvmConstructor constructor = anonymousClass.getConstructorCall().getConstructor(); - JvmDeclaredType type = constructor.getDeclaringType(); - if (((JvmGenericType) type).isAnonymous()) { - return false; - } + return !canCompileToJavaAnonymousClass(constructorCall); } } } From 6847a7e953927b76860b219fbbad4b42a54cce0c Mon Sep 17 00:00:00 2001 From: Lorenzo Bettini Date: Tue, 2 Jan 2024 12:26:38 +0100 Subject: [PATCH 05/10] simplified isVariableDeclarationRequired --- .../src/org/eclipse/xtend/core/compiler/XtendCompiler.java | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/org.eclipse.xtend.core/src/org/eclipse/xtend/core/compiler/XtendCompiler.java b/org.eclipse.xtend.core/src/org/eclipse/xtend/core/compiler/XtendCompiler.java index 2993d680c1a..a5ba3e997cb 100644 --- a/org.eclipse.xtend.core/src/org/eclipse/xtend/core/compiler/XtendCompiler.java +++ b/org.eclipse.xtend.core/src/org/eclipse/xtend/core/compiler/XtendCompiler.java @@ -584,10 +584,8 @@ protected boolean isVariableDeclarationRequired(XExpression expr, ITreeAppendabl XConstructorCall constructorCall = (XConstructorCall) expr; if (constructorCall.isAnonymousClassConstructorCall()) { EObject container = expr.eContainer(); - result = isVariableDeclarationRequired((XExpression) container, b, recursive); - if (result) { - return !canCompileToJavaAnonymousClass(constructorCall); - } + return isVariableDeclarationRequired((XExpression) container, b, recursive) && + !canCompileToJavaAnonymousClass(constructorCall); } } return result; From 4a3e18f8c1830da441fd0f3151a1467c2eb720d6 Mon Sep 17 00:00:00 2001 From: Lorenzo Bettini Date: Tue, 2 Jan 2024 14:41:28 +0100 Subject: [PATCH 06/10] simplified isVariableDeclarationRequired 2 --- .../src/org/eclipse/xtend/core/compiler/XtendCompiler.java | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/org.eclipse.xtend.core/src/org/eclipse/xtend/core/compiler/XtendCompiler.java b/org.eclipse.xtend.core/src/org/eclipse/xtend/core/compiler/XtendCompiler.java index a5ba3e997cb..bad82039c06 100644 --- a/org.eclipse.xtend.core/src/org/eclipse/xtend/core/compiler/XtendCompiler.java +++ b/org.eclipse.xtend.core/src/org/eclipse/xtend/core/compiler/XtendCompiler.java @@ -579,8 +579,7 @@ protected boolean internalCanCompileToJavaExpression(XExpression expression, ITr @Override protected boolean isVariableDeclarationRequired(XExpression expr, ITreeAppendable b, boolean recursive) { - boolean result = super.isVariableDeclarationRequired(expr, b, recursive); - if (result && expr instanceof XConstructorCall) { + if (expr instanceof XConstructorCall) { XConstructorCall constructorCall = (XConstructorCall) expr; if (constructorCall.isAnonymousClassConstructorCall()) { EObject container = expr.eContainer(); @@ -588,7 +587,7 @@ protected boolean isVariableDeclarationRequired(XExpression expr, ITreeAppendabl !canCompileToJavaAnonymousClass(constructorCall); } } - return result; + return super.isVariableDeclarationRequired(expr, b, recursive); } @Override From ec836331fe0a4ec9ef8d108be5e555bfea977421 Mon Sep 17 00:00:00 2001 From: Lorenzo Bettini Date: Tue, 2 Jan 2024 15:11:19 +0100 Subject: [PATCH 07/10] isVariableDeclarationRequired for constructor in Xbase --- .../xtend/core/compiler/XtendCompiler.java | 15 +-------------- .../xtext/xbase/compiler/XbaseCompiler.java | 7 +++++++ 2 files changed, 8 insertions(+), 14 deletions(-) diff --git a/org.eclipse.xtend.core/src/org/eclipse/xtend/core/compiler/XtendCompiler.java b/org.eclipse.xtend.core/src/org/eclipse/xtend/core/compiler/XtendCompiler.java index bad82039c06..f0e7d1fa63e 100644 --- a/org.eclipse.xtend.core/src/org/eclipse/xtend/core/compiler/XtendCompiler.java +++ b/org.eclipse.xtend.core/src/org/eclipse/xtend/core/compiler/XtendCompiler.java @@ -576,20 +576,7 @@ protected boolean internalCanCompileToJavaExpression(XExpression expression, ITr } else return super.internalCanCompileToJavaExpression(expression, appendable); } - - @Override - protected boolean isVariableDeclarationRequired(XExpression expr, ITreeAppendable b, boolean recursive) { - if (expr instanceof XConstructorCall) { - XConstructorCall constructorCall = (XConstructorCall) expr; - if (constructorCall.isAnonymousClassConstructorCall()) { - EObject container = expr.eContainer(); - return isVariableDeclarationRequired((XExpression) container, b, recursive) && - !canCompileToJavaAnonymousClass(constructorCall); - } - } - return super.isVariableDeclarationRequired(expr, b, recursive); - } - + @Override /* @Nullable */ protected String getReferenceName(XExpression expr, ITreeAppendable b) { 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 5402e8299a3..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 @@ -2177,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); } From 7e4a4ecf677cee547dcdd438550ef6f17bcee4be Mon Sep 17 00:00:00 2001 From: Lorenzo Bettini Date: Tue, 2 Jan 2024 17:25:14 +0100 Subject: [PATCH 08/10] removed duplication by constructorCallToJavaExpression instead of redefining _toJavaStatement we redefine constructorCallToJavaExpression and we call it also in other parts --- .../xtend/core/compiler/XtendCompiler.java | 46 +++++-------------- 1 file changed, 11 insertions(+), 35 deletions(-) diff --git a/org.eclipse.xtend.core/src/org/eclipse/xtend/core/compiler/XtendCompiler.java b/org.eclipse.xtend.core/src/org/eclipse/xtend/core/compiler/XtendCompiler.java index f0e7d1fa63e..bb95fe293e0 100644 --- a/org.eclipse.xtend.core/src/org/eclipse/xtend/core/compiler/XtendCompiler.java +++ b/org.eclipse.xtend.core/src/org/eclipse/xtend/core/compiler/XtendCompiler.java @@ -54,7 +54,6 @@ import org.eclipse.xtext.xbase.XbasePackage; import org.eclipse.xtext.xbase.compiler.GeneratorConfig; import org.eclipse.xtext.xbase.compiler.IGeneratorConfigProvider; -import org.eclipse.xtext.xbase.compiler.Later; import org.eclipse.xtext.xbase.compiler.XbaseCompiler; import org.eclipse.xtext.xbase.compiler.output.ITreeAppendable; import org.eclipse.xtext.xbase.lib.Extension; @@ -433,8 +432,16 @@ protected void _toJavaExpression(AnonymousClass anonymousClass, ITreeAppendable } else { XConstructorCall constructorCall = anonymousClass.getConstructorCall(); constructorCallToJavaExpression(constructorCall, b); - JvmDeclaredType declaringType = constructorCall.getConstructor().getDeclaringType(); - compileAnonymousClassBody(anonymousClass, declaringType, b); + } + } + + @Override + protected void constructorCallToJavaExpression(XConstructorCall expr, ITreeAppendable b) { + super.constructorCallToJavaExpression(expr, b); + if (expr.eContainer() instanceof AnonymousClass) { + JvmConstructor constructor = expr.getConstructor(); + JvmDeclaredType declaringType = constructor.getDeclaringType(); + compileAnonymousClassBody((AnonymousClass) expr.eContainer(), declaringType, b); } } @@ -535,38 +542,7 @@ public void _toJavaStatement(final XStringLiteral expr, ITreeAppendable b, boole protected void _toJavaStatement(final AnonymousClass anonymousClass, ITreeAppendable b, final boolean isReferenced) { _toJavaStatement(anonymousClass.getConstructorCall(), b, isReferenced); } - - @Override - protected void _toJavaStatement(final XConstructorCall expr, ITreeAppendable b, final boolean isReferenced) { - for (XExpression arg : expr.getArguments()) { - prepareExpression(arg, b); - } - - if (!isReferenced) { - b.newLine(); - constructorCallToJavaExpression(expr, b); - if (expr.eContainer() instanceof AnonymousClass) { - JvmConstructor constructor = expr.getConstructor(); - JvmDeclaredType declaringType = constructor.getDeclaringType(); - compileAnonymousClassBody((AnonymousClass) expr.eContainer(), declaringType, b); - } - b.append(";"); - } else if (isVariableDeclarationRequired(expr, b, true)) { - Later later = new Later() { - @Override - public void exec(ITreeAppendable appendable) { - constructorCallToJavaExpression(expr, appendable); - if (expr.eContainer() instanceof AnonymousClass) { - JvmConstructor constructor = expr.getConstructor(); - JvmDeclaredType declaringType = constructor.getDeclaringType(); - compileAnonymousClassBody((AnonymousClass) expr.eContainer(), declaringType, appendable); - } - } - }; - declareFreshLocalVariable(expr, b, later); - } - } - + @Override protected boolean internalCanCompileToJavaExpression(XExpression expression, ITreeAppendable appendable) { if(expression instanceof AnonymousClass) { From e56c9b68fa28d9fd3d664a8e951b5e250f8c9245 Mon Sep 17 00:00:00 2001 From: Lorenzo Bettini Date: Tue, 2 Jan 2024 19:20:38 +0100 Subject: [PATCH 09/10] reduced visibility of some methods when redefining them it's useless to make them public; when used internally, make them private --- .../xtend/core/compiler/XtendCompiler.java | 20 +++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/org.eclipse.xtend.core/src/org/eclipse/xtend/core/compiler/XtendCompiler.java b/org.eclipse.xtend.core/src/org/eclipse/xtend/core/compiler/XtendCompiler.java index bb95fe293e0..0eae3d402cd 100644 --- a/org.eclipse.xtend.core/src/org/eclipse/xtend/core/compiler/XtendCompiler.java +++ b/org.eclipse.xtend.core/src/org/eclipse/xtend/core/compiler/XtendCompiler.java @@ -357,7 +357,7 @@ protected XExpression normalizeBlockExpression(XExpression expr) { } @Override - public void doInternalToJavaStatement(XExpression obj, ITreeAppendable appendable, boolean isReferenced) { + protected void doInternalToJavaStatement(XExpression obj, ITreeAppendable appendable, boolean isReferenced) { prependLocalTypesIfFieldInitializer(obj, appendable, isReferenced); if(obj instanceof AnonymousClass) _toJavaStatement((AnonymousClass)obj, appendable, isReferenced); @@ -374,7 +374,7 @@ private void prependLocalTypesIfFieldInitializer(XExpression obj, ITreeAppendabl } } - public void _toJavaStatement(RichString richString, ITreeAppendable b, boolean isReferenced) { + private void _toJavaStatement(RichString richString, ITreeAppendable b, boolean isReferenced) { LightweightTypeReference actualType = getLightweightType(richString); b = b.trace(richString); if (actualType.isType(StringConcatenationClient.class)) { @@ -416,7 +416,7 @@ public void _toJavaStatement(RichString richString, ITreeAppendable b, boolean i } @Override - public void internalToConvertedExpression(XExpression obj, ITreeAppendable appendable) { + protected void internalToConvertedExpression(XExpression obj, ITreeAppendable appendable) { if (obj instanceof AnonymousClass) _toJavaExpression((AnonymousClass) obj, appendable); else if (obj instanceof RichString) @@ -425,7 +425,7 @@ else if (obj instanceof RichString) super.internalToConvertedExpression(obj, appendable); } - protected void _toJavaExpression(AnonymousClass anonymousClass, ITreeAppendable b) { + private void _toJavaExpression(AnonymousClass anonymousClass, ITreeAppendable b) { String varName = getReferenceName(anonymousClass, b); if (varName != null) { b.trace(anonymousClass, false).append(varName); @@ -445,7 +445,7 @@ protected void constructorCallToJavaExpression(XConstructorCall expr, ITreeAppen } } - protected void compileAnonymousClassBody(AnonymousClass anonymousClass, JvmDeclaredType type, ITreeAppendable b) { + private void compileAnonymousClassBody(AnonymousClass anonymousClass, JvmDeclaredType type, ITreeAppendable b) { ITreeAppendable appendable = b.trace(anonymousClass, true); appendable.append(" "); appendable.openScope(); @@ -455,7 +455,7 @@ protected void compileAnonymousClassBody(AnonymousClass anonymousClass, JvmDecla appendable.closeScope(); } - public void _toJavaExpression(RichString richString, ITreeAppendable b) { + private void _toJavaExpression(RichString richString, ITreeAppendable b) { b.append(getVarName(richString, b)); if(getLightweightType(richString).isType(String.class)) b.append(".toString()"); @@ -468,7 +468,7 @@ protected void appendCatchClauseParameter(XCatchClause catchClause, JvmTypeRefer super.appendCatchClauseParameter(catchClause, parameterType, parameterName, appendable); } - protected void appendExtensionAnnotation(JvmFormalParameter parameter, EObject context, + private void appendExtensionAnnotation(JvmFormalParameter parameter, EObject context, ITreeAppendable appendable, boolean newLine) { if (parameter instanceof XtendFormalParameter) { XtendFormalParameter castedParameter = (XtendFormalParameter) parameter; @@ -478,7 +478,7 @@ protected void appendExtensionAnnotation(JvmFormalParameter parameter, EObject c } } - protected void appendExtensionAnnotation(EObject context, ITreeAppendable appendable, boolean newLine) { + private void appendExtensionAnnotation(EObject context, ITreeAppendable appendable, boolean newLine) { JvmType extension = findKnownTopLevelType(Extension.class, context); if (extension != null) { appendable.append("@"); @@ -538,8 +538,8 @@ public void _toJavaExpression(XStringLiteral expr, ITreeAppendable b) { public void _toJavaStatement(final XStringLiteral expr, ITreeAppendable b, boolean isReferenced) { toJavaStatement(expr, b, isReferenced, false); } - - protected void _toJavaStatement(final AnonymousClass anonymousClass, ITreeAppendable b, final boolean isReferenced) { + + private void _toJavaStatement(final AnonymousClass anonymousClass, ITreeAppendable b, final boolean isReferenced) { _toJavaStatement(anonymousClass.getConstructorCall(), b, isReferenced); } From 7ac3f496fd906b5cdbeef5932ff0d17388d405b6 Mon Sep 17 00:00:00 2001 From: Lorenzo Bettini Date: Mon, 8 Jan 2024 19:02:42 +0100 Subject: [PATCH 10/10] private -> protected (restored visibility) --- .../eclipse/xtend/core/compiler/XtendCompiler.java | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/org.eclipse.xtend.core/src/org/eclipse/xtend/core/compiler/XtendCompiler.java b/org.eclipse.xtend.core/src/org/eclipse/xtend/core/compiler/XtendCompiler.java index 0eae3d402cd..a96f6e071bc 100644 --- a/org.eclipse.xtend.core/src/org/eclipse/xtend/core/compiler/XtendCompiler.java +++ b/org.eclipse.xtend.core/src/org/eclipse/xtend/core/compiler/XtendCompiler.java @@ -374,7 +374,7 @@ private void prependLocalTypesIfFieldInitializer(XExpression obj, ITreeAppendabl } } - private void _toJavaStatement(RichString richString, ITreeAppendable b, boolean isReferenced) { + protected void _toJavaStatement(RichString richString, ITreeAppendable b, boolean isReferenced) { LightweightTypeReference actualType = getLightweightType(richString); b = b.trace(richString); if (actualType.isType(StringConcatenationClient.class)) { @@ -425,7 +425,7 @@ else if (obj instanceof RichString) super.internalToConvertedExpression(obj, appendable); } - private void _toJavaExpression(AnonymousClass anonymousClass, ITreeAppendable b) { + protected void _toJavaExpression(AnonymousClass anonymousClass, ITreeAppendable b) { String varName = getReferenceName(anonymousClass, b); if (varName != null) { b.trace(anonymousClass, false).append(varName); @@ -445,7 +445,7 @@ protected void constructorCallToJavaExpression(XConstructorCall expr, ITreeAppen } } - private void compileAnonymousClassBody(AnonymousClass anonymousClass, JvmDeclaredType type, ITreeAppendable b) { + protected void compileAnonymousClassBody(AnonymousClass anonymousClass, JvmDeclaredType type, ITreeAppendable b) { ITreeAppendable appendable = b.trace(anonymousClass, true); appendable.append(" "); appendable.openScope(); @@ -455,7 +455,7 @@ private void compileAnonymousClassBody(AnonymousClass anonymousClass, JvmDeclare appendable.closeScope(); } - private void _toJavaExpression(RichString richString, ITreeAppendable b) { + protected void _toJavaExpression(RichString richString, ITreeAppendable b) { b.append(getVarName(richString, b)); if(getLightweightType(richString).isType(String.class)) b.append(".toString()"); @@ -468,7 +468,7 @@ protected void appendCatchClauseParameter(XCatchClause catchClause, JvmTypeRefer super.appendCatchClauseParameter(catchClause, parameterType, parameterName, appendable); } - private void appendExtensionAnnotation(JvmFormalParameter parameter, EObject context, + protected void appendExtensionAnnotation(JvmFormalParameter parameter, EObject context, ITreeAppendable appendable, boolean newLine) { if (parameter instanceof XtendFormalParameter) { XtendFormalParameter castedParameter = (XtendFormalParameter) parameter; @@ -478,7 +478,7 @@ private void appendExtensionAnnotation(JvmFormalParameter parameter, EObject con } } - private void appendExtensionAnnotation(EObject context, ITreeAppendable appendable, boolean newLine) { + protected void appendExtensionAnnotation(EObject context, ITreeAppendable appendable, boolean newLine) { JvmType extension = findKnownTopLevelType(Extension.class, context); if (extension != null) { appendable.append("@"); @@ -539,7 +539,7 @@ public void _toJavaStatement(final XStringLiteral expr, ITreeAppendable b, boole toJavaStatement(expr, b, isReferenced, false); } - private void _toJavaStatement(final AnonymousClass anonymousClass, ITreeAppendable b, final boolean isReferenced) { + protected void _toJavaStatement(final AnonymousClass anonymousClass, ITreeAppendable b, final boolean isReferenced) { _toJavaStatement(anonymousClass.getConstructorCall(), b, isReferenced); }