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;
}
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;
}
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");
}
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);
}
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);
}
}
}
Aggregations