-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
And customize code generation
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -46,6 +46,8 @@ import org.eclipse.xtext.xbase.compiler.output.ITreeAppendable | |
import org.eclipse.xtext.xbase.compiler.output.SharedAppendableState | ||
import org.eclipse.xtext.xbase.typesystem.IBatchTypeResolver | ||
import org.eclipse.xtext.xbase.typesystem.references.ITypeReferenceOwner | ||
import org.eclipse.xtend.core.xtend.XtendField | ||
import org.eclipse.xtext.common.types.impl.JvmGenericTypeImplCustom | ||
|
||
/** | ||
* @author Sven Efftinge - Initial contribution and API | ||
|
@@ -164,9 +166,13 @@ class XtendGenerator extends JvmModelGenerator implements IGenerator2 { | |
} | ||
|
||
def compileLocalTypeStubs(JvmFeature feature, ITreeAppendable appendable, GeneratorConfig config) { | ||
feature.localClasses.filter[ !anonymous ].forEach[ | ||
appendable.newLine | ||
feature.localClasses.forEach[ | ||
val anonymousClass = sourceElements.head as AnonymousClass | ||
if (anonymousClass.canBeCompiledAsJavaAnonymousClass) { | ||
return | ||
} | ||
(it as JvmGenericTypeImplCustom).basicSetAnonymous(false) | ||
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
LorenzoBettini
Author
Owner
|
||
appendable.newLine | ||
val childAppendable = appendable.trace(anonymousClass) | ||
childAppendable.append('abstract class ') | ||
childAppendable.traceSignificant(anonymousClass).append(simpleName) | ||
|
@@ -386,5 +392,13 @@ class XtendGenerator extends JvmModelGenerator implements IGenerator2 { | |
} | ||
|
||
} | ||
|
||
|
||
def private boolean canBeCompiledAsJavaAnonymousClass(AnonymousClass anonymousClass) { | ||
for(XtendMember member: anonymousClass.getMembers()) { | ||
if(member instanceof XtendField || | ||
(member instanceof XtendFunction && !(member as XtendFunction).isOverride())) | ||
return false; | ||
} | ||
return true; | ||
} | ||
} |
This is not an option. The model is not supposed to be modified by the compiler. Otherwise validation results are no longer trustworthy since introduces a semantic dependency back from the code generator into the model.