Search in sources :

Example 1 with JdkProvider

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
}
Also used : ModuleSpec(org.eclipse.ceylon.common.ModuleSpec) JdkProvider(org.eclipse.ceylon.model.loader.JdkProvider) ToolUsageError(org.eclipse.ceylon.common.tool.ToolUsageError) ArtifactResult(org.eclipse.ceylon.model.cmr.ArtifactResult)

Example 2 with JdkProvider

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);
}
Also used : JdkProvider(org.eclipse.ceylon.model.loader.JdkProvider) Package(org.eclipse.ceylon.model.typechecker.model.Package) LazyModule(org.eclipse.ceylon.model.loader.model.LazyModule) Module(org.eclipse.ceylon.model.typechecker.model.Module)

Example 3 with JdkProvider

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;
}
Also used : AbstractModelLoader(org.eclipse.ceylon.model.loader.AbstractModelLoader) JdkProvider(org.eclipse.ceylon.model.loader.JdkProvider) ModuleImport(org.eclipse.ceylon.model.typechecker.model.ModuleImport) Package(org.eclipse.ceylon.model.typechecker.model.Package) Module(org.eclipse.ceylon.model.typechecker.model.Module) HashSet(java.util.HashSet)

Example 4 with JdkProvider

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);
}
Also used : JdkProvider(org.eclipse.ceylon.model.loader.JdkProvider)

Aggregations

JdkProvider (org.eclipse.ceylon.model.loader.JdkProvider)4 Module (org.eclipse.ceylon.model.typechecker.model.Module)2 Package (org.eclipse.ceylon.model.typechecker.model.Package)2 HashSet (java.util.HashSet)1 ModuleSpec (org.eclipse.ceylon.common.ModuleSpec)1 ToolUsageError (org.eclipse.ceylon.common.tool.ToolUsageError)1 ArtifactResult (org.eclipse.ceylon.model.cmr.ArtifactResult)1 AbstractModelLoader (org.eclipse.ceylon.model.loader.AbstractModelLoader)1 LazyModule (org.eclipse.ceylon.model.loader.model.LazyModule)1 ModuleImport (org.eclipse.ceylon.model.typechecker.model.ModuleImport)1