use of org.eclipse.ceylon.model.typechecker.model.Module 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;
}
use of org.eclipse.ceylon.model.typechecker.model.Module in project ceylon by eclipse.
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 org.eclipse.ceylon.model.typechecker.model.Module in project ceylon by eclipse.
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(resourceFolder + "/" + to);
String result = relativize(module, fromUrl, toUrl).toString();
return result;
}
use of org.eclipse.ceylon.model.typechecker.model.Module in project ceylon by eclipse.
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 org.eclipse.ceylon.model.typechecker.model.Module in project ceylon by eclipse.
the class CeylonDocTool method getFolder.
private File getFolder(Package pkg) {
Module module = pkg.getModule();
List<String> unprefixedName;
if (module.isDefaultModule())
unprefixedName = pkg.getName();
else {
// remove the leading module name part
unprefixedName = pkg.getName().subList(module.getName().size(), pkg.getName().size());
}
File dir = new File(getApiOutputFolder(module), join("/", unprefixedName));
if (shouldInclude(module))
FileUtil.mkdirs(dir);
return dir;
}
Aggregations