Search in sources :

Example 1 with Module

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

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(com.redhat.ceylon.model.typechecker.model.ClassOrInterface) TypedDeclaration(com.redhat.ceylon.model.typechecker.model.TypedDeclaration) Constructor(com.redhat.ceylon.model.typechecker.model.Constructor) ArrayList(java.util.ArrayList) TypeAlias(com.redhat.ceylon.model.typechecker.model.TypeAlias) Annotation(com.redhat.ceylon.model.typechecker.model.Annotation) ModuleImport(com.redhat.ceylon.model.typechecker.model.ModuleImport) Class(com.redhat.ceylon.model.typechecker.model.Class) TypedDeclaration(com.redhat.ceylon.model.typechecker.model.TypedDeclaration) Declaration(com.redhat.ceylon.model.typechecker.model.Declaration) Package(com.redhat.ceylon.model.typechecker.model.Package) Module(com.redhat.ceylon.model.typechecker.model.Module) Interface(com.redhat.ceylon.model.typechecker.model.Interface) ClassOrInterface(com.redhat.ceylon.model.typechecker.model.ClassOrInterface) NothingType(com.redhat.ceylon.model.typechecker.model.NothingType)

Example 2 with Module

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

the class CeylonDocTool method getResourceUrl.

protected String getResourceUrl(Object from, String to) throws IOException {
    Module module = getModule(from);
    URI fromUrl = getAbsoluteObjectUrl(from);
    URI toUrl = getBaseUrl(module).resolve(".resources/" + to);
    String result = relativize(module, fromUrl, toUrl).toString();
    return result;
}
Also used : Module(com.redhat.ceylon.model.typechecker.model.Module) URI(java.net.URI)

Example 3 with Module

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

the class CeylonDocTool method getObjectUrl.

protected String getObjectUrl(Object from, Object to, boolean withFragment) throws IOException {
    Module module = getModule(from);
    URI fromUrl = getAbsoluteObjectUrl(from);
    URI toUrl = getAbsoluteObjectUrl(to);
    String result = relativize(module, fromUrl, toUrl).toString();
    if (withFragment && to instanceof Package && isRootPackage(module, (Package) to)) {
        result += "#section-package";
    }
    return result;
}
Also used : Package(com.redhat.ceylon.model.typechecker.model.Package) Module(com.redhat.ceylon.model.typechecker.model.Module) URI(java.net.URI)

Example 4 with Module

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

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(com.redhat.ceylon.model.typechecker.model.Function) 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 5 with Module

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

the class CeylonDocTool method getObjectFile.

private File getObjectFile(Object modPgkOrDecl) throws IOException {
    final File file;
    if (modPgkOrDecl instanceof TypeDeclaration) {
        TypeDeclaration type = (TypeDeclaration) modPgkOrDecl;
        String filename = getFileName(type);
        file = new File(getFolder(type), filename);
    } else if (modPgkOrDecl instanceof Module) {
        String filename = "index.html";
        file = new File(getApiOutputFolder((Module) modPgkOrDecl), filename);
    } else if (modPgkOrDecl instanceof Package) {
        String filename = "index.html";
        file = new File(getFolder((Package) modPgkOrDecl), filename);
    } else {
        throw new RuntimeException(CeylondMessages.msg("error.unexpected", modPgkOrDecl));
    }
    return file.getCanonicalFile();
}
Also used : Package(com.redhat.ceylon.model.typechecker.model.Package) Module(com.redhat.ceylon.model.typechecker.model.Module) File(java.io.File) TypeDeclaration(com.redhat.ceylon.model.typechecker.model.TypeDeclaration)

Aggregations

Module (com.redhat.ceylon.model.typechecker.model.Module)50 Package (com.redhat.ceylon.model.typechecker.model.Package)16 File (java.io.File)14 Test (org.junit.Test)12 TypeDeclaration (com.redhat.ceylon.model.typechecker.model.TypeDeclaration)10 CeylonDocTool (com.redhat.ceylon.ceylondoc.CeylonDocTool)9 Declaration (com.redhat.ceylon.model.typechecker.model.Declaration)9 ArrayList (java.util.ArrayList)6 ClassOrInterface (com.redhat.ceylon.model.typechecker.model.ClassOrInterface)5 ModuleImport (com.redhat.ceylon.model.typechecker.model.ModuleImport)5 ImportModule (com.redhat.ceylon.compiler.typechecker.tree.Tree.ImportModule)4 Class (com.redhat.ceylon.model.typechecker.model.Class)4 TypedDeclaration (com.redhat.ceylon.model.typechecker.model.TypedDeclaration)4 ErrorCollector (com.redhat.ceylon.compiler.java.test.ErrorCollector)3 CeyloncTaskImpl (com.redhat.ceylon.compiler.java.tools.CeyloncTaskImpl)3 PhasedUnit (com.redhat.ceylon.compiler.typechecker.context.PhasedUnit)3 LazyModule (com.redhat.ceylon.model.loader.model.LazyModule)3 Function (com.redhat.ceylon.model.typechecker.model.Function)3 FunctionOrValue (com.redhat.ceylon.model.typechecker.model.FunctionOrValue)3 Type (com.redhat.ceylon.model.typechecker.model.Type)3