use of org.eclipse.ceylon.compiler.java.codegen.CeylonCompilationUnit in project ceylon by eclipse.
the class CeylonModelLoader method setupSourceFileObjects.
public static void setupSourceFileObjects(java.util.List<?> treeHolders, final ClassReader reader, final Names names) {
for (Object treeHolder : treeHolders) {
if (!(treeHolder instanceof CeylonCompilationUnit)) {
continue;
}
final CeylonCompilationUnit tree = (CeylonCompilationUnit) treeHolder;
CompilationUnit ceylonTree = tree.ceylonTree;
final String pkgName = tree.getPackageName() != null ? Util.quoteJavaKeywords(tree.getPackageName().toString()) : "";
ceylonTree.visit(new SourceDeclarationVisitor() {
@Override
public void loadFromSource(Declaration decl) {
if (!checkNative(decl))
return;
String fqn = Naming.toplevelClassName(pkgName, decl);
try {
reader.enterClass(names.fromString(fqn), tree.getSourceFile());
if (Decl.isAnnotationClassNoModel(decl)) {
String annotationName = Naming.suffixName(Suffix.$annotation$, fqn);
reader.enterClass(names.fromString(annotationName), tree.getSourceFile());
if (Decl.isSequencedAnnotationClassNoModel((Tree.AnyClass) decl)) {
String annotationsName = Naming.suffixName(Suffix.$annotations$, fqn);
reader.enterClass(names.fromString(annotationsName), tree.getSourceFile());
}
}
} catch (AssertionError error) {
// this happens when we have already registered a source file for this decl, hopefully the typechecker
// will catch this and log an error
}
}
@Override
public void loadFromSource(ModuleDescriptor that) {
try {
reader.enterClass(names.fromString(pkgName + "." + Naming.MODULE_DESCRIPTOR_CLASS_NAME), tree.getSourceFile());
} catch (AssertionError error) {
// this happens when we have already registered a source file for this decl, hopefully the typechecker
// will catch this and log an error
}
}
@Override
public void loadFromSource(PackageDescriptor that) {
try {
reader.enterClass(names.fromString(pkgName + "." + Naming.PACKAGE_DESCRIPTOR_CLASS_NAME), tree.getSourceFile());
} catch (AssertionError error) {
// this happens when we have already registered a source file for this decl, hopefully the typechecker
// will catch this and log an error
}
}
});
}
}
Aggregations