Search in sources :

Example 6 with ClassOrInterface

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

the class BoxingDeclarationVisitor method setErasureState.

private void setErasureState(TypedDeclaration decl) {
    // deal with invalid input
    if (decl == null)
        return;
    Type type = decl.getType();
    boolean erased = false;
    boolean untrusted = false;
    if (type != null) {
        if (hasErasure(type) || hasSubstitutedBounds(type) || type.isTypeConstructor()) {
            erased = true;
        }
        if (decl.isActual() && decl.getContainer() instanceof ClassOrInterface) {
            TypedDeclaration refinedDeclaration = getRefinedDeclarationForWideningRules(decl);
            if (refinedDeclaration != null && refinedDeclaration != decl && decl.getUntrustedType() == null) {
                // make sure the refined decl is set before we look at it
                setErasureState(refinedDeclaration);
            }
            // make sure we did not lose type information due to non-widening
            if (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
                untrusted = true;
                erased = true;
            }
        }
    }
    decl.setTypeErased(erased);
    if (isPinnedType(decl)) {
        untrusted = true;
    }
    decl.setUntrustedType(untrusted);
}
Also used : ClassOrInterface(org.eclipse.ceylon.model.typechecker.model.ClassOrInterface) TypedDeclaration(org.eclipse.ceylon.model.typechecker.model.TypedDeclaration) AbstractTransformer.isPinnedType(org.eclipse.ceylon.compiler.java.codegen.AbstractTransformer.isPinnedType) Type(org.eclipse.ceylon.model.typechecker.model.Type)

Example 7 with ClassOrInterface

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

the class CeylonDoc method getIcons.

protected final List<String> getIcons(Object obj) {
    List<String> icons = new ArrayList<String>();
    if (obj instanceof Declaration) {
        Declaration decl = (Declaration) obj;
        Annotation deprecated = Util.findAnnotation(decl, "deprecated");
        if (deprecated != null) {
            icons.add("icon-decoration-deprecated");
        }
        if (decl instanceof ClassOrInterface || decl instanceof Constructor) {
            if (decl instanceof Interface) {
                icons.add("icon-interface");
                if (Util.isEnumerated((ClassOrInterface) decl)) {
                    icons.add("icon-decoration-enumerated");
                }
            }
            if (decl instanceof Class) {
                Class klass = (Class) decl;
                if (klass.isAnonymous()) {
                    icons.add("icon-object");
                } else {
                    icons.add("icon-class");
                }
                if (klass.isAbstract()) {
                    icons.add("icon-decoration-abstract");
                }
                if (klass.isFinal() && !klass.isAnonymous() && !klass.isAnnotation()) {
                    icons.add("icon-decoration-final");
                }
                if (Util.isEnumerated(klass)) {
                    icons.add("icon-decoration-enumerated");
                }
            }
            if (decl instanceof Constructor) {
                icons.add("icon-class");
            }
            if (!decl.isShared()) {
                icons.add("icon-decoration-local");
            }
        }
        if (decl instanceof TypedDeclaration) {
            if (decl.isShared()) {
                icons.add("icon-shared-member");
            } else {
                icons.add("icon-local-member");
            }
            if (decl.isFormal()) {
                icons.add("icon-decoration-formal");
            }
            if (decl.isActual()) {
                Declaration refinedDeclaration = decl.getRefinedDeclaration();
                if (refinedDeclaration != null) {
                    if (refinedDeclaration.isFormal()) {
                        icons.add("icon-decoration-impl");
                    }
                    if (refinedDeclaration.isDefault()) {
                        icons.add("icon-decoration-over");
                    }
                }
            }
            if (((TypedDeclaration) decl).isVariable()) {
                icons.add("icon-decoration-variable");
            }
        }
        if (decl instanceof TypeAlias || decl instanceof NothingType) {
            icons.add("icon-type-alias");
        }
        if (decl.isAnnotation()) {
            icons.add("icon-decoration-annotation");
        }
    }
    if (obj instanceof Package) {
        Package pkg = (Package) obj;
        icons.add("icon-package");
        if (!pkg.isShared()) {
            icons.add("icon-decoration-local");
        }
    }
    if (obj instanceof ModuleImport) {
        ModuleImport moduleImport = (ModuleImport) obj;
        icons.add("icon-module");
        if (moduleImport.isExport()) {
            icons.add("icon-module-exported-decoration");
        }
        if (moduleImport.isOptional()) {
            icons.add("icon-module-optional-decoration");
        }
    }
    if (obj instanceof Module) {
        icons.add("icon-module");
    }
    return icons;
}
Also used : ClassOrInterface(org.eclipse.ceylon.model.typechecker.model.ClassOrInterface) TypedDeclaration(org.eclipse.ceylon.model.typechecker.model.TypedDeclaration) Constructor(org.eclipse.ceylon.model.typechecker.model.Constructor) ArrayList(java.util.ArrayList) TypeAlias(org.eclipse.ceylon.model.typechecker.model.TypeAlias) Annotation(org.eclipse.ceylon.model.typechecker.model.Annotation) ModuleImport(org.eclipse.ceylon.model.typechecker.model.ModuleImport) Class(org.eclipse.ceylon.model.typechecker.model.Class) TypedDeclaration(org.eclipse.ceylon.model.typechecker.model.TypedDeclaration) Declaration(org.eclipse.ceylon.model.typechecker.model.Declaration) Package(org.eclipse.ceylon.model.typechecker.model.Package) Module(org.eclipse.ceylon.model.typechecker.model.Module) Interface(org.eclipse.ceylon.model.typechecker.model.Interface) ClassOrInterface(org.eclipse.ceylon.model.typechecker.model.ClassOrInterface) NothingType(org.eclipse.ceylon.model.typechecker.model.NothingType)

