Search in sources :

Example 1 with MutableMemberDeclaration

use of org.eclipse.xtend.lib.macro.declaration.MutableMemberDeclaration in project xtext-xtend by eclipse.

the class DeclarationsTest method testRemove.

@Test
public void testRemove() {
    StringConcatenation _builder = new StringConcatenation();
    _builder.append("class C {");
    _builder.newLine();
    _builder.append("\t");
    _builder.append("def void m() {}");
    _builder.newLine();
    _builder.append("}");
    _builder.newLine();
    final Procedure1<CompilationUnitImpl> _function = (CompilationUnitImpl it) -> {
        TypeDeclaration _head = IterableExtensions.head(it.getSourceTypeDeclarations());
        final ClassDeclaration c = ((ClassDeclaration) _head);
        final MutableClassDeclaration mutable = it.getTypeLookup().findClass(c.getQualifiedName());
        final Consumer<MutableMemberDeclaration> _function_1 = (MutableMemberDeclaration it_1) -> {
            it_1.remove();
        };
        mutable.getDeclaredMembers().forEach(_function_1);
        Assert.assertTrue(IterableExtensions.isEmpty(mutable.getDeclaredMembers()));
    };
    this.asCompilationUnit(this.validFile(_builder), _function);
}
Also used : MutableMemberDeclaration(org.eclipse.xtend.lib.macro.declaration.MutableMemberDeclaration) ClassDeclaration(org.eclipse.xtend.lib.macro.declaration.ClassDeclaration) MutableClassDeclaration(org.eclipse.xtend.lib.macro.declaration.MutableClassDeclaration) Consumer(java.util.function.Consumer) CompilationUnitImpl(org.eclipse.xtend.core.macro.declaration.CompilationUnitImpl) StringConcatenation(org.eclipse.xtend2.lib.StringConcatenation) AnnotationTypeDeclaration(org.eclipse.xtend.lib.macro.declaration.AnnotationTypeDeclaration) TypeDeclaration(org.eclipse.xtend.lib.macro.declaration.TypeDeclaration) MutableClassDeclaration(org.eclipse.xtend.lib.macro.declaration.MutableClassDeclaration) Test(org.junit.Test)

Aggregations

Consumer (java.util.function.Consumer)1 CompilationUnitImpl (org.eclipse.xtend.core.macro.declaration.CompilationUnitImpl)1 AnnotationTypeDeclaration (org.eclipse.xtend.lib.macro.declaration.AnnotationTypeDeclaration)1 ClassDeclaration (org.eclipse.xtend.lib.macro.declaration.ClassDeclaration)1 MutableClassDeclaration (org.eclipse.xtend.lib.macro.declaration.MutableClassDeclaration)1 MutableMemberDeclaration (org.eclipse.xtend.lib.macro.declaration.MutableMemberDeclaration)1 TypeDeclaration (org.eclipse.xtend.lib.macro.declaration.TypeDeclaration)1 StringConcatenation (org.eclipse.xtend2.lib.StringConcatenation)1 Test (org.junit.Test)1