Search in sources :

Example 76 with TypeDeclaration

use of com.redhat.ceylon.model.typechecker.model.TypeDeclaration in project ceylon-compiler by ceylon.

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(com.redhat.ceylon.compiler.typechecker.tree.Tree.CompilationUnit) ModuleDescriptor(com.redhat.ceylon.compiler.typechecker.tree.Tree.ModuleDescriptor) Visitor(com.redhat.ceylon.compiler.typechecker.tree.Visitor) SourceDeclarationVisitor(com.redhat.ceylon.compiler.java.loader.SourceDeclarationVisitor) Referenceable(com.redhat.ceylon.model.typechecker.model.Referenceable) Tree(com.redhat.ceylon.compiler.typechecker.tree.Tree) PackageDescriptor(com.redhat.ceylon.compiler.typechecker.tree.Tree.PackageDescriptor) TypeDeclaration(com.redhat.ceylon.model.typechecker.model.TypeDeclaration) PhasedUnit(com.redhat.ceylon.compiler.typechecker.context.PhasedUnit)

Example 77 with TypeDeclaration

use of com.redhat.ceylon.model.typechecker.model.TypeDeclaration in project ceylon-compiler by ceylon.

the class ClassDoc method writeSubtypesHierarchy.

private void writeSubtypesHierarchy(List<TypeDeclaration> types, int level) throws IOException {
    if (types.size() > 1) {
        Collections.sort(types, ReferenceableComparatorByName.INSTANCE);
    }
    for (TypeDeclaration type : types) {
        List<TypeDeclaration> subtypes = collectSubtypes(type);
        writeTypeHierarchyLevel(type, !subtypes.isEmpty());
        if (level == 0 && Util.isEnumerated(type)) {
            around("span class='keyword'", " of");
        }
        open("div class='subhierarchy'");
        writeSubtypesHierarchy(subtypes, level + 1);
        // subhierarchy
        close("div");
        close("li", "ul");
    }
}
Also used : TypeDeclaration(com.redhat.ceylon.model.typechecker.model.TypeDeclaration)

Example 78 with TypeDeclaration

use of com.redhat.ceylon.model.typechecker.model.TypeDeclaration in project ceylon-compiler by ceylon.

the class ClassDoc method writeQualifyingType.

private void writeQualifyingType(TypeDeclaration klass) throws IOException {
    if (klass.isClassOrInterfaceMember()) {
        TypeDeclaration container = (TypeDeclaration) klass.getContainer();
        writeQualifyingType(container);
        linkRenderer().to(container).useScope(klass).write();
        write(".");
    }
}
Also used : TypeDeclaration(com.redhat.ceylon.model.typechecker.model.TypeDeclaration)

Example 79 with TypeDeclaration

use of com.redhat.ceylon.model.typechecker.model.TypeDeclaration in project ceylon-compiler by ceylon.

the class ClassDoc method writeSuperTypeHierarchy.

private void writeSuperTypeHierarchy(List<TypeDeclaration> types, int level) throws IOException {
    if (types.size() > 1) {
        Collections.sort(types, ReferenceableComparatorByName.INSTANCE);
    }
    for (TypeDeclaration type : types) {
        List<TypeDeclaration> supertypes = collectSupertypes(type);
        writeTypeHierarchyLevel(type, !supertypes.isEmpty());
        open("div class='subhierarchy'");
        writeSuperTypeHierarchy(supertypes, level + 1);
        // subhierarchy
        close("div");
        close("li", "ul");
    }
}
Also used : TypeDeclaration(com.redhat.ceylon.model.typechecker.model.TypeDeclaration)

Example 80 with TypeDeclaration

use of com.redhat.ceylon.model.typechecker.model.TypeDeclaration in project ceylon-compiler by ceylon.

the class ClassDoc method writeInheritedMembers.

private void writeInheritedMembers(MemberSpecification specification, String tableTitle, String rowTitle) throws IOException {
    boolean first = true;
    Map<TypeDeclaration, SortedMap<String, Declaration>> superClassInheritedMembersMap = superclassInheritedMembers.get(specification);
    List<TypeDeclaration> superClasses = new ArrayList<TypeDeclaration>(superclassInheritedMembers.get(specification).keySet());
    Collections.sort(superClasses, ReferenceableComparatorByName.INSTANCE);
    for (TypeDeclaration superClass : superClasses) {
        SortedMap<String, Declaration> inheritedMembers = superClassInheritedMembersMap.get(superClass);
        if (first) {
            first = false;
            openTable(null, tableTitle, 1, false);
        }
        writeInheritedMembersRow(rowTitle, superClass, inheritedMembers);
    }
    Map<TypeDeclaration, SortedMap<String, Declaration>> superInterfaceInheritedMembersMap = interfaceInheritedMembers.get(specification);
    List<TypeDeclaration> superInterfaces = new ArrayList<TypeDeclaration>(superInterfaceInheritedMembersMap.keySet());
    Collections.sort(superInterfaces, ReferenceableComparatorByName.INSTANCE);
    for (TypeDeclaration superInterface : superInterfaces) {
        SortedMap<String, Declaration> members = superInterfaceInheritedMembersMap.get(superInterface);
        if (members == null || members.isEmpty()) {
            continue;
        }
        if (first) {
            first = false;
            openTable(null, tableTitle, 1, false);
        }
        writeInheritedMembersRow(rowTitle, superInterface, members);
    }
    if (!first) {
        closeTable();
    }
}
Also used : SortedMap(java.util.SortedMap) ArrayList(java.util.ArrayList) TypedDeclaration(com.redhat.ceylon.model.typechecker.model.TypedDeclaration) Declaration(com.redhat.ceylon.model.typechecker.model.Declaration) TypeDeclaration(com.redhat.ceylon.model.typechecker.model.TypeDeclaration) TypeDeclaration(com.redhat.ceylon.model.typechecker.model.TypeDeclaration)

Aggregations

TypeDeclaration (com.redhat.ceylon.model.typechecker.model.TypeDeclaration)140 Type (com.redhat.ceylon.model.typechecker.model.Type)85 Test (org.junit.Test)51 Class (com.redhat.ceylon.model.typechecker.model.Class)40 ClassOrInterface (com.redhat.ceylon.model.typechecker.model.ClassOrInterface)37 TypedDeclaration (com.redhat.ceylon.model.typechecker.model.TypedDeclaration)36 IntersectionType (com.redhat.ceylon.model.typechecker.model.IntersectionType)33 UnionType (com.redhat.ceylon.model.typechecker.model.UnionType)33 TypeParser (com.redhat.ceylon.model.loader.TypeParser)32 Declaration (com.redhat.ceylon.model.typechecker.model.Declaration)32 Interface (com.redhat.ceylon.model.typechecker.model.Interface)27 JCExpression (com.sun.tools.javac.tree.JCTree.JCExpression)24 Tree (com.redhat.ceylon.compiler.typechecker.tree.Tree)20 ModelUtil.appliedType (com.redhat.ceylon.model.typechecker.model.ModelUtil.appliedType)19 TypeParameter (com.redhat.ceylon.model.typechecker.model.TypeParameter)19 Function (com.redhat.ceylon.model.typechecker.model.Function)18 ArrayList (java.util.ArrayList)17 JCTree (com.sun.tools.javac.tree.JCTree)16 FunctionOrValue (com.redhat.ceylon.model.typechecker.model.FunctionOrValue)14 JCNewClass (com.sun.tools.javac.tree.JCTree.JCNewClass)14