Example 8 with ClassOrInterface

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

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(org.eclipse.ceylon.model.typechecker.model.TypedDeclaration) ClassOrInterface(org.eclipse.ceylon.model.typechecker.model.ClassOrInterface) Util.isAbbreviatedType(org.eclipse.ceylon.ceylondoc.Util.isAbbreviatedType) Type(org.eclipse.ceylon.model.typechecker.model.Type)

Example 9 with ClassOrInterface

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

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(org.eclipse.ceylon.model.typechecker.model.ClassOrInterface) TypeAlias(org.eclipse.ceylon.model.typechecker.model.TypeAlias) TypeDeclaration(org.eclipse.ceylon.model.typechecker.model.TypeDeclaration)

Example 10 with ClassOrInterface

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

the class LinkRenderer method getExternalUrl.

private String getExternalUrl(Object to) {
    String url = null;
    if (to instanceof Module) {
        url = getExternalModuleUrl((Module) to);
        if (url != null) {
            url += "index.html";
        }
    } else if (to instanceof Package) {
        Package pkg = (Package) to;
        url = getExternalModuleUrl(pkg.getModule());
        if (url != null) {
            url += buildPackageUrlPath(pkg);
            url += "index.html";
        }
    } else if (to instanceof ClassOrInterface) {
        ClassOrInterface klass = (ClassOrInterface) to;
        Package pkg = getPackage(klass);
        url = getExternalModuleUrl(pkg.getModule());
        if (url != null) {
            url += buildPackageUrlPath(pkg);
            url += ceylonDocTool.getFileName(klass);
        }
    }
    return url;
}
Also used : ClassOrInterface(org.eclipse.ceylon.model.typechecker.model.ClassOrInterface) Package(org.eclipse.ceylon.model.typechecker.model.Package) Module(org.eclipse.ceylon.model.typechecker.model.Module)

Aggregations

ClassOrInterface (org.eclipse.ceylon.model.typechecker.model.ClassOrInterface)102 TypeDeclaration (org.eclipse.ceylon.model.typechecker.model.TypeDeclaration)62 Declaration (org.eclipse.ceylon.model.typechecker.model.Declaration)48 TypedDeclaration (org.eclipse.ceylon.model.typechecker.model.TypedDeclaration)46 Type (org.eclipse.ceylon.model.typechecker.model.Type)44 Tree (org.eclipse.ceylon.compiler.typechecker.tree.Tree)27 Class (org.eclipse.ceylon.model.typechecker.model.Class)24 Interface (org.eclipse.ceylon.model.typechecker.model.Interface)23 Scope (org.eclipse.ceylon.model.typechecker.model.Scope)23 TypeParameter (org.eclipse.ceylon.model.typechecker.model.TypeParameter)20 ModelUtil.getContainingClassOrInterface (org.eclipse.ceylon.model.typechecker.model.ModelUtil.getContainingClassOrInterface)19 Value (org.eclipse.ceylon.model.typechecker.model.Value)19 ModelUtil.appliedType (org.eclipse.ceylon.model.typechecker.model.ModelUtil.appliedType)18 ArrayList (java.util.ArrayList)17 FunctionOrValue (org.eclipse.ceylon.model.typechecker.model.FunctionOrValue)17 Constructor (org.eclipse.ceylon.model.typechecker.model.Constructor)16 Function (org.eclipse.ceylon.model.typechecker.model.Function)14 LazyInterface (org.eclipse.ceylon.model.loader.model.LazyInterface)13 JCExpression (org.eclipse.ceylon.langtools.tools.javac.tree.JCTree.JCExpression)12 UnknownType (org.eclipse.ceylon.model.typechecker.model.UnknownType)12