Search in sources :

Example 71 with Package

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

the class CeylonDocTool method collectAnnotationConstructors.

private void collectAnnotationConstructors() {
    for (Module module : modules) {
        for (Package pkg : getPackages(module)) {
            for (Declaration decl : pkg.getMembers()) {
                if (decl instanceof Function && decl.isAnnotation() && shouldInclude(decl)) {
                    Function annotationCtor = (Function) decl;
                    TypeDeclaration annotationType = annotationCtor.getTypeDeclaration();
                    List<Function> annotationConstructorList = annotationConstructors.get(annotationType);
                    if (annotationConstructorList == null) {
                        annotationConstructorList = new ArrayList<Function>();
                        annotationConstructors.put(annotationType, annotationConstructorList);
                    }
                    annotationConstructorList.add(annotationCtor);
                }
            }
        }
    }
}
Also used : Function(org.eclipse.ceylon.model.typechecker.model.Function) Package(org.eclipse.ceylon.model.typechecker.model.Package) TypeDeclaration(org.eclipse.ceylon.model.typechecker.model.TypeDeclaration) Declaration(org.eclipse.ceylon.model.typechecker.model.Declaration) Module(org.eclipse.ceylon.model.typechecker.model.Module) TypeDeclaration(org.eclipse.ceylon.model.typechecker.model.TypeDeclaration)

Example 72 with Package

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

the class ClassDoc method writeSubNavBar.

private void writeSubNavBar() throws IOException {
    Package pkg = tool.getPackage(klass);
    open("div class='sub-navbar'");
    writeLinkSourceCode(klass);
    open("div class='sub-navbar-inner'");
    open("span class='sub-navbar-package'");
    writeIcon(pkg);
    writePackageNavigation(pkg);
    close("span");
    write("<br/>");
    writeClassSignature();
    // sub-navbar-inner
    close("div");
    open("div class='sub-navbar-menu'");
    writeSubNavBarLink(linkRenderer().to(module).getUrl(), "Overview", 'O', "Jump to module documentation");
    writeSubNavBarLink(linkRenderer().to(pkg).getUrl(), "Package", 'P', "Jump to package documentation");
    if (hasInitializer()) {
        writeSubNavBarLink("#section-initializer", "Initializer", 'z', "Jump to initializer");
    }
    if (!constructors.isEmpty()) {
        writeSubNavBarLink("#section-constructors", "Constructors", 't', "Jump to constructors");
    }
    if (hasAnyAttributes()) {
        writeSubNavBarLink("#section-attributes", "Attributes", 'A', "Jump to attributes");
    }
    if (hasAnyMethods()) {
        writeSubNavBarLink("#section-methods", "Methods", 'M', "Jump to methods");
    }
    if (!innerAliases.isEmpty()) {
        writeSubNavBarLink("#section-nested-aliases", "Nested Aliases", 'l', "Jump to nested aliases");
    }
    if (!innerInterfaces.isEmpty()) {
        writeSubNavBarLink("#section-nested-interfaces", "Nested Interfaces", 'I', "Jump to nested interfaces");
    }
    if (!innerClasses.isEmpty()) {
        writeSubNavBarLink("#section-nested-classes", "Nested Classes", 'C', "Jump to nested classes");
    }
    if (!innerExceptions.isEmpty()) {
        writeSubNavBarLink("#section-nested-exceptions", "Nested Exceptions", 'E', "Jump to nested exceptions");
    }
    if (isObject()) {
        writeSubNavBarLink(linkRenderer().to(klass.getContainer()).useAnchor(klass.getName()).getUrl(), "Singleton object declaration", '\0', "Jump to singleton object declaration");
    }
    // sub-navbar-menu
    close("div");
    // sub-navbar
    close("div");
}
Also used : Package(org.eclipse.ceylon.model.typechecker.model.Package)

Example 73 with Package

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

the class LinkRenderer method isLinkable.

private boolean isLinkable(Declaration decl) {
    if (decl == null) {
        return false;
    }
    if (decl.isParameter()) {
        return true;
    }
    if (!ceylonDocTool.isIncludeNonShared()) {
        if (!decl.isShared()) {
            return false;
        }
        Scope c = decl.getContainer();
        while (c != null) {
            boolean isShared = true;
            if (c instanceof Declaration) {
                isShared = ((Declaration) c).isShared();
            }
            if (c instanceof Package) {
                isShared = ((Package) c).isShared();
            }
            if (!isShared) {
                return false;
            }
            c = c.getContainer();
        }
    }
    return true;
}
Also used : Scope(org.eclipse.ceylon.model.typechecker.model.Scope) TypedDeclaration(org.eclipse.ceylon.model.typechecker.model.TypedDeclaration) TypeDeclaration(org.eclipse.ceylon.model.typechecker.model.TypeDeclaration) Declaration(org.eclipse.ceylon.model.typechecker.model.Declaration) Package(org.eclipse.ceylon.model.typechecker.model.Package)

Example 74 with Package

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

the class LinkRenderer method processAnnotationParam.

private String processAnnotationParam(String text) {
    if (text.equals("module")) {
        Module mod = getCurrentModule();
        if (mod != null) {
            return processModule(mod);
        }
    }
    if (text.startsWith("module ")) {
        String modName = text.substring(7);
        for (Module m : ceylonDocTool.getTypeChecker().getContext().getModules().getListOfModules()) {
            if (m.getNameAsString().equals(modName)) {
                return processModule(m);
            }
        }
    }
    if (text.equals("package")) {
        Package pkg = getCurrentPackage();
        if (pkg != null) {
            return processPackage(pkg);
        }
    }
    if (text.startsWith("package ")) {
        String pkgName = text.substring(8);
        for (Module m : ceylonDocTool.getTypeChecker().getContext().getModules().getListOfModules()) {
            if (pkgName.startsWith(m.getNameAsString() + ".")) {
                Package pkg = m.getPackage(pkgName);
                if (pkg != null) {
                    return processPackage(pkg);
                }
            }
        }
    }
    if (text.equals("interface")) {
        Interface interf = getCurrentInterface();
        if (interf != null) {
            return processProducedType(interf.getType());
        }
    }
    if (text.equals("class")) {
        Class clazz = getCurrentClass();
        if (clazz != null) {
            return processProducedType(clazz.getType());
        }
    }
    String declName;
    Scope currentScope;
    int pkgSeparatorIndex = text.indexOf("::");
    if (pkgSeparatorIndex == -1) {
        declName = text;
        currentScope = resolveScope(scope);
    } else {
        String pkgName = text.substring(0, pkgSeparatorIndex);
        declName = text.substring(pkgSeparatorIndex + 2, text.length());
        currentScope = ceylonDocTool.getCurrentModule().getPackage(pkgName);
    }
    String[] declNames = declName.split("\\.");
    Declaration currentDecl = null;
    boolean isNested = false;
    for (String currentDeclName : declNames) {
        currentDecl = resolveDeclaration(currentScope, currentDeclName, isNested);
        if (currentDecl != null) {
            if (isValueWithTypeObject(currentDecl)) {
                TypeDeclaration objectType = ((Value) currentDecl).getTypeDeclaration();
                currentScope = objectType;
                currentDecl = objectType;
            } else {
                currentScope = resolveScope(currentDecl);
            }
            isNested = true;
        } else {
            break;
        }
    }
    // we can't link to parameters yet, unless they're toplevel
    if (currentDecl != null && !isParameter(currentDecl)) {
        if (currentDecl instanceof TypeDeclaration) {
            return processProducedType(((TypeDeclaration) currentDecl).getType());
        } else {
            return processTypedDeclaration((TypedDeclaration) currentDecl);
        }
    } else {
        return getUnresolvableLink(text);
    }
}
Also used : Scope(org.eclipse.ceylon.model.typechecker.model.Scope) Value(org.eclipse.ceylon.model.typechecker.model.Value) FunctionOrValue(org.eclipse.ceylon.model.typechecker.model.FunctionOrValue) Class(org.eclipse.ceylon.model.typechecker.model.Class) Package(org.eclipse.ceylon.model.typechecker.model.Package) TypedDeclaration(org.eclipse.ceylon.model.typechecker.model.TypedDeclaration) TypeDeclaration(org.eclipse.ceylon.model.typechecker.model.TypeDeclaration) Declaration(org.eclipse.ceylon.model.typechecker.model.Declaration) Module(org.eclipse.ceylon.model.typechecker.model.Module) TypeDeclaration(org.eclipse.ceylon.model.typechecker.model.TypeDeclaration) Interface(org.eclipse.ceylon.model.typechecker.model.Interface) ClassOrInterface(org.eclipse.ceylon.model.typechecker.model.ClassOrInterface)

Example 75 with Package

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

the class CeylonDoc method writePackagesTable.

protected final void writePackagesTable(String title, List<Package> packages) throws IOException {
    if (!packages.isEmpty()) {
        openTable("section-packages", title, 2, true);
        for (Package pkg : packages) {
            writePackagesTableRow(pkg);
        }
        closeTable();
    }
}
Also used : Package(org.eclipse.ceylon.model.typechecker.model.Package)

Aggregations

Package (org.eclipse.ceylon.model.typechecker.model.Package)84 Declaration (org.eclipse.ceylon.model.typechecker.model.Declaration)31 TypeDeclaration (org.eclipse.ceylon.model.typechecker.model.TypeDeclaration)31 TypedDeclaration (org.eclipse.ceylon.model.typechecker.model.TypedDeclaration)27 Module (org.eclipse.ceylon.model.typechecker.model.Module)26 Scope (org.eclipse.ceylon.model.typechecker.model.Scope)21 ClassOrInterface (org.eclipse.ceylon.model.typechecker.model.ClassOrInterface)14 ArrayList (java.util.ArrayList)13 LazyPackage (org.eclipse.ceylon.model.loader.model.LazyPackage)11 Class (org.eclipse.ceylon.model.typechecker.model.Class)11 Function (org.eclipse.ceylon.model.typechecker.model.Function)9 Interface (org.eclipse.ceylon.model.typechecker.model.Interface)9 Value (org.eclipse.ceylon.model.typechecker.model.Value)9 PhasedUnit (org.eclipse.ceylon.compiler.typechecker.context.PhasedUnit)8 Constructor (org.eclipse.ceylon.model.typechecker.model.Constructor)8 TypeParameter (org.eclipse.ceylon.model.typechecker.model.TypeParameter)8 HashSet (java.util.HashSet)7 Tree (org.eclipse.ceylon.compiler.typechecker.tree.Tree)7 ModuleImport (org.eclipse.ceylon.model.typechecker.model.ModuleImport)7 Type (org.eclipse.ceylon.model.typechecker.model.Type)7