Search in sources :

Example 11 with Visitor

use of org.eclipse.ceylon.compiler.typechecker.tree.Visitor in project ceylon by eclipse.

the class CeylonDocTool method buildNodesMaps.

private void buildNodesMaps() {
    for (final PhasedUnit pu : phasedUnits) {
        CompilationUnit cu = pu.getCompilationUnit();
        Walker.walkCompilationUnit(new Visitor() {

            public void visit(Tree.Declaration that) {
                modelUnitMap.put(that.getDeclarationModel(), pu);
                modelNodeMap.put(that.getDeclarationModel(), that);
                super.visit(that);
            }

            public void visit(Tree.ObjectDefinition that) {
                if (that.getDeclarationModel() != null && that.getDeclarationModel().getTypeDeclaration() != null) {
                    TypeDeclaration typeDecl = that.getDeclarationModel().getTypeDeclaration();
                    modelUnitMap.put(typeDecl, pu);
                    modelNodeMap.put(typeDecl, that);
                }
                super.visit(that);
            }

            public void visit(Tree.PackageDescriptor that) {
                if (that.getImportPath() != null && that.getImportPath().getModel() != null) {
                    Referenceable model = that.getImportPath().getModel();
                    modelUnitMap.put(model, pu);
                    modelNodeMap.put(model, that);
                }
                super.visit(that);
            }

            public void visit(Tree.ModuleDescriptor that) {
                if (that.getImportPath() != null && that.getImportPath().getModel() != null) {
                    Referenceable model = that.getImportPath().getModel();
                    modelUnitMap.put(model, pu);
                    modelNodeMap.put(model, that);
                }
                super.visit(that);
            }

            public void visit(Tree.SpecifierStatement that) {
                modelUnitMap.put(that.getDeclaration(), pu);
                modelNodeMap.put(that.getDeclaration(), that);
                super.visit(that);
            }

            public void visit(Tree.Parameter param) {
                parameterUnitMap.put(param.getParameterModel(), pu);
                parameterNodeMap.put(param.getParameterModel(), param);
                super.visit(param);
            }
        }, cu);
    }
}
Also used : CompilationUnit(org.eclipse.ceylon.compiler.typechecker.tree.Tree.CompilationUnit) Visitor(org.eclipse.ceylon.compiler.typechecker.tree.Visitor) AssertionVisitor(org.eclipse.ceylon.compiler.typechecker.util.AssertionVisitor) Referenceable(org.eclipse.ceylon.model.typechecker.model.Referenceable) Tree(org.eclipse.ceylon.compiler.typechecker.tree.Tree) TypeDeclaration(org.eclipse.ceylon.model.typechecker.model.TypeDeclaration) PhasedUnit(org.eclipse.ceylon.compiler.typechecker.context.PhasedUnit)

Aggregations

Visitor (org.eclipse.ceylon.compiler.typechecker.tree.Visitor)11 Tree (org.eclipse.ceylon.compiler.typechecker.tree.Tree)8 Declaration (org.eclipse.ceylon.model.typechecker.model.Declaration)5 PhasedUnit (org.eclipse.ceylon.compiler.typechecker.context.PhasedUnit)4 Node (org.eclipse.ceylon.compiler.typechecker.tree.Node)4 TypeDeclaration (org.eclipse.ceylon.model.typechecker.model.TypeDeclaration)4 ArrayList (java.util.ArrayList)3 HashMap (java.util.HashMap)3 Scope (org.eclipse.ceylon.model.typechecker.model.Scope)3 TypedDeclaration (org.eclipse.ceylon.model.typechecker.model.TypedDeclaration)3 Map (java.util.Map)2 CustomTree (org.eclipse.ceylon.compiler.typechecker.tree.CustomTree)2 AssertionVisitor (org.eclipse.ceylon.compiler.typechecker.util.AssertionVisitor)2 FunctionOrValue (org.eclipse.ceylon.model.typechecker.model.FunctionOrValue)2 Module (org.eclipse.ceylon.model.typechecker.model.Module)2 BufferedReader (java.io.BufferedReader)1 File (java.io.File)1 FileInputStream (java.io.FileInputStream)1 FileWriter (java.io.FileWriter)1 InputStreamReader (java.io.InputStreamReader)1