Search in sources :

Example 1 with LazyPackage

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

the class Metamodel method getJavaClass.

public static java.lang.Class<?> getJavaClass(org.eclipse.ceylon.model.typechecker.model.Package pkg) {
    String className = ((LazyPackage) pkg).getNameAsString() + "." + NamingBase.PACKAGE_DESCRIPTOR_CLASS_NAME;
    ReflectionClass classMirror = (ReflectionClass) moduleManager.getModelLoader().lookupClassMirror(pkg.getModule(), className);
    return classMirror != null ? classMirror.klass : null;
}
Also used : LazyPackage(org.eclipse.ceylon.model.loader.model.LazyPackage) ReflectionClass(org.eclipse.ceylon.model.loader.impl.reflect.mirror.ReflectionClass)

Example 2 with LazyPackage

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

the class RuntimeModuleManager method createPackage.

@Override
public Package createPackage(String pkgName, Module module) {
    final Package pkg = new LazyPackage(getModelLoader());
    List<String> name = pkgName.isEmpty() ? Collections.<String>emptyList() : splitModuleName(pkgName);
    pkg.setName(name);
    if (module != null) {
        module.getPackages().add(pkg);
        pkg.setModule(module);
    }
    return pkg;
}
Also used : LazyPackage(org.eclipse.ceylon.model.loader.model.LazyPackage) LazyPackage(org.eclipse.ceylon.model.loader.model.LazyPackage) Package(org.eclipse.ceylon.model.typechecker.model.Package)

Example 3 with LazyPackage

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

the class AbstractModelLoader method convertToDeclaration.

private Declaration convertToDeclaration(Module module, Declaration container, ClassMirror classMirror, DeclarationType declarationType) {
    // find its package
    String pkgName = getPackageNameForQualifiedClassName(classMirror);
    if (pkgName.equals("java.lang")) {
        module = getJDKBaseModule();
    }
    Declaration decl = findCachedDeclaration(module, container, classMirror, declarationType);
    if (decl != null) {
        return decl;
    }
    // avoid ignored classes
    if (classMirror.getAnnotation(CEYLON_IGNORE_ANNOTATION) != null)
        return null;
    // avoid local interfaces that were pulled to the toplevel if required
    if (classMirror.getAnnotation(CEYLON_LOCAL_CONTAINER_ANNOTATION) != null && !needsLocalDeclarations())
        return null;
    // avoid Ceylon annotations
    if (classMirror.getAnnotation(CEYLON_CEYLON_ANNOTATION) != null && classMirror.isAnnotationType())
        return null;
    // avoid module and package descriptors too
    if (classMirror.getAnnotation(CEYLON_MODULE_ANNOTATION) != null || classMirror.getAnnotation(CEYLON_PACKAGE_ANNOTATION) != null)
        return null;
    List<Declaration> decls = new ArrayList<Declaration>();
    LazyPackage pkg = findOrCreatePackage(module, pkgName);
    decl = createDeclaration(container, classMirror, declarationType, decls);
    cacheDeclaration(module, container, classMirror, declarationType, decl, decls);
    // find/make its Unit
    Unit unit = getCompiledUnit(pkg, classMirror);
    // set all the containers
    for (Declaration d : decls) {
        // add it to its Unit
        d.setUnit(unit);
        unit.addDeclaration(d);
        setContainer(classMirror, d, pkg);
    }
    return decl;
}
Also used : LazyPackage(org.eclipse.ceylon.model.loader.model.LazyPackage) ArrayList(java.util.ArrayList) TypedDeclaration(org.eclipse.ceylon.model.typechecker.model.TypedDeclaration) TypeDeclaration(org.eclipse.ceylon.model.typechecker.model.TypeDeclaration) Declaration(org.eclipse.ceylon.model.typechecker.model.Declaration) Unit(org.eclipse.ceylon.model.typechecker.model.Unit)

Example 4 with LazyPackage

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

the class AbstractModelLoader method getUnitForModule.

private Unit getUnitForModule(Module module) {
    List<Package> packages = module.getPackages();
    if (packages.isEmpty()) {
        System.err.println("No package for module " + module.getNameAsString());
        return null;
    }
    Package pkg = packages.get(0);
    if (pkg instanceof LazyPackage == false) {
        System.err.println("No lazy package for module " + module.getNameAsString());
        return null;
    }
    Unit unit = getCompiledUnit((LazyPackage) pkg, null);
    if (unit == null) {
        System.err.println("No unit for module " + module.getNameAsString());
        return null;
    }
    return unit;
}
Also used : LazyPackage(org.eclipse.ceylon.model.loader.model.LazyPackage) LazyPackage(org.eclipse.ceylon.model.loader.model.LazyPackage) Package(org.eclipse.ceylon.model.typechecker.model.Package) Unit(org.eclipse.ceylon.model.typechecker.model.Unit)

Example 5 with LazyPackage

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

the class PhasedUnitsModuleManager method createPackage.

@Override
public Package createPackage(String pkgName, Module module) {
    // never create a lazy package for ceylon.language when we're documenting it
    if ((pkgName.equals(AbstractModelLoader.CEYLON_LANGUAGE) || pkgName.startsWith(AbstractModelLoader.CEYLON_LANGUAGE + ".")) && isModuleLoadedFromSource(AbstractModelLoader.CEYLON_LANGUAGE))
        return super.createPackage(pkgName, module);
    final Package pkg = new LazyPackage(getModelLoader());
    List<String> name = pkgName.isEmpty() ? Collections.<String>emptyList() : splitModuleName(pkgName);
    pkg.setName(name);
    if (module != null) {
        module.getPackages().add(pkg);
        pkg.setModule(module);
    }
    return pkg;
}
Also used : LazyPackage(org.eclipse.ceylon.model.loader.model.LazyPackage) LazyPackage(org.eclipse.ceylon.model.loader.model.LazyPackage) Package(org.eclipse.ceylon.model.typechecker.model.Package)

Aggregations

LazyPackage (org.eclipse.ceylon.model.loader.model.LazyPackage)5 Package (org.eclipse.ceylon.model.typechecker.model.Package)3 Unit (org.eclipse.ceylon.model.typechecker.model.Unit)2 ArrayList (java.util.ArrayList)1 ReflectionClass (org.eclipse.ceylon.model.loader.impl.reflect.mirror.ReflectionClass)1 Declaration (org.eclipse.ceylon.model.typechecker.model.Declaration)1 TypeDeclaration (org.eclipse.ceylon.model.typechecker.model.TypeDeclaration)1 TypedDeclaration (org.eclipse.ceylon.model.typechecker.model.TypedDeclaration)1