Search in sources :

Example 1 with ImportList

use of org.eclipse.ceylon.model.typechecker.model.ImportList in project ceylon by eclipse.

the class ImportVisitor method visit.

@Override
public void visit(Tree.Import that) {
    Backends scopedBackends = that.getScope().getScopedBackends();
    if (!scopedBackends.none() && !scopedBackends.supports(unit.getSupportedBackends())) {
        return;
    }
    Tree.ImportPath path = that.getImportPath();
    Package importedPackage = importedPackage(path, unit);
    if (importedPackage != null) {
        path.setModel(importedPackage);
        Tree.ImportMemberOrTypeList imtl = that.getImportMemberOrTypeList();
        if (imtl != null) {
            ImportList il = imtl.getImportList();
            il.setImportedScope(importedPackage);
            Set<String> names = new HashSet<String>();
            List<Tree.ImportMemberOrType> list = imtl.getImportMemberOrTypes();
            for (Tree.ImportMemberOrType member : list) {
                names.add(importMember(member, importedPackage, il));
            }
            if (imtl.getImportWildcard() != null) {
                importAllMembers(importedPackage, names, il);
            } else if (list.isEmpty()) {
                imtl.addError("empty import list", 1020);
            }
        }
    }
}
Also used : Backends(org.eclipse.ceylon.common.Backends) ImportList(org.eclipse.ceylon.model.typechecker.model.ImportList) Tree(org.eclipse.ceylon.compiler.typechecker.tree.Tree) AnalyzerUtil.declaredInPackage(org.eclipse.ceylon.compiler.typechecker.analyzer.AnalyzerUtil.declaredInPackage) Package(org.eclipse.ceylon.model.typechecker.model.Package) AnalyzerUtil.importedPackage(org.eclipse.ceylon.compiler.typechecker.analyzer.AnalyzerUtil.importedPackage) HashSet(java.util.HashSet)

Example 2 with ImportList

use of org.eclipse.ceylon.model.typechecker.model.ImportList in project ceylon by eclipse.

the class ImportVisitor method importMembers.

private void importMembers(Tree.ImportMemberOrType member, Declaration d) {
    Tree.ImportMemberOrTypeList imtl = member.getImportMemberOrTypeList();
    if (imtl != null) {
        if (d instanceof Value) {
            Value v = (Value) d;
            TypeDeclaration td = v.getTypeDeclaration();
            if (td.isObjectClass()) {
                d = td;
            }
        }
        if (d instanceof TypeDeclaration) {
            Set<String> names = new HashSet<String>();
            ImportList til = imtl.getImportList();
            TypeDeclaration td = (TypeDeclaration) d;
            til.setImportedScope(td);
            List<Tree.ImportMemberOrType> imts = imtl.getImportMemberOrTypes();
            for (Tree.ImportMemberOrType imt : imts) {
                names.add(importMember(imt, td, til));
            }
            if (imtl.getImportWildcard() != null) {
                importAllMembers(td, names, til);
            } else if (imts.isEmpty()) {
                imtl.addError("empty import list", 1020);
            }
        } else {
            imtl.addError("member alias list must follow a type");
        }
    }
}
Also used : Value(org.eclipse.ceylon.model.typechecker.model.Value) ImportList(org.eclipse.ceylon.model.typechecker.model.ImportList) Tree(org.eclipse.ceylon.compiler.typechecker.tree.Tree) TypeDeclaration(org.eclipse.ceylon.model.typechecker.model.TypeDeclaration) HashSet(java.util.HashSet)

Example 3 with ImportList

use of org.eclipse.ceylon.model.typechecker.model.ImportList in project ceylon by eclipse.

the class DeclarationVisitor method visit.

@Override
public void visit(Tree.ImportMemberOrTypeList that) {
    ImportList il = new ImportList();
    unit.getImportLists().add(il);
    that.setImportList(il);
    il.setContainer(scope);
    il.setUnit(unit);
    Scope o = enterScope(il);
    super.visit(that);
    exitScope(o);
}
Also used : Scope(org.eclipse.ceylon.model.typechecker.model.Scope) ConditionScope(org.eclipse.ceylon.model.typechecker.model.ConditionScope) ModelUtil.getRealScope(org.eclipse.ceylon.model.typechecker.model.ModelUtil.getRealScope) ImportList(org.eclipse.ceylon.model.typechecker.model.ImportList) ModuleImportList(org.eclipse.ceylon.model.typechecker.model.ModuleImportList)

Aggregations

ImportList (org.eclipse.ceylon.model.typechecker.model.ImportList)3 HashSet (java.util.HashSet)2 Tree (org.eclipse.ceylon.compiler.typechecker.tree.Tree)2 Backends (org.eclipse.ceylon.common.Backends)1 AnalyzerUtil.declaredInPackage (org.eclipse.ceylon.compiler.typechecker.analyzer.AnalyzerUtil.declaredInPackage)1 AnalyzerUtil.importedPackage (org.eclipse.ceylon.compiler.typechecker.analyzer.AnalyzerUtil.importedPackage)1 ConditionScope (org.eclipse.ceylon.model.typechecker.model.ConditionScope)1 ModelUtil.getRealScope (org.eclipse.ceylon.model.typechecker.model.ModelUtil.getRealScope)1 ModuleImportList (org.eclipse.ceylon.model.typechecker.model.ModuleImportList)1 Package (org.eclipse.ceylon.model.typechecker.model.Package)1 Scope (org.eclipse.ceylon.model.typechecker.model.Scope)1 TypeDeclaration (org.eclipse.ceylon.model.typechecker.model.TypeDeclaration)1 Value (org.eclipse.ceylon.model.typechecker.model.Value)1