Search in sources :

Example 1 with LazyModule

use of org.eclipse.ceylon.model.loader.model.LazyModule in project ceylon by eclipse.

the class PhasedUnitsModelLoader method addModuleToClassPath.

@Override
public void addModuleToClassPath(final Module module, ArtifactResult artifact) {
    // don't add the same module more than once
    if (artifact == null || !modulesAddedToClassPath.add(module))
        return;
    File file = artifact.artifact();
    // do not load classes from it if it's the language module, since it's already in our ClassLoader and
    // that would create multiple instances of the same class
    classLoader.addJar(artifact, module, module == modules.getLanguageModule());
    log.debug("Adding jar to classpath: " + file);
    if (module instanceof LazyModule) {
        ((LazyModule) module).loadPackageList(artifact);
    }
}
Also used : File(java.io.File) LazyModule(org.eclipse.ceylon.model.loader.model.LazyModule)

Example 2 with LazyModule

use of org.eclipse.ceylon.model.loader.model.LazyModule in project ceylon by eclipse.

the class PhasedUnitsModuleManager method createModule.

@Override
protected Module createModule(List<String> moduleName, String version) {
    String name = org.eclipse.ceylon.compiler.java.util.Util.getName(moduleName);
    // never create a reflection module for ceylon.language when we're documenting it
    Module module;
    if (name.equals(AbstractModelLoader.CEYLON_LANGUAGE) && isModuleLoadedFromSource(AbstractModelLoader.CEYLON_LANGUAGE))
        module = new Module();
    else
        module = new ReflectionModule(this);
    module.setName(moduleName);
    module.setVersion(version);
    if (module instanceof ReflectionModule)
        setupIfJDKModule((LazyModule) module);
    return module;
}
Also used : ReflectionModule(org.eclipse.ceylon.model.loader.impl.reflect.model.ReflectionModule) LazyModule(org.eclipse.ceylon.model.loader.model.LazyModule) ReflectionModule(org.eclipse.ceylon.model.loader.impl.reflect.model.ReflectionModule) Module(org.eclipse.ceylon.model.typechecker.model.Module) LazyModule(org.eclipse.ceylon.model.loader.model.LazyModule)

Example 3 with LazyModule

use of org.eclipse.ceylon.model.loader.model.LazyModule in project ceylon by eclipse.

the class LazyModuleSourceMapper method resolveModule.

@Override
public void resolveModule(ArtifactResult artifact, Module module, ModuleImport moduleImport, LinkedList<Module> dependencyTree, List<PhasedUnits> phasedUnitsOfDependencies, boolean forCompiledModule) {
    String moduleName = module.getNameAsString();
    LazyModuleManager moduleManager = getModuleManager();
    boolean moduleLoadedFromSource = moduleManager.isModuleLoadedFromSource(moduleName);
    boolean isLanguageModule = module == module.getLanguageModule();
    AbstractModelLoader modelLoader = moduleManager.getModelLoader();
    if (modelLoader.getJdkProviderModule() == module) {
        modelLoader.setupAlternateJdk(module, artifact);
    }
    // module in question will be in the classpath
    if (moduleLoadedFromSource || forCompiledModule) {
        if (shouldAbortOnDuplicateModule(module, moduleName, modelLoader, dependencyTree))
            return;
    }
    if (moduleLoadedFromSource) {
        super.resolveModule(artifact, module, moduleImport, dependencyTree, phasedUnitsOfDependencies, forCompiledModule);
    } else if (forCompiledModule || isLanguageModule || moduleManager.shouldLoadTransitiveDependencies()) {
        // we only add stuff to the classpath and load the modules if we need them to compile our modules
        // To be able to load it from the corresponding archive
        modelLoader.addModuleToClassPath(module, artifact);
        LazyModule lazyModule = (LazyModule) module;
        if (!module.isDefaultModule()) {
            if (artifact.groupId() != null)
                module.setGroupId(artifact.groupId());
            if (artifact.artifactId() != null)
                module.setArtifactId(artifact.artifactId());
            if (artifact.classifier() != null)
                module.setClassifier(artifact.classifier());
            if (!modelLoader.loadCompiledModule(module)) {
                setupJavaModule(moduleImport, lazyModule, modelLoader, moduleManager, artifact);
            } else {
                setupCeylonModule(moduleImport, lazyModule, modelLoader, moduleManager, artifact, dependencyTree);
            }
        }
        // module is now available
        module.setAvailable(true);
    }
}
Also used : AbstractModelLoader(org.eclipse.ceylon.model.loader.AbstractModelLoader) LazyModuleManager(org.eclipse.ceylon.model.loader.model.LazyModuleManager) LazyModule(org.eclipse.ceylon.model.loader.model.LazyModule)

Example 4 with LazyModule

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

Example 5 with LazyModule

use of org.eclipse.ceylon.model.loader.model.LazyModule in project ceylon by eclipse.

the class RuntimeModuleManager method createModule.

@Override
protected Module createModule(List<String> moduleName, String version) {
    Module module;
    module = new ReflectionModule(this);
    module.setName(moduleName);
    module.setVersion(version);
    if (module instanceof ReflectionModule)
        setupIfJDKModule((LazyModule) module);
    return module;
}
Also used : ReflectionModule(org.eclipse.ceylon.model.loader.impl.reflect.model.ReflectionModule) LazyModule(org.eclipse.ceylon.model.loader.model.LazyModule) ReflectionModule(org.eclipse.ceylon.model.loader.impl.reflect.model.ReflectionModule) Module(org.eclipse.ceylon.model.typechecker.model.Module) LazyModule(org.eclipse.ceylon.model.loader.model.LazyModule)

Aggregations

LazyModule (org.eclipse.ceylon.model.loader.model.LazyModule)10 Module (org.eclipse.ceylon.model.typechecker.model.Module)7 ReflectionModule (org.eclipse.ceylon.model.loader.impl.reflect.model.ReflectionModule)3 File (java.io.File)2 ArrayList (java.util.ArrayList)2 ModuleImport (org.eclipse.ceylon.model.typechecker.model.ModuleImport)2 IOException (java.io.IOException)1 LinkedList (java.util.LinkedList)1 List (java.util.List)1 InvalidArchiveException (org.eclipse.ceylon.cmr.impl.InvalidArchiveException)1 Backends (org.eclipse.ceylon.common.Backends)1 RuntimeModelLoader (org.eclipse.ceylon.compiler.java.runtime.model.RuntimeModelLoader)1 ArtifactResult (org.eclipse.ceylon.model.cmr.ArtifactResult)1 AbstractModelLoader (org.eclipse.ceylon.model.loader.AbstractModelLoader)1 AnnotationMirror (org.eclipse.ceylon.model.loader.mirror.AnnotationMirror)1 ClassMirror (org.eclipse.ceylon.model.loader.mirror.ClassMirror)1 LazyModuleManager (org.eclipse.ceylon.model.loader.model.LazyModuleManager)1 ParameterList (org.eclipse.ceylon.model.typechecker.model.ParameterList)1 Unit (org.eclipse.ceylon.model.typechecker.model.Unit)1