use of org.eclipse.xtend.lib.macro.declaration.MemberDeclaration in project xtext-xtend by eclipse.
the class CompilationUnitImpl method toMemberDeclaration.
public MemberDeclaration toMemberDeclaration(final JvmMember delegate) {
final Function1<JvmMember, MemberDeclaration> _function = (JvmMember it) -> {
MemberDeclaration _switchResult = null;
boolean _matched = false;
if (delegate instanceof JvmDeclaredType) {
_matched = true;
_switchResult = this.toTypeDeclaration(((JvmDeclaredType) delegate));
}
if (!_matched) {
if (delegate instanceof JvmOperation) {
_matched = true;
MemberDeclaration _xifexpression = null;
JvmDeclaredType _declaringType = ((JvmOperation) delegate).getDeclaringType();
if ((_declaringType instanceof JvmAnnotationType)) {
JvmAnnotationTypeElementDeclarationImpl _xifexpression_1 = null;
boolean _isBelongedToCompilationUnit = this.isBelongedToCompilationUnit(delegate);
if (_isBelongedToCompilationUnit) {
MutableJvmAnnotationTypeElementDeclarationImpl _mutableJvmAnnotationTypeElementDeclarationImpl = new MutableJvmAnnotationTypeElementDeclarationImpl();
final Procedure1<MutableJvmAnnotationTypeElementDeclarationImpl> _function_1 = (MutableJvmAnnotationTypeElementDeclarationImpl it_1) -> {
it_1.setDelegate(((JvmOperation) delegate));
it_1.setCompilationUnit(this);
};
_xifexpression_1 = ObjectExtensions.<MutableJvmAnnotationTypeElementDeclarationImpl>operator_doubleArrow(_mutableJvmAnnotationTypeElementDeclarationImpl, _function_1);
} else {
JvmAnnotationTypeElementDeclarationImpl _jvmAnnotationTypeElementDeclarationImpl = new JvmAnnotationTypeElementDeclarationImpl();
final Procedure1<JvmAnnotationTypeElementDeclarationImpl> _function_2 = (JvmAnnotationTypeElementDeclarationImpl it_1) -> {
it_1.setDelegate(((JvmOperation) delegate));
it_1.setCompilationUnit(this);
};
_xifexpression_1 = ObjectExtensions.<JvmAnnotationTypeElementDeclarationImpl>operator_doubleArrow(_jvmAnnotationTypeElementDeclarationImpl, _function_2);
}
_xifexpression = _xifexpression_1;
} else {
JvmMethodDeclarationImpl _xifexpression_2 = null;
boolean _isBelongedToCompilationUnit_1 = this.isBelongedToCompilationUnit(delegate);
if (_isBelongedToCompilationUnit_1) {
MutableJvmMethodDeclarationImpl _mutableJvmMethodDeclarationImpl = new MutableJvmMethodDeclarationImpl();
final Procedure1<MutableJvmMethodDeclarationImpl> _function_3 = (MutableJvmMethodDeclarationImpl it_1) -> {
it_1.setDelegate(((JvmOperation) delegate));
it_1.setCompilationUnit(this);
};
_xifexpression_2 = ObjectExtensions.<MutableJvmMethodDeclarationImpl>operator_doubleArrow(_mutableJvmMethodDeclarationImpl, _function_3);
} else {
JvmMethodDeclarationImpl _jvmMethodDeclarationImpl = new JvmMethodDeclarationImpl();
final Procedure1<JvmMethodDeclarationImpl> _function_4 = (JvmMethodDeclarationImpl it_1) -> {
it_1.setDelegate(((JvmOperation) delegate));
it_1.setCompilationUnit(this);
};
_xifexpression_2 = ObjectExtensions.<JvmMethodDeclarationImpl>operator_doubleArrow(_jvmMethodDeclarationImpl, _function_4);
}
_xifexpression = ((MemberDeclaration) _xifexpression_2);
}
_switchResult = _xifexpression;
}
}
if (!_matched) {
if (delegate instanceof JvmConstructor) {
_matched = true;
JvmConstructorDeclarationImpl _xifexpression = null;
boolean _isBelongedToCompilationUnit = this.isBelongedToCompilationUnit(delegate);
if (_isBelongedToCompilationUnit) {
MutableJvmConstructorDeclarationImpl _mutableJvmConstructorDeclarationImpl = new MutableJvmConstructorDeclarationImpl();
final Procedure1<MutableJvmConstructorDeclarationImpl> _function_1 = (MutableJvmConstructorDeclarationImpl it_1) -> {
it_1.setDelegate(((JvmConstructor) delegate));
it_1.setCompilationUnit(this);
};
_xifexpression = ObjectExtensions.<MutableJvmConstructorDeclarationImpl>operator_doubleArrow(_mutableJvmConstructorDeclarationImpl, _function_1);
} else {
JvmConstructorDeclarationImpl _jvmConstructorDeclarationImpl = new JvmConstructorDeclarationImpl();
final Procedure1<JvmConstructorDeclarationImpl> _function_2 = (JvmConstructorDeclarationImpl it_1) -> {
it_1.setDelegate(((JvmConstructor) delegate));
it_1.setCompilationUnit(this);
};
_xifexpression = ObjectExtensions.<JvmConstructorDeclarationImpl>operator_doubleArrow(_jvmConstructorDeclarationImpl, _function_2);
}
_switchResult = _xifexpression;
}
}
if (!_matched) {
if (delegate instanceof JvmEnumerationLiteral) {
_matched = true;
JvmEnumerationValueDeclarationImpl _xifexpression = null;
boolean _isBelongedToCompilationUnit = this.isBelongedToCompilationUnit(delegate);
if (_isBelongedToCompilationUnit) {
MutableJvmEnumerationValueDeclarationImpl _mutableJvmEnumerationValueDeclarationImpl = new MutableJvmEnumerationValueDeclarationImpl();
final Procedure1<MutableJvmEnumerationValueDeclarationImpl> _function_1 = (MutableJvmEnumerationValueDeclarationImpl it_1) -> {
it_1.setDelegate(((JvmEnumerationLiteral) delegate));
it_1.setCompilationUnit(this);
};
_xifexpression = ObjectExtensions.<MutableJvmEnumerationValueDeclarationImpl>operator_doubleArrow(_mutableJvmEnumerationValueDeclarationImpl, _function_1);
} else {
JvmEnumerationValueDeclarationImpl _jvmEnumerationValueDeclarationImpl = new JvmEnumerationValueDeclarationImpl();
final Procedure1<JvmEnumerationValueDeclarationImpl> _function_2 = (JvmEnumerationValueDeclarationImpl it_1) -> {
it_1.setDelegate(((JvmEnumerationLiteral) delegate));
it_1.setCompilationUnit(this);
};
_xifexpression = ObjectExtensions.<JvmEnumerationValueDeclarationImpl>operator_doubleArrow(_jvmEnumerationValueDeclarationImpl, _function_2);
}
_switchResult = _xifexpression;
}
}
if (!_matched) {
if (delegate instanceof JvmField) {
_matched = true;
JvmFieldDeclarationImpl _xifexpression = null;
boolean _isBelongedToCompilationUnit = this.isBelongedToCompilationUnit(delegate);
if (_isBelongedToCompilationUnit) {
MutableJvmFieldDeclarationImpl _mutableJvmFieldDeclarationImpl = new MutableJvmFieldDeclarationImpl();
final Procedure1<MutableJvmFieldDeclarationImpl> _function_1 = (MutableJvmFieldDeclarationImpl it_1) -> {
it_1.setDelegate(((JvmField) delegate));
it_1.setCompilationUnit(this);
};
_xifexpression = ObjectExtensions.<MutableJvmFieldDeclarationImpl>operator_doubleArrow(_mutableJvmFieldDeclarationImpl, _function_1);
} else {
JvmFieldDeclarationImpl _jvmFieldDeclarationImpl = new JvmFieldDeclarationImpl();
final Procedure1<JvmFieldDeclarationImpl> _function_2 = (JvmFieldDeclarationImpl it_1) -> {
it_1.setDelegate(((JvmField) delegate));
it_1.setCompilationUnit(this);
};
_xifexpression = ObjectExtensions.<JvmFieldDeclarationImpl>operator_doubleArrow(_jvmFieldDeclarationImpl, _function_2);
}
_switchResult = _xifexpression;
}
}
return _switchResult;
};
return this.<JvmMember, MemberDeclaration>getOrCreate(delegate, _function);
}
use of org.eclipse.xtend.lib.macro.declaration.MemberDeclaration in project xtext-xtend by eclipse.
the class JvmParameterDeclarationImpl method getDeclaringExecutable.
@Override
public ExecutableDeclaration getDeclaringExecutable() {
EObject _eContainer = this.getDelegate().eContainer();
MemberDeclaration _memberDeclaration = this.getCompilationUnit().toMemberDeclaration(((JvmMember) _eContainer));
return ((ExecutableDeclaration) _memberDeclaration);
}
use of org.eclipse.xtend.lib.macro.declaration.MemberDeclaration 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.MemberDeclaration in project xtext-xtend by eclipse.
the class JvmInterfaceDeclarationImpl method addMethod.
@Override
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()));
newMethod.setAbstract(true);
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 JvmTypeParameterDeclarationImpl method getTypeParameterDeclarator.
@Override
public TypeParameterDeclarator getTypeParameterDeclarator() {
EObject _eContainer = this.getDelegate().eContainer();
MemberDeclaration _memberDeclaration = this.getCompilationUnit().toMemberDeclaration(((JvmMember) _eContainer));
return ((TypeParameterDeclarator) _memberDeclaration);
}
Aggregations