use of com.redhat.ceylon.model.typechecker.model.Module in project ceylon-compiler by ceylon.
the class LinkRenderer method getExternalUrl.
private String getExternalUrl(Object to) {
String url = null;
if (to instanceof Module) {
url = getExternalModuleUrl((Module) to);
if (url != null) {
url += "index.html";
}
} else if (to instanceof Package) {
Package pkg = (Package) to;
url = getExternalModuleUrl(pkg.getModule());
if (url != null) {
url += buildPackageUrlPath(pkg);
url += "index.html";
}
} else if (to instanceof ClassOrInterface) {
ClassOrInterface klass = (ClassOrInterface) to;
Package pkg = getPackage(klass);
url = getExternalModuleUrl(pkg.getModule());
if (url != null) {
url += buildPackageUrlPath(pkg);
url += ceylonDocTool.getFileName(klass);
}
}
return url;
}
use of com.redhat.ceylon.model.typechecker.model.Module in project ceylon-compiler by ceylon.
the class CeylonDocTool method makeDoc.
private void makeDoc() throws IOException {
buildNodesMaps();
if (includeSourceCode) {
copySourceFiles();
}
collectSubclasses();
collectAnnotationConstructors();
// document every module
boolean documentedOne = false;
for (Module module : modules) {
if (isEmpty(module)) {
log.warning(CeylondMessages.msg("warn.moduleHasNoDeclaration", module.getNameAsString()));
} else {
documentedOne = true;
}
documentModule(module);
ArtifactContext artifactDocs = new ArtifactContext(module.getNameAsString(), module.getVersion(), ArtifactContext.DOCS);
// find all doc folders to copy
File outputDocFolder = getDocOutputFolder(module);
for (File docFolder : docFolders) {
File moduleDocFolder = new File(docFolder, join("/", module.getName()));
if (moduleDocFolder.exists()) {
FileUtil.copyAll(moduleDocFolder, outputDocFolder);
}
}
repositoryRemoveArtifact(outputRepositoryManager, artifactDocs);
repositoryPutArtifact(outputRepositoryManager, artifactDocs, getOutputFolder(module, null));
}
if (!documentedOne) {
log.warning(CeylondMessages.msg("warn.couldNotFindAnyDeclaration"));
}
if (browse) {
for (Module module : modules) {
if (isEmpty(module)) {
continue;
}
ArtifactContext docArtifact = new ArtifactContext(module.getNameAsString(), module.getVersion(), ArtifactContext.DOCS);
File docFolder = outputRepositoryManager.getArtifact(docArtifact);
File docIndex = new File(docFolder, "api/index.html");
if (docIndex.isFile()) {
try {
Desktop.getDesktop().browse(docIndex.toURI());
} catch (Exception e) {
log.error(CeylondMessages.msg("error.unableBrowseModuleDoc", docIndex.toURI()));
}
}
}
}
}
use of com.redhat.ceylon.model.typechecker.model.Module 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.Module in project ceylon-compiler by ceylon.
the class ForcedCaptureVisitor method isForcedCapture.
private boolean isForcedCapture(Tree.TypedDeclaration that) {
if (that.getAnnotationList() == null)
return false;
for (Annotation anno : that.getAnnotationList().getAnnotations()) {
Type type = anno.getTypeModel();
if (type == null || !type.isClassOrInterface())
continue;
TypeDeclaration decl = type.getDeclaration();
if (decl == null)
continue;
Module module = Decl.getModule(decl);
if (module == null)
continue;
if (module.getLanguageModule() == module)
continue;
// does not come from the language module
return true;
}
return false;
}
use of com.redhat.ceylon.model.typechecker.model.Module in project ceylon-compiler by ceylon.
the class LazyModuleSourceMapper method addModuleDependencyDefinition.
@Override
public void addModuleDependencyDefinition(ModuleImport moduleImport, Node definition) {
super.addModuleDependencyDefinition(moduleImport, definition);
Module module = moduleImport.getModule();
if (module == null)
return;
String nameAsString = module.getNameAsString();
String version = module.getVersion();
if (version != null && AbstractModelLoader.isJDKModule(nameAsString)) {
// Add a warning if we're using a lower JDK than the one we're running on
if (JDKUtils.jdk.isLowerVersion(version)) {
definition.addUsageWarning(Warning.importsOtherJdk, "You import JDK7, which is provided by the JDK8 you are running on, but" + " we cannot check that you are not using any JDK8-specific classes or methods. Upgrade your import to JDK8 if you depend on" + " JDK8 classes or methods.", Backend.Java);
}
}
}
Aggregations