Search in sources :

Example 26 with ClassOrInterface

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

the class CeylonDocTool method collectSubclasses.

private void collectSubclasses() throws IOException {
    for (Module module : modules) {
        for (Package pkg : getPackages(module)) {
            for (Declaration decl : pkg.getMembers()) {
                if (!shouldInclude(decl)) {
                    continue;
                }
                if (decl instanceof ClassOrInterface) {
                    ClassOrInterface c = (ClassOrInterface) decl;
                    // subclasses map
                    if (c instanceof Class) {
                        Type superclass = c.getExtendedType();
                        if (superclass != null) {
                            TypeDeclaration superdec = superclass.getDeclaration();
                            if (subclasses.get(superdec) == null) {
                                subclasses.put(superdec, new ArrayList<Class>());
                            }
                            subclasses.get(superdec).add((Class) c);
                        }
                    }
                    List<Type> satisfiedTypes = new ArrayList<Type>(c.getSatisfiedTypes());
                    if (satisfiedTypes != null && satisfiedTypes.isEmpty() == false) {
                        // satisfying classes or interfaces map
                        for (Type satisfiedType : satisfiedTypes) {
                            TypeDeclaration superdec = satisfiedType.getDeclaration();
                            if (satisfyingClassesOrInterfaces.get(superdec) == null) {
                                satisfyingClassesOrInterfaces.put(superdec, new ArrayList<ClassOrInterface>());
                            }
                            satisfyingClassesOrInterfaces.get(superdec).add(c);
                        }
                    }
                }
            }
        }
    }
}
Also used : ClassOrInterface(com.redhat.ceylon.model.typechecker.model.ClassOrInterface) NothingType(com.redhat.ceylon.model.typechecker.model.NothingType) Type(com.redhat.ceylon.model.typechecker.model.Type) ArrayList(java.util.ArrayList) Class(com.redhat.ceylon.model.typechecker.model.Class) Package(com.redhat.ceylon.model.typechecker.model.Package) Declaration(com.redhat.ceylon.model.typechecker.model.Declaration) TypeDeclaration(com.redhat.ceylon.model.typechecker.model.TypeDeclaration) Module(com.redhat.ceylon.model.typechecker.model.Module) TypeDeclaration(com.redhat.ceylon.model.typechecker.model.TypeDeclaration)

Example 27 with ClassOrInterface

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

the class ClassDoc method writeListOnSummary.

private void writeListOnSummary(String cssClass, String title, List<?> types) throws IOException {
    if (!isEmpty(types)) {
        open("div class='" + cssClass + " section'");
        around("span class='title'", title);
        boolean first = true;
        for (Object type : types) {
            if (!first) {
                write(", ");
            } else {
                first = false;
            }
            if (type instanceof TypedDeclaration) {
                TypedDeclaration decl = (TypedDeclaration) type;
                linkRenderer().to(decl).useScope(klass).write();
            } else if (type instanceof ClassOrInterface) {
                ClassOrInterface coi = (ClassOrInterface) type;
                linkRenderer().to(coi).useScope(klass).printAbbreviated(!isAbbreviatedType(coi)).write();
            } else {
                Type pt = (Type) type;
                linkRenderer().to(pt).useScope(klass).printAbbreviated(!isAbbreviatedType(pt.getDeclaration())).write();
            }
        }
        close("div");
    }
}
Also used : TypedDeclaration(com.redhat.ceylon.model.typechecker.model.TypedDeclaration) ClassOrInterface(com.redhat.ceylon.model.typechecker.model.ClassOrInterface) Type(com.redhat.ceylon.model.typechecker.model.Type) Util.isAbbreviatedType(com.redhat.ceylon.ceylondoc.Util.isAbbreviatedType)

Example 28 with ClassOrInterface

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

the class ClassDoc method writeInnerTypes.

private void writeInnerTypes(Map<String, ? extends TypeDeclaration> innerTypeDeclarations, String id, String title) throws IOException {
    if (!innerTypeDeclarations.isEmpty()) {
        openTable(id, title, 2, true);
        for (Entry<String, ? extends TypeDeclaration> entry : innerTypeDeclarations.entrySet()) {
            TypeDeclaration innerTypeDeclaration = entry.getValue();
            String name = entry.getKey();
            if (innerTypeDeclaration instanceof ClassOrInterface) {
                ClassOrInterface innerClassOrInterface = (ClassOrInterface) innerTypeDeclaration;
                tool.doc(innerClassOrInterface);
                doc(name, innerClassOrInterface);
            }
            if (innerTypeDeclaration instanceof TypeAlias) {
                TypeAlias innerAlias = (TypeAlias) innerTypeDeclaration;
                doc(name, innerAlias);
            }
        }
        closeTable();
    }
}
Also used : ClassOrInterface(com.redhat.ceylon.model.typechecker.model.ClassOrInterface) TypeAlias(com.redhat.ceylon.model.typechecker.model.TypeAlias) TypeDeclaration(com.redhat.ceylon.model.typechecker.model.TypeDeclaration)

Example 29 with ClassOrInterface

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

the class TypeParameterCaptureVisitor method visit.

@Override
public void visit(Tree.ClassOrInterface that) {
    ClassOrInterface model = that.getDeclarationModel();
    if (model != null && !model.isAlias() && !model.isToplevel() && !model.isMember()) {
        // it's a local type, capture!
        captureTypeParameters(model);
    }
    super.visit(that);
}
Also used : ClassOrInterface(com.redhat.ceylon.model.typechecker.model.ClassOrInterface)

Example 30 with ClassOrInterface

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

the class BoxingDeclarationVisitor method setErasureState.

private void setErasureState(TypedDeclaration decl) {
    // deal with invalid input
    if (decl == null)
        return;
    Type type = decl.getType();
    if (type != null) {
        if (hasErasure(type) || hasSubstitutedBounds(type) || type.isTypeConstructor()) {
            decl.setTypeErased(true);
        }
        if (decl.isActual() && decl.getContainer() instanceof ClassOrInterface && // make sure we did not lose type information due to non-widening
        isWideningTypedDeclaration(decl)) {
            // widening means not trusting the type, otherwise we end up thinking that the type is
            // something it's not and regular erasure rules don't apply there
            decl.setUntrustedType(true);
            decl.setTypeErased(true);
        }
    }
}
Also used : ClassOrInterface(com.redhat.ceylon.model.typechecker.model.ClassOrInterface) Type(com.redhat.ceylon.model.typechecker.model.Type)

Aggregations

ClassOrInterface (com.redhat.ceylon.model.typechecker.model.ClassOrInterface)37 Type (com.redhat.ceylon.model.typechecker.model.Type)21 TypeDeclaration (com.redhat.ceylon.model.typechecker.model.TypeDeclaration)20 TypedDeclaration (com.redhat.ceylon.model.typechecker.model.TypedDeclaration)16 Declaration (com.redhat.ceylon.model.typechecker.model.Declaration)15 Interface (com.redhat.ceylon.model.typechecker.model.Interface)13 ModelUtil.appliedType (com.redhat.ceylon.model.typechecker.model.ModelUtil.appliedType)11 JCExpression (com.sun.tools.javac.tree.JCTree.JCExpression)11 Class (com.redhat.ceylon.model.typechecker.model.Class)9 Package (com.redhat.ceylon.model.typechecker.model.Package)7 Scope (com.redhat.ceylon.model.typechecker.model.Scope)7 TypeParameter (com.redhat.ceylon.model.typechecker.model.TypeParameter)7 Function (com.redhat.ceylon.model.typechecker.model.Function)6 JCNewClass (com.sun.tools.javac.tree.JCTree.JCNewClass)6 Tree (com.redhat.ceylon.compiler.typechecker.tree.Tree)5 Constructor (com.redhat.ceylon.model.typechecker.model.Constructor)5 TypeAlias (com.redhat.ceylon.model.typechecker.model.TypeAlias)5 JCTree (com.sun.tools.javac.tree.JCTree)5 JCTypeParameter (com.sun.tools.javac.tree.JCTree.JCTypeParameter)5 ArrayList (java.util.ArrayList)5