use of org.eclipse.xtend.lib.macro.declaration.MemberDeclaration in project xtext-xtend by eclipse.
the class XtendMethodDeclarationImpl method getOverriddenOrImplementedMethods.
@Override
public Iterable<? extends MethodDeclaration> getOverriddenOrImplementedMethods() {
boolean _isOverride = this.getDelegate().isOverride();
if (_isOverride) {
final JvmOperation jvmOperation = this.getCompilationUnit().getJvmModelAssociations().getDirectlyInferredOperation(this.getDelegate());
final ResolvedFeatures resolvedFeatures = this.getCompilationUnit().getOverrideHelper().getResolvedFeatures(jvmOperation.getDeclaringType());
final IResolvedOperation resolvedOperation = resolvedFeatures.getResolvedOperation(jvmOperation);
final List<IResolvedOperation> overriddenOrImplemented = resolvedOperation.getOverriddenAndImplementedMethods();
final Function1<IResolvedOperation, MemberDeclaration> _function = (IResolvedOperation it) -> {
return this.getCompilationUnit().toMemberDeclaration(it.getDeclaration());
};
return Iterables.<MethodDeclaration>filter(ListExtensions.<IResolvedOperation, MemberDeclaration>map(overriddenOrImplemented, _function), MethodDeclaration.class);
}
return CollectionLiterals.<MethodDeclaration>emptyList();
}
use of org.eclipse.xtend.lib.macro.declaration.MemberDeclaration in project xtext-xtend by eclipse.
the class XtendParameterDeclarationImpl method getDeclaringExecutable.
@Override
public ExecutableDeclaration getDeclaringExecutable() {
EObject _eContainer = this.getDelegate().eContainer();
MemberDeclaration _xtendMemberDeclaration = this.getCompilationUnit().toXtendMemberDeclaration(((XtendMember) _eContainer));
return ((ExecutableDeclaration) _xtendMemberDeclaration);
}
use of org.eclipse.xtend.lib.macro.declaration.MemberDeclaration in project xtext-xtend by eclipse.
the class DeclarationsTest method testSimpleClassWithField.
@Test
public void testSimpleClassWithField() {
StringConcatenation _builder = new StringConcatenation();
_builder.append("package foo");
_builder.newLine();
_builder.newLine();
_builder.append("class MyClass extends Object implements java.io.Serializable {");
_builder.newLine();
_builder.append("\t");
_builder.append("MyClass foo");
_builder.newLine();
_builder.append("}");
_builder.newLine();
final Procedure1<CompilationUnitImpl> _function = (CompilationUnitImpl it) -> {
Assert.assertEquals("foo", it.getPackageName());
TypeDeclaration _head = IterableExtensions.head(it.getSourceTypeDeclarations());
final ClassDeclaration clazz = ((ClassDeclaration) _head);
Assert.assertEquals("foo.MyClass", clazz.getQualifiedName());
Assert.assertEquals("Object", clazz.getExtendedClass().toString());
Assert.assertEquals("Serializable", IterableExtensions.head(clazz.getImplementedInterfaces()).toString());
MemberDeclaration _head_1 = IterableExtensions.head(clazz.getDeclaredMembers());
final FieldDeclaration field = ((FieldDeclaration) _head_1);
Assert.assertEquals("foo", field.getSimpleName());
Assert.assertSame(it.getTypeLookup().findClass("foo.MyClass"), field.getType().getType());
};
this.asCompilationUnit(this.validFile(_builder), _function);
}
use of org.eclipse.xtend.lib.macro.declaration.MemberDeclaration in project xtext-xtend by eclipse.
the class DeclarationsTest method testAnnotation.
@Test
public void testAnnotation() {
StringConcatenation _builder = new StringConcatenation();
_builder.append("@SuppressWarnings(\"unused\")");
_builder.newLine();
_builder.append("class MyClass {");
_builder.newLine();
_builder.append("\t");
_builder.append("@com.google.inject.Inject(optional=true) MyClass foo");
_builder.newLine();
_builder.append("}");
_builder.newLine();
final Procedure1<CompilationUnitImpl> _function = (CompilationUnitImpl it) -> {
Assert.assertNull(it.getPackageName());
TypeDeclaration _head = IterableExtensions.head(it.getSourceTypeDeclarations());
final ClassDeclaration clazz = ((ClassDeclaration) _head);
Assert.assertEquals("MyClass", clazz.getQualifiedName());
final AnnotationReference suppressWarning = IterableExtensions.head(clazz.getAnnotations());
final AnnotationTypeDeclaration supressWarningsDeclaration = suppressWarning.getAnnotationTypeDeclaration();
Assert.assertEquals("java.lang.SuppressWarnings", supressWarningsDeclaration.getQualifiedName());
Assert.assertEquals("unused", suppressWarning.getStringArrayValue("value")[0]);
Assert.assertEquals(2, IterableExtensions.size(supressWarningsDeclaration.getAnnotations()));
final AnnotationTypeElementDeclaration valueProperty = IterableExtensions.<AnnotationTypeElementDeclaration>head(Iterables.<AnnotationTypeElementDeclaration>filter(supressWarningsDeclaration.getDeclaredMembers(), AnnotationTypeElementDeclaration.class));
Assert.assertEquals("String[]", valueProperty.getType().toString());
Assert.assertEquals("value", valueProperty.getSimpleName());
MemberDeclaration _head_1 = IterableExtensions.head(clazz.getDeclaredMembers());
final FieldDeclaration field = ((FieldDeclaration) _head_1);
final AnnotationReference inject = IterableExtensions.head(field.getAnnotations());
Object _value = inject.getValue("optional");
Assert.assertTrue((((Boolean) _value)).booleanValue());
};
this.asCompilationUnit(this.validFile(_builder), _function);
}
use of org.eclipse.xtend.lib.macro.declaration.MemberDeclaration in project xtext-xtend by eclipse.
the class JvmMethodDeclarationImpl method getOverriddenOrImplementedMethods.
@Override
public Iterable<? extends MethodDeclaration> getOverriddenOrImplementedMethods() {
final ResolvedFeatures resolvedFeatures = this.getCompilationUnit().getOverrideHelper().getResolvedFeatures(this.getDelegate().getDeclaringType());
final IResolvedOperation resolvedOperation = resolvedFeatures.getResolvedOperation(this.getDelegate());
final List<IResolvedOperation> overriddenOrImplemented = resolvedOperation.getOverriddenAndImplementedMethods();
final Function1<IResolvedOperation, MemberDeclaration> _function = (IResolvedOperation it) -> {
return this.getCompilationUnit().toMemberDeclaration(it.getDeclaration());
};
return Iterables.<MethodDeclaration>filter(ListExtensions.<IResolvedOperation, MemberDeclaration>map(overriddenOrImplemented, _function), MethodDeclaration.class);
}
Aggregations