Search in sources :

Example 1 with OverridesRuntimeResolver

use of org.eclipse.ceylon.cmr.api.OverridesRuntimeResolver in project ceylon by eclipse.

the class Main method setup.

/**
 * Sets up the Ceylon metamodel by adding the specified module to it. This does not run any Ceylon code,
 * nor does it reset the metamodel first. You can repeatedly invoke this method to add new Ceylon modules
 * to the metamodel.
 *
 * @param module the module name to load.
 * @param version the version to load. Ignored if the module is the default module.
 */
public void setup(String module, String version) {
    Overrides parsedOverrides = Overrides.getDistOverrides();
    if (overrides != null) {
        try {
            parsedOverrides = parsedOverrides.append(overrides);
        } catch (RuntimeException e) {
            throw e;
        } catch (Exception e) {
            throw new RuntimeException(e);
        }
    }
    Metamodel.resetModuleManager(new OverridesRuntimeResolver(parsedOverrides));
    if (moduleClassLoader == null)
        setupModuleClassLoader(module);
    if (classPath == null) {
        classPath = new ClassPath(parsedOverrides);
        visited = new HashSet<ClassPath.Module>();
        registerInMetamodel("ceylon.language", Versions.CEYLON_VERSION_NUMBER, false);
        registerInMetamodel("org.eclipse.ceylon.common", Versions.CEYLON_VERSION_NUMBER, false);
        registerInMetamodel("org.eclipse.ceylon.model", Versions.CEYLON_VERSION_NUMBER, false);
    }
    if (module.equals(org.eclipse.ceylon.model.typechecker.model.Module.DEFAULT_MODULE_NAME))
        version = null;
    registerInMetamodel(module, version, false);
}
Also used : Overrides(org.eclipse.ceylon.cmr.api.Overrides) ArtifactOverrides(org.eclipse.ceylon.cmr.api.ArtifactOverrides) Java9Module(org.eclipse.ceylon.model.loader.Java9ModuleReader.Java9Module) InvocationTargetException(java.lang.reflect.InvocationTargetException) RepositoryException(org.eclipse.ceylon.model.cmr.RepositoryException) IOException(java.io.IOException) ConstantPoolException(org.eclipse.ceylon.langtools.classfile.ConstantPoolException) OverridesRuntimeResolver(org.eclipse.ceylon.cmr.api.OverridesRuntimeResolver)

Aggregations

IOException (java.io.IOException)1 InvocationTargetException (java.lang.reflect.InvocationTargetException)1 ArtifactOverrides (org.eclipse.ceylon.cmr.api.ArtifactOverrides)1 Overrides (org.eclipse.ceylon.cmr.api.Overrides)1 OverridesRuntimeResolver (org.eclipse.ceylon.cmr.api.OverridesRuntimeResolver)1 ConstantPoolException (org.eclipse.ceylon.langtools.classfile.ConstantPoolException)1 RepositoryException (org.eclipse.ceylon.model.cmr.RepositoryException)1 Java9Module (org.eclipse.ceylon.model.loader.Java9ModuleReader.Java9Module)1