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;
}
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;
}
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;
}
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;
}
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;
}
Aggregations