Search in sources :

Example 1 with ResolvedName

use of org.abs_models.frontend.typechecker.ResolvedName in project abstools by abstools.

the class AddImportsTest method addExport.

@Test
public void addExport() throws DeltaModellingException {
    Model model = assertParse("module Exporter;" + "interface I {}" + "module M;" + "class C {}" + "delta D1; uses Exporter;" + "adds export I;" + "delta D2; uses M;" + "adds import Exporter.I;" + "modifies class C { adds Exporter.I field1; } ");
    ClassDecl cls = (ClassDecl) findDecl(model, "M", "C");
    DeltaDecl d1 = findDelta(model, "D1");
    DeltaDecl d2 = findDelta(model, "D2");
    model.applyDeltas(new ArrayList<>(Arrays.asList(d1, d2)));
    ModuleDecl clsmodule = cls.getModuleDecl();
    Map<KindedName, ResolvedName> clsVisibleSymbols = clsmodule.getVisibleNames();
    KindedName symbol1 = new KindedName(KindedName.Kind.TYPE_DECL, "Exporter.I");
    assertTrue(clsVisibleSymbols.containsKey(symbol1));
}
Also used : ClassDecl(org.abs_models.frontend.ast.ClassDecl) Model(org.abs_models.frontend.ast.Model) ModuleDecl(org.abs_models.frontend.ast.ModuleDecl) ResolvedName(org.abs_models.frontend.typechecker.ResolvedName) KindedName(org.abs_models.frontend.typechecker.KindedName) DeltaDecl(org.abs_models.frontend.ast.DeltaDecl) Test(org.junit.Test)

Example 2 with ResolvedName

use of org.abs_models.frontend.typechecker.ResolvedName in project abstools by abstools.

the class AddImportsTest method addImport.

@Test
public void addImport() throws DeltaModellingException {
    Model model = assertParse("module Exporter; export *;" + "interface I {}" + "interface J {}" + "module Exporter2; export *;" + "interface K {}" + "module M;" + "class C {}" + "delta D; uses M;" + "adds import Exporter.I;" + "adds import J from Exporter;" + "adds import * from Exporter2;" + "modifies class C { adds Exporter.I field1; } " + "modifies class C { adds          J field2; } " + "modifies class C { adds          K field3; } ");
    ClassDecl cls = (ClassDecl) findDecl(model, "M", "C");
    DeltaDecl delta = findDelta(model, "D");
    model.applyDeltas(new ArrayList<>(Arrays.asList(delta)));
    ModuleDecl clsmodule = cls.getModuleDecl();
    Map<KindedName, ResolvedName> clsVisibleSymbols = clsmodule.getVisibleNames();
    KindedName symbol1 = new KindedName(KindedName.Kind.TYPE_DECL, "Exporter.I");
    KindedName symbol2 = new KindedName(KindedName.Kind.TYPE_DECL, "J");
    KindedName symbol3 = new KindedName(KindedName.Kind.TYPE_DECL, "K");
    assertTrue(clsVisibleSymbols.containsKey(symbol1));
    assertTrue(clsVisibleSymbols.containsKey(symbol2));
    assertTrue(clsVisibleSymbols.containsKey(symbol3));
}
Also used : ClassDecl(org.abs_models.frontend.ast.ClassDecl) Model(org.abs_models.frontend.ast.Model) ModuleDecl(org.abs_models.frontend.ast.ModuleDecl) ResolvedName(org.abs_models.frontend.typechecker.ResolvedName) KindedName(org.abs_models.frontend.typechecker.KindedName) DeltaDecl(org.abs_models.frontend.ast.DeltaDecl) Test(org.junit.Test)

Aggregations

ClassDecl (org.abs_models.frontend.ast.ClassDecl)2 DeltaDecl (org.abs_models.frontend.ast.DeltaDecl)2 Model (org.abs_models.frontend.ast.Model)2 ModuleDecl (org.abs_models.frontend.ast.ModuleDecl)2 KindedName (org.abs_models.frontend.typechecker.KindedName)2 ResolvedName (org.abs_models.frontend.typechecker.ResolvedName)2 Test (org.junit.Test)2