use of com.redhat.ceylon.model.typechecker.model.Module in project ceylon-compiler by ceylon.
the class LinkRenderer method isInCurrentModule.
private boolean isInCurrentModule(Object obj) {
Module objModule = null;
if (obj instanceof Module) {
objModule = (Module) obj;
} else if (obj instanceof Scope) {
objModule = getPackage((Scope) obj).getModule();
} else if (obj instanceof Element) {
objModule = getPackage(((Element) obj).getScope()).getModule();
}
Module currentModule = ceylonDocTool.getCurrentModule();
if (currentModule != null && objModule != null) {
return currentModule.equals(objModule);
}
return false;
}
use of com.redhat.ceylon.model.typechecker.model.Module in project ceylon-compiler by ceylon.
the class CeylonModelLoader method lookupNewClassMirror.
@Override
public ClassMirror lookupNewClassMirror(Module module, String name) {
synchronized (getLock()) {
ClassMirror classMirror = lookupNewClassMirror(name);
if (classMirror == null)
return null;
Module classMirrorModule = findModuleForClassMirror(classMirror);
if (classMirrorModule == null) {
logVerbose("Found a class mirror with no module");
return null;
}
// make sure it's imported
if (isImported(module, classMirrorModule)) {
return classMirror;
}
logVerbose("Found a class mirror that is not imported: " + name);
return null;
}
}
use of com.redhat.ceylon.model.typechecker.model.Module in project ceylon-compiler by ceylon.
the class AnnotationLoader method setPrimaryFromAnnotationInvocationAnnotation.
private void setPrimaryFromAnnotationInvocationAnnotation(AnnotationMirror annotationInvocationAnnotation, AnnotationInvocation ai) {
TypeMirror annotationType = (TypeMirror) annotationInvocationAnnotation.getValue(AbstractModelLoader.CEYLON_ANNOTATION_INSTANTIATION_ANNOTATION_MEMBER);
ClassMirror annotationClassMirror = annotationType.getDeclaredClass();
Module module = modelLoader.findModuleForClassMirror(annotationClassMirror);
if (annotationClassMirror.getAnnotation(AbstractModelLoader.CEYLON_METHOD_ANNOTATION) != null) {
ai.setPrimary((Function) modelLoader.convertToDeclaration(module, annotationClassMirror, DeclarationType.VALUE));
} else {
ai.setPrimary((Class) modelLoader.convertToDeclaration(module, annotationClassMirror, DeclarationType.TYPE));
}
}
use of com.redhat.ceylon.model.typechecker.model.Module in project ceylon-compiler by ceylon.
the class Resolve method loadClass.
/** Load toplevel or member class with given fully qualified name and
* verify that it is accessible.
* @param env The current environment.
* @param name The fully qualified name of the class to be loaded.
*/
Symbol loadClass(Env<AttrContext> env, Name name) {
try {
ClassSymbol c = reader.loadClass(name);
if (!isAccessible(env, c))
return new AccessError(c);
if (modelLoader != null && !sourceLanguage.isCeylon()) {
// special cases for java.lang.String and java.lang.Override which are fine
// See https://github.com/ceylon/ceylon-compiler/issues/2003
String nameString = name.toString();
if (!nameString.equals("java.lang.String") && !nameString.equals("java.lang.Override")) {
// Check if the class is accessible according to Ceylon's access rules
String scopePackageName = pkgSymbol(env.info.scope.owner).toString();
Package scopePackage = modelLoader.findPackage(scopePackageName);
// Don't check if we failed to find it
if (scopePackage != null) {
Module scopeModule = scopePackage.getModule();
// Ugly special case where we skip the test when we're compiling the language module itself
if (scopeModule != modelLoader.getLanguageModule()) {
String importedPackageName = modelLoader.getPackageNameForQualifiedClassName(pkgName(nameString), nameString);
Package importedPackage = scopeModule.getPackage(importedPackageName);
// Don't check if we failed to find it
if (importedPackage == null) {
return new ImportError(c, scopeModule);
}
}
}
}
}
return c;
} catch (ClassReader.BadClassFile err) {
throw err;
} catch (CompletionFailure ex) {
return typeNotFound;
}
}
use of com.redhat.ceylon.model.typechecker.model.Module in project ceylon-compiler by ceylon.
the class CeylonDocTool method getFolder.
private File getFolder(Package pkg) {
Module module = pkg.getModule();
List<String> unprefixedName;
if (module.isDefault())
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))
dir.mkdirs();
return dir;
}
Aggregations