Search in sources :

Example 16 with Package

use of com.redhat.ceylon.model.typechecker.model.Package 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 17 with Package

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

the class CeylonDocTool method getSrcUrl.

/**
 * Gets a URL for the source file containing the given thing
 * @param from Where the link is relative to
 * @param modPkgOrDecl e.g. Module, Package or Declaration
 * @return A (relative) URL, or null if no source file exists (e.g. for a
 * package or a module without a descriptor)
 * @throws IOException
 */
protected String getSrcUrl(Object from, Object modPkgOrDecl) throws IOException {
    URI fromUrl = getAbsoluteObjectUrl(from);
    Module module = getModule(from);
    String filename;
    File folder;
    if (modPkgOrDecl instanceof Element) {
        Unit unit = ((Element) modPkgOrDecl).getUnit();
        filename = unit.getFilename();
        folder = getFolder(unit.getPackage());
    } else if (modPkgOrDecl instanceof Package) {
        filename = "package.ceylon";
        folder = getFolder((Package) modPkgOrDecl);
    } else if (modPkgOrDecl instanceof Module) {
        Module moduleDecl = (Module) modPkgOrDecl;
        folder = getApiOutputFolder(moduleDecl);
        filename = Constants.MODULE_DESCRIPTOR;
    } else {
        throw new RuntimeException(CeylondMessages.msg("error.unexpected", modPkgOrDecl));
    }
    File srcFile = new File(folder, filename + ".html").getCanonicalFile();
    String result;
    if (srcFile.exists()) {
        URI url = srcFile.toURI();
        result = relativize(module, fromUrl, url).toString();
    } else {
        result = null;
    }
    return result;
}
Also used : Element(com.redhat.ceylon.model.typechecker.model.Element) Package(com.redhat.ceylon.model.typechecker.model.Package) Module(com.redhat.ceylon.model.typechecker.model.Module) CompilationUnit(com.redhat.ceylon.compiler.typechecker.tree.Tree.CompilationUnit) Unit(com.redhat.ceylon.model.typechecker.model.Unit) PhasedUnit(com.redhat.ceylon.compiler.typechecker.context.PhasedUnit) URI(java.net.URI) File(java.io.File)

Example 18 with Package

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

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).getUrl(), "Singleton object declaration", '\0', "Jump to singleton object declaration");
    }
    // sub-navbar-menu
    close("div");
    // sub-navbar
    close("div");
}
Also used : Package(com.redhat.ceylon.model.typechecker.model.Package)

Example 19 with Package

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

the class ImportScanner method visitTopLevel.

@Override
public void visitTopLevel(JCCompilationUnit that) {
    JCExpression pid = that.pid;
    String pkgName;
    if (pid instanceof JCFieldAccess) {
        pkgName = ((JCFieldAccess) pid).toString();
    } else if (pid instanceof JCIdent) {
        pkgName = ((JCIdent) pid).toString();
    } else {
        // default package
        pkgName = "";
    }
    Package thisPackage = modelLoader.findPackage(pkgName);
    if (thisPackage == null)
        // give up
        return;
    importingModule = thisPackage.getModule();
    // Ugly special case where we skip the test when we're compiling the language module itself
    if (importingModule == modelLoader.getLanguageModule())
        return;
    visit(that.defs);
}
Also used : JCIdent(com.sun.tools.javac.tree.JCTree.JCIdent) JCExpression(com.sun.tools.javac.tree.JCTree.JCExpression) JCFieldAccess(com.sun.tools.javac.tree.JCTree.JCFieldAccess) Package(com.redhat.ceylon.model.typechecker.model.Package)

Example 20 with Package

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

the class ImportScanner method importPackage.

private void importPackage(JCFieldAccess selected) {
    String importedPkg = selected.toString();
    if (importedPkg.isEmpty())
        return;
    Package importedPackage = importingModule.getPackage(importedPkg);
    if (importedPackage == null) {
        // try one level up to skip potential types
        if (selected.selected instanceof JCFieldAccess) {
            importPackage((JCFieldAccess) selected.selected);
        }
    }
}
Also used : JCFieldAccess(com.sun.tools.javac.tree.JCTree.JCFieldAccess) Package(com.redhat.ceylon.model.typechecker.model.Package)

Aggregations

Package (com.redhat.ceylon.model.typechecker.model.Package)47 TypeDeclaration (com.redhat.ceylon.model.typechecker.model.TypeDeclaration)18 Declaration (com.redhat.ceylon.model.typechecker.model.Declaration)17 Module (com.redhat.ceylon.model.typechecker.model.Module)16 Scope (com.redhat.ceylon.model.typechecker.model.Scope)16 TypedDeclaration (com.redhat.ceylon.model.typechecker.model.TypedDeclaration)14 ClassOrInterface (com.redhat.ceylon.model.typechecker.model.ClassOrInterface)11 ArrayList (java.util.ArrayList)10 Class (com.redhat.ceylon.model.typechecker.model.Class)8 Interface (com.redhat.ceylon.model.typechecker.model.Interface)7 TypeParameter (com.redhat.ceylon.model.typechecker.model.TypeParameter)6 Value (com.redhat.ceylon.model.typechecker.model.Value)6 PhasedUnit (com.redhat.ceylon.compiler.typechecker.context.PhasedUnit)5 Function (com.redhat.ceylon.model.typechecker.model.Function)5 FunctionOrValue (com.redhat.ceylon.model.typechecker.model.FunctionOrValue)5 Type (com.redhat.ceylon.model.typechecker.model.Type)4 JCNewClass (com.sun.tools.javac.tree.JCTree.JCNewClass)4 CeylonCompilationUnit (com.redhat.ceylon.compiler.java.codegen.CeylonCompilationUnit)3 Tree (com.redhat.ceylon.compiler.typechecker.tree.Tree)3 File (java.io.File)3