use of org.eclipse.xtend.lib.macro.declaration.MemberDeclaration in project xtext-xtend by eclipse.
the class JvmTypeDeclarationImpl method addField.
public MutableFieldDeclaration addField(final String name, final Procedure1<MutableFieldDeclaration> initializer) {
this.checkMutable();
ConditionUtils.checkJavaIdentifier(name, "name");
Preconditions.checkArgument((initializer != null), "initializer cannot be null");
final JvmField newField = TypesFactory.eINSTANCE.createJvmField();
newField.setSimpleName(name);
newField.setVisibility(JvmVisibility.PRIVATE);
this.getDelegate().getMembers().add(newField);
MemberDeclaration _memberDeclaration = this.getCompilationUnit().toMemberDeclaration(newField);
final MutableFieldDeclaration mutableFieldDeclaration = ((MutableFieldDeclaration) _memberDeclaration);
initializer.apply(mutableFieldDeclaration);
return mutableFieldDeclaration;
}
use of org.eclipse.xtend.lib.macro.declaration.MemberDeclaration in project xtext-xtend by eclipse.
the class JvmTypeDeclarationImpl method addConstructor.
public MutableConstructorDeclaration addConstructor(final Procedure1<MutableConstructorDeclaration> initializer) {
this.checkMutable();
Preconditions.checkArgument((initializer != null), "initializer cannot be null");
final Function1<JvmConstructor, Boolean> _function = (JvmConstructor it) -> {
return Boolean.valueOf(this.getCompilationUnit().getTypeExtensions().isSingleSyntheticDefaultConstructor(it));
};
final JvmConstructor constructor = IterableExtensions.<JvmConstructor>findFirst(Iterables.<JvmConstructor>filter(this.getDelegate().getMembers(), JvmConstructor.class), _function);
if ((constructor != null)) {
MemberDeclaration _memberDeclaration = this.getCompilationUnit().toMemberDeclaration(constructor);
final MutableConstructorDeclaration mutableConstructorDeclaration = ((MutableConstructorDeclaration) _memberDeclaration);
mutableConstructorDeclaration.remove();
}
final JvmConstructor newConstructor = TypesFactory.eINSTANCE.createJvmConstructor();
newConstructor.setVisibility(JvmVisibility.PUBLIC);
newConstructor.setSimpleName(this.getSimpleName());
this.getDelegate().getMembers().add(newConstructor);
MemberDeclaration _memberDeclaration_1 = this.getCompilationUnit().toMemberDeclaration(newConstructor);
final MutableConstructorDeclaration mutableConstructorDeclaration_1 = ((MutableConstructorDeclaration) _memberDeclaration_1);
initializer.apply(mutableConstructorDeclaration_1);
return mutableConstructorDeclaration_1;
}
use of org.eclipse.xtend.lib.macro.declaration.MemberDeclaration in project xtext-xtend by eclipse.
the class JvmTypeDeclarationImpl method addMethod.
public MutableMethodDeclaration addMethod(final String name, final Procedure1<MutableMethodDeclaration> initializer) {
this.checkMutable();
ConditionUtils.checkJavaIdentifier(name, "name");
Preconditions.checkArgument((initializer != null), "initializer cannot be null");
final JvmOperation newMethod = TypesFactory.eINSTANCE.createJvmOperation();
newMethod.setVisibility(JvmVisibility.PUBLIC);
newMethod.setSimpleName(name);
newMethod.setReturnType(this.getCompilationUnit().toJvmTypeReference(this.getCompilationUnit().getTypeReferenceProvider().getPrimitiveVoid()));
this.getDelegate().getMembers().add(newMethod);
MemberDeclaration _memberDeclaration = this.getCompilationUnit().toMemberDeclaration(newMethod);
final MutableMethodDeclaration mutableMethodDeclaration = ((MutableMethodDeclaration) _memberDeclaration);
initializer.apply(mutableMethodDeclaration);
return mutableMethodDeclaration;
}
use of org.eclipse.xtend.lib.macro.declaration.MemberDeclaration in project xtext-xtend by eclipse.
the class MutableJvmEnumerationTypeDeclarationImpl method addValue.
@Override
public MutableEnumerationValueDeclaration addValue(final String name, final Procedure1<MutableEnumerationValueDeclaration> initializer) {
this.checkMutable();
ConditionUtils.checkJavaIdentifier(name, "name");
Preconditions.checkArgument((initializer != null), "initializer cannot be null");
final JvmEnumerationLiteral jvmLiteral = TypesFactory.eINSTANCE.createJvmEnumerationLiteral();
jvmLiteral.setSimpleName(name);
jvmLiteral.setVisibility(JvmVisibility.PUBLIC);
this.getDelegate().getMembers().add(jvmLiteral);
MemberDeclaration _memberDeclaration = this.getCompilationUnit().toMemberDeclaration(jvmLiteral);
final MutableEnumerationValueDeclaration mutableEnumerationValueDeclaration = ((MutableEnumerationValueDeclaration) _memberDeclaration);
initializer.apply(mutableEnumerationValueDeclaration);
return mutableEnumerationValueDeclaration;
}
use of org.eclipse.xtend.lib.macro.declaration.MemberDeclaration in project xtext-xtend by eclipse.
the class TypeParameterDeclarationImpl method getTypeParameterDeclarator.
@Override
public TypeParameterDeclarator getTypeParameterDeclarator() {
EObject _eContainer = this.getDelegate().eContainer();
MemberDeclaration _memberDeclaration = this.getCompilationUnit().toMemberDeclaration(((JvmMember) _eContainer));
return ((TypeParameterDeclarator) _memberDeclaration);
}
Aggregations