Search in sources :

Example 61 with Module

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;
}
Also used : ModelResolutionException(org.eclipse.ceylon.model.loader.ModelResolutionException) ReflectionClass(org.eclipse.ceylon.model.loader.impl.reflect.mirror.ReflectionClass) LazyModule(org.eclipse.ceylon.model.loader.model.LazyModule) Module(org.eclipse.ceylon.model.typechecker.model.Module)

Example 62 with Module

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;
    }
}
Also used : Type(org.eclipse.ceylon.model.typechecker.model.Type) Scope(org.eclipse.ceylon.model.typechecker.model.Scope) Module(org.eclipse.ceylon.model.typechecker.model.Module) Unit(org.eclipse.ceylon.model.typechecker.model.Unit)

Example 63 with Module

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

Example 64 with Module

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;
}
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 65 with 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;
}
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)

Aggregations

Module (org.eclipse.ceylon.model.typechecker.model.Module)113 LazyModule (org.eclipse.ceylon.model.loader.model.LazyModule)37 Package (org.eclipse.ceylon.model.typechecker.model.Package)26 ModuleImport (org.eclipse.ceylon.model.typechecker.model.ModuleImport)25 Declaration (org.eclipse.ceylon.model.typechecker.model.Declaration)20 TypeDeclaration (org.eclipse.ceylon.model.typechecker.model.TypeDeclaration)19 ArrayList (java.util.ArrayList)18 TypedDeclaration (org.eclipse.ceylon.model.typechecker.model.TypedDeclaration)16 File (java.io.File)14 Type (org.eclipse.ceylon.model.typechecker.model.Type)14 HashMap (java.util.HashMap)9 HashSet (java.util.HashSet)9 FunctionalInterfaceType (org.eclipse.ceylon.model.loader.mirror.FunctionalInterfaceType)9 UnknownType (org.eclipse.ceylon.model.typechecker.model.UnknownType)9 Test (org.junit.Test)9 Value (org.eclipse.ceylon.model.typechecker.model.Value)8 LinkedList (java.util.LinkedList)7 List (java.util.List)7 Backends (org.eclipse.ceylon.common.Backends)7 ClassMirror (org.eclipse.ceylon.model.loader.mirror.ClassMirror)7