Search in sources :

Example 1 with RemoveMethodModifier

use of abs.frontend.ast.RemoveMethodModifier in project abstools by abstools.

the class TraitTest method addRemoveModifierAtRuntime.

@Test
public void addRemoveModifierAtRuntime() {
    Model model = assertParseOk("module M;" + "class C { Unit m(){skip;} }");
    ClassDecl cls = (ClassDecl) findDecl(model, "M", "C");
    MethodSig sig = AbsASTBuilderUtil.createMethodSig("m", AbsASTBuilderUtil.getUnit());
    List<MethodSig> l = new List<>(sig);
    RemoveMethodModifier opr = new RemoveMethodModifier(l);
    ModifyClassModifier mcn = new ModifyClassModifier();
    mcn.setName("M.C");
    DeltaAccess acc = new DeltaAccess(cls.getModuleDecl().getName());
    DeltaDecl dd = new DeltaDecl();
    dd.setName("MyDelta");
    dd.addDeltaAccess(acc);
    dd.addModuleModifier(mcn);
    mcn.addModifier(opr);
    mcn.setParent(dd);
    acc.setParent(dd);
    opr.setParent(mcn);
    sig.setParent(opr);
    CompilationUnit cu = model.getCompilationUnitList().getChild(0);
    cu.addDeltaDecl(dd);
    dd.setParent(cu);
    model.applyDelta(dd);
    assertEquals(0, cls.getMethods().getNumChild());
}
Also used : CompilationUnit(abs.frontend.ast.CompilationUnit) MethodSig(abs.frontend.ast.MethodSig) RemoveMethodModifier(abs.frontend.ast.RemoveMethodModifier) ClassDecl(abs.frontend.ast.ClassDecl) DeltaAccess(abs.frontend.ast.DeltaAccess) Model(abs.frontend.ast.Model) List(abs.frontend.ast.List) DeltaDecl(abs.frontend.ast.DeltaDecl) ModifyClassModifier(abs.frontend.ast.ModifyClassModifier) Test(org.junit.Test)

Aggregations

ClassDecl (abs.frontend.ast.ClassDecl)1 CompilationUnit (abs.frontend.ast.CompilationUnit)1 DeltaAccess (abs.frontend.ast.DeltaAccess)1 DeltaDecl (abs.frontend.ast.DeltaDecl)1 List (abs.frontend.ast.List)1 MethodSig (abs.frontend.ast.MethodSig)1 Model (abs.frontend.ast.Model)1 ModifyClassModifier (abs.frontend.ast.ModifyClassModifier)1 RemoveMethodModifier (abs.frontend.ast.RemoveMethodModifier)1 Test (org.junit.Test)1