use of org.eclipse.ceylon.model.typechecker.model.Module in project ceylon by eclipse.
the class RuntimeModelLoader method findModuleForClassMirror.
@Override
public Module findModuleForClassMirror(ClassMirror classMirror) {
Class<?> klass = ((ReflectionClass) classMirror).klass;
Module ret = findModuleForClass(klass);
if (ret == null)
throw new ModelResolutionException("Could not find module for class " + klass);
return ret;
}
use of org.eclipse.ceylon.model.typechecker.model.Module in project ceylon by eclipse.
the class TypeParser method decodeType.
public Type decodeType(String type, Scope scope, Module moduleScope, Unit unit) {
// save the previous state (this method is reentrant)
char[] oldType = lexer.type;
int oldIndex = lexer.index;
int oldMark = lexer.mark;
Scope oldScope = this.scope;
Module oldModuleScope = this.moduleScope;
Unit oldUnit = this.unit;
try {
// setup the new state
lexer.setup(type);
this.scope = scope;
this.moduleScope = moduleScope;
this.unit = unit;
// do the parsing
Type ret = parseType();
if (!lexer.lookingAt(TypeLexer.EOT))
throw new TypeParserException("Junk lexemes remaining: " + lexer.eatTokenString());
return ret;
} finally {
// restore the previous state
lexer.type = oldType;
lexer.index = oldIndex;
lexer.mark = oldMark;
this.scope = oldScope;
this.moduleScope = oldModuleScope;
this.unit = oldUnit;
}
}
use of org.eclipse.ceylon.model.typechecker.model.Module in project ceylon by eclipse.
the class ReflectionModuleManager method initCoreModules.
@Override
public void initCoreModules(Modules modules) {
super.initCoreModules(modules);
// FIXME: this should go away somewhere else, but we need it to be set otherwise
// when we load the module from compiled sources, ModuleManager.getOrCreateModule() will not
// return the language module because its version is null
Module languageModule = modules.getLanguageModule();
languageModule.setVersion(Versions.CEYLON_VERSION_NUMBER);
}
use of org.eclipse.ceylon.model.typechecker.model.Module in project ceylon by eclipse.
the class ReflectionModuleManager method createModule.
@Override
protected Module createModule(List<String> moduleName, String version) {
Module module;
if (isModuleLoadedFromSource(JvmBackendUtil.getName(moduleName)))
module = new Module();
else
module = new ReflectionModule(this);
module.setName(moduleName);
module.setVersion(version);
if (module instanceof ReflectionModule)
setupIfJDKModule((LazyModule) module);
return module;
}
use of org.eclipse.ceylon.model.typechecker.model.Module in project ceylon by eclipse.
the class LazyModule method getPackage.
@Override
public Package getPackage(String name) {
// try here first
Package pkg = null;
// unless we're the default module, in which case we have to check this at the end,
// since every package can be part of the default module
boolean defaultModule = isDefaultModule();
if (!defaultModule) {
pkg = findPackageInModule(this, name);
if (pkg != null)
return loadPackage(pkg);
}
// then try in dependencies
Set<Module> visited = new HashSet<Module>();
for (ModuleImport dependency : getImports()) {
// we don't have to worry about the default module here since we can't depend on it
pkg = findPackageInImport(name, dependency, visited);
if (pkg != null)
return loadPackage(pkg);
}
AbstractModelLoader modelLoader = getModelLoader();
JdkProvider jdkProvider = modelLoader.getJdkProvider();
// so we pretend the JDK imports the language module
if (jdkProvider != null && jdkProvider.isJDKModule(getNameAsString())) {
Module languageModule = getModelLoader().getLanguageModule();
if (languageModule instanceof LazyModule) {
pkg = findPackageInModule((LazyModule) languageModule, name);
if (pkg != null)
return loadPackage(pkg);
}
}
// work and appear to come from there
if (jdkProvider.isJDKPackage(name)) {
return null;
}
// do the lookup of the default module last
if (defaultModule)
pkg = modelLoader.findExistingPackage(this, name);
return pkg;
}
Aggregations