use of org.eclipse.ceylon.model.loader.JdkProvider in project ceylon by eclipse.
the class ModuleLoadingTool method initialize.
@Override
public void initialize(CeylonTool mainTool) throws Exception {
super.initialize(mainTool);
loader = new ToolModuleLoader(this, getRepositoryManager(), getLoaderSuffixes());
if (jdkProviderModule != null) {
ModuleSpec moduleSpec = ModuleSpec.parse(jdkProviderModule);
if (!internalLoadModule(null, moduleSpec.getName(), moduleSpec.getVersion())) {
throw new ToolUsageError(Messages.msg(bundle, "jdk.provider.not.found", jdkProviderModule));
}
ArtifactResult result = loader.getModuleArtifact(moduleSpec.getName());
jdkProvider = new JdkProvider(moduleSpec.getName(), moduleSpec.getVersion(), null, result.artifact());
}
// else keep the JDK one
}
use of org.eclipse.ceylon.model.loader.JdkProvider in project ceylon by eclipse.
the class RuntimeModelLoader method loadStandardModules.
@Override
public void loadStandardModules() {
// set up the type factory and that's it: do not try to load the language module package before it's set up
// by Metamodel.loadModule
jdkProvider = new JdkProvider();
Module languageModule = findOrCreateModule(CEYLON_LANGUAGE, null);
addModuleToClassPath(languageModule, (ArtifactResult) null);
Package languagePackage = findOrCreatePackage(languageModule, CEYLON_LANGUAGE);
typeFactory.setPackage(languagePackage);
// make sure the jdk modules are loaded because those are not initialised by jboss modules nor the IDE Launcher
for (String jdkModule : JDKUtils.getJDKModuleNames()) findOrCreateModule(jdkModule, JDKUtils.jdk.version);
for (String jdkOracleModule : JDKUtils.getOracleJDKModuleNames()) findOrCreateModule(jdkOracleModule, JDKUtils.jdk.version);
}
use of org.eclipse.ceylon.model.loader.JdkProvider 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;
}
use of org.eclipse.ceylon.model.loader.JdkProvider in project ceylon by eclipse.
the class LazyModuleSourceMapper method attachErrorToDependencyDeclaration.
@Override
public void attachErrorToDependencyDeclaration(ModuleImport moduleImport, List<Module> dependencyTree, String error, boolean isError) {
// special case for the java modules, which we only get when using the wrong version
String name = moduleImport.getModule().getNameAsString();
JdkProvider jdkProvider = getJdkProvider();
if (jdkProvider != null && jdkProvider.isJDKModule(name)) {
error = "imported module '" + name + "' depends on JDK version '\"" + moduleImport.getModule().getVersion() + "\"' and compiler is using Java " + jdkProvider.getJDKVersion();
}
super.attachErrorToDependencyDeclaration(moduleImport, dependencyTree, error, isError);
}
Aggregations