use of org.eclipse.xtend.lib.macro.declaration.MutableAnnotationTypeElementDeclaration in project xtext-xtend by eclipse.
the class MutableJvmAnnotationTypeDeclarationImpl method addAnnotationTypeElement.
@Override
public MutableAnnotationTypeElementDeclaration addAnnotationTypeElement(final String name, final Procedure1<MutableAnnotationTypeElementDeclaration> initializer) {
this.checkMutable();
ConditionUtils.checkJavaIdentifier(name, "name");
Preconditions.checkArgument((initializer != null), "initializer cannot be null");
final JvmOperation newAnnotationElement = TypesFactory.eINSTANCE.createJvmOperation();
newAnnotationElement.setSimpleName(name);
newAnnotationElement.setVisibility(JvmVisibility.PUBLIC);
this.getDelegate().getMembers().add(newAnnotationElement);
MemberDeclaration _memberDeclaration = this.getCompilationUnit().toMemberDeclaration(newAnnotationElement);
final MutableAnnotationTypeElementDeclaration mutableAnnotationTypeElementDeclaration = ((MutableAnnotationTypeElementDeclaration) _memberDeclaration);
initializer.apply(mutableAnnotationTypeElementDeclaration);
return mutableAnnotationTypeElementDeclaration;
}
use of org.eclipse.xtend.lib.macro.declaration.MutableAnnotationTypeElementDeclaration in project xtext-xtend by eclipse.
the class ToAnnoProcessor method doTransform.
@Override
public void doTransform(final MutableClassDeclaration annotatedClass, @Extension final TransformationContext context) {
super.doTransform(annotatedClass, context);
Type _findTypeGlobally = context.findTypeGlobally(this.generatedAnnotationName(annotatedClass));
final MutableAnnotationTypeDeclaration annotationType = ((MutableAnnotationTypeDeclaration) _findTypeGlobally);
final Procedure1<MutableAnnotationTypeElementDeclaration> _function = (MutableAnnotationTypeElementDeclaration it) -> {
it.setDocComment("Best building strategy game ever");
it.setType(context.newTypeReference(Integer.TYPE));
boolean _booleanValue = annotatedClass.findAnnotation(context.findTypeGlobally(ToAnno.class)).getBooleanValue("defaultValue");
if (_booleanValue) {
StringConcatenationClient _client = new StringConcatenationClient() {
@Override
protected void appendTo(StringConcatenationClient.TargetStringConcatenation _builder) {
_builder.append("1602");
}
};
it.setDefaultValueExpression(_client);
}
};
annotationType.addAnnotationTypeElement("anno", _function);
}
Aggregations