Search in sources :

Example 1 with Import

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

the class AbsASTBuilderUtil method generateImportAST.

public static final Set<Import> generateImportAST(TypeUse t) {
    Set<Import> imports = new HashSet<>();
    imports.add(generateImportAST(t.getName(), t.getModuleDecl().getName()));
    if (t instanceof ParametricDataTypeUse) {
        for (TypeUse st : ((ParametricDataTypeUse) t).getParams()) {
            imports.addAll(generateImportAST(st));
        }
    }
    return imports;
}
Also used : TypeUse(abs.frontend.ast.TypeUse) ParametricDataTypeUse(abs.frontend.ast.ParametricDataTypeUse) DataTypeUse(abs.frontend.ast.DataTypeUse) InterfaceTypeUse(abs.frontend.ast.InterfaceTypeUse) FromImport(abs.frontend.ast.FromImport) Import(abs.frontend.ast.Import) HashSet(java.util.HashSet) ParametricDataTypeUse(abs.frontend.ast.ParametricDataTypeUse)

Example 2 with Import

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

the class ASTBasedABSTestRunnerGenerator method generateImportsAST.

private List<Import> generateImportsAST() {
    List<Import> imports = new List<>();
    Set<String> mn = new HashSet<>();
    Set<String> qn = new HashSet<>();
    for (InterfaceDecl key : tests.keySet()) {
        getImportsFrom(mn, qn, key.getModuleDecl());
        for (ClassDecl clazz : tests.get(key)) {
            getImportsFrom(mn, qn, clazz.getModuleDecl());
        }
    }
    for (String m : mn) {
        imports.add(new StarImport(m));
    }
    if (!qn.isEmpty()) {
        List<Name> names = new List<>();
        for (String q : qn) {
            names.add(new Name(q));
        }
        imports.add(new NamedImport(names));
    }
    return imports;
}
Also used : NamedImport(abs.frontend.ast.NamedImport) StarImport(abs.frontend.ast.StarImport) FromImport(abs.frontend.ast.FromImport) Import(abs.frontend.ast.Import) ClassDecl(abs.frontend.ast.ClassDecl) StarImport(abs.frontend.ast.StarImport) List(abs.frontend.ast.List) InterfaceDecl(abs.frontend.ast.InterfaceDecl) HashSet(java.util.HashSet) Name(abs.frontend.ast.Name) NamedImport(abs.frontend.ast.NamedImport)

Aggregations

FromImport (abs.frontend.ast.FromImport)2 Import (abs.frontend.ast.Import)2 HashSet (java.util.HashSet)2 ClassDecl (abs.frontend.ast.ClassDecl)1 DataTypeUse (abs.frontend.ast.DataTypeUse)1 InterfaceDecl (abs.frontend.ast.InterfaceDecl)1 InterfaceTypeUse (abs.frontend.ast.InterfaceTypeUse)1 List (abs.frontend.ast.List)1 Name (abs.frontend.ast.Name)1 NamedImport (abs.frontend.ast.NamedImport)1 ParametricDataTypeUse (abs.frontend.ast.ParametricDataTypeUse)1 StarImport (abs.frontend.ast.StarImport)1 TypeUse (abs.frontend.ast.TypeUse)1