use of com.redhat.ceylon.model.typechecker.model.Module in project ceylon-compiler by ceylon.
the class CeylonDocToolTests method makeModule.
private Module makeModule(String name, String version) {
Module module = new Module();
module.setName(Arrays.asList(name.split("\\.")));
module.setVersion(version);
return module;
}
use of com.redhat.ceylon.model.typechecker.model.Module in project ceylon-compiler by ceylon.
the class ModelLoaderTests method compareDeclarations.
private void compareDeclarations(final ModelComparison modelCompare, final Map<String, Declaration> decls, AbstractModelLoader modelLoader, Modules modules) {
Module testModule = getTestModule(modules);
for (Entry<String, Declaration> entry : decls.entrySet()) {
String quotedQualifiedName = entry.getKey().substring(1);
Declaration modelDeclaration = modelLoader.getDeclaration(testModule, quotedQualifiedName, Decl.isValue(entry.getValue()) ? DeclarationType.VALUE : DeclarationType.TYPE);
Assert.assertNotNull(modelDeclaration);
// make sure we loaded them exactly the same
modelCompare.compareDeclarations(entry.getValue().getQualifiedNameString(), entry.getValue(), modelDeclaration);
}
}
use of com.redhat.ceylon.model.typechecker.model.Module in project ceylon-compiler by ceylon.
the class LinkRenderer method canLinkToCeylonLanguageModule.
private boolean canLinkToCeylonLanguageModule() {
Module currentModule = ceylonDocTool.getCurrentModule();
if (currentModule.getNameAsString().equals(Module.LANGUAGE_MODULE_NAME)) {
return true;
} else {
Module languageModule = currentModule.getLanguageModule();
String languageModuleUrl = getExternalModuleUrl(languageModule);
return languageModuleUrl != null;
}
}
use of com.redhat.ceylon.model.typechecker.model.Module in project ceylon-compiler by ceylon.
the class LinkRenderer method processAnnotationParam.
private String processAnnotationParam(String text) {
if (text.equals("module")) {
Module mod = getCurrentModule();
if (mod != null) {
return processModule(mod);
}
}
if (text.startsWith("module ")) {
String modName = text.substring(7);
for (Module m : ceylonDocTool.getTypeChecker().getContext().getModules().getListOfModules()) {
if (m.getNameAsString().equals(modName)) {
return processModule(m);
}
}
}
if (text.equals("package")) {
Package pkg = getCurrentPackage();
if (pkg != null) {
return processPackage(pkg);
}
}
if (text.startsWith("package ")) {
String pkgName = text.substring(8);
for (Module m : ceylonDocTool.getTypeChecker().getContext().getModules().getListOfModules()) {
if (pkgName.startsWith(m.getNameAsString() + ".")) {
Package pkg = m.getPackage(pkgName);
if (pkg != null) {
return processPackage(pkg);
}
}
}
}
if (text.equals("interface")) {
Interface interf = getCurrentInterface();
if (interf != null) {
return processProducedType(interf.getType());
}
}
if (text.equals("class")) {
Class clazz = getCurrentClass();
if (clazz != null) {
return processProducedType(clazz.getType());
}
}
String declName;
Scope currentScope;
int pkgSeparatorIndex = text.indexOf("::");
if (pkgSeparatorIndex == -1) {
declName = text;
currentScope = resolveScope(scope);
} else {
String pkgName = text.substring(0, pkgSeparatorIndex);
declName = text.substring(pkgSeparatorIndex + 2, text.length());
currentScope = ceylonDocTool.getCurrentModule().getPackage(pkgName);
}
String[] declNames = declName.split("\\.");
Declaration currentDecl = null;
boolean isNested = false;
for (String currentDeclName : declNames) {
currentDecl = resolveDeclaration(currentScope, currentDeclName, isNested);
if (currentDecl != null) {
if (isValueWithTypeObject(currentDecl)) {
TypeDeclaration objectType = ((Value) currentDecl).getTypeDeclaration();
currentScope = objectType;
currentDecl = objectType;
} else {
currentScope = resolveScope(currentDecl);
}
isNested = true;
} else {
break;
}
}
// we can't link to parameters yet, unless they're toplevel
if (currentDecl != null && !isParameter(currentDecl)) {
if (currentDecl instanceof TypeDeclaration) {
return processProducedType(((TypeDeclaration) currentDecl).getType());
} else {
return processTypedDeclaration((TypedDeclaration) currentDecl);
}
} else {
return getUnresolvableLink(text);
}
}
use of com.redhat.ceylon.model.typechecker.model.Module in project ceylon-compiler by ceylon.
the class AbstractTransformer method isJavaEnumType.
boolean isJavaEnumType(Type type) {
Module jdkBaseModule = loader().getJDKBaseModule();
Package javaLang = jdkBaseModule.getPackage("java.lang");
TypeDeclaration enumDecl = (TypeDeclaration) javaLang.getDirectMember("Enum", null, false);
if (type.isClass() && type.getDeclaration().isAnonymous()) {
type = type.getExtendedType();
}
return type.isSubtypeOf(enumDecl.appliedType(null, Collections.singletonList(type)));
}
Aggregations