use of org.eclipse.ceylon.compiler.java.tools.CeylonPhasedUnit in project ceylon by eclipse.
the class CeylonEnter method completeCeylonTrees.
public List<JCCompilationUnit> completeCeylonTrees(List<JCCompilationUnit> trees) {
// run the type checker
timer.startTask("Ceylon type checking");
typeCheck();
// some debugging
// printModules();
timer.startTask("Ceylon code generation");
/*
* Here we convert the ceylon tree to its javac AST, after the typechecker has run
*/
Timer nested = timer.nestedTimer();
if (sp != null) {
sp.clearLine();
sp.log("Generating AST");
}
int i = 1;
int size = countCeylonFiles(trees);
List<JCCompilationUnit> packageInfos = List.<JCCompilationUnit>nil();
for (JCCompilationUnit tree : trees) {
if (tree instanceof CeylonCompilationUnit) {
CeylonCompilationUnit ceylonTree = (CeylonCompilationUnit) tree;
gen.setMap(ceylonTree.lineMap);
CeylonPhasedUnit phasedUnit = (CeylonPhasedUnit) ceylonTree.phasedUnit;
if (sp != null) {
sp.clearLine();
sp.log("Generating [" + (i++) + "/" + size + "] ");
sp.log(phasedUnit.getPathRelativeToSrcDir());
}
gen.setFileObject(phasedUnit.getFileObject());
nested.startTask("Ceylon code generation for " + phasedUnit.getUnitFile().getName());
TaskEvent event = new TaskEvent(TaskEvent.Kind.PARSE, tree);
if (taskListener != null) {
taskListener.started(event);
}
ceylonTree.defs = gen.transformAfterTypeChecking(ceylonTree.ceylonTree).toList();
if (taskListener != null) {
taskListener.finished(event);
}
packageInfos = packageInfos.prependList(gen.transformPackageInfo(ceylonTree));
nested.endTask();
if (isVerbose("ast")) {
log.printRawLines(WriterKind.ERROR, "Model tree for " + tree.getSourceFile());
log.printRawLines(WriterKind.ERROR, ceylonTree.ceylonTree.toString());
}
if (isVerbose("code")) {
log.printRawLines(WriterKind.ERROR, "Java code generated for " + tree.getSourceFile());
log.printRawLines(WriterKind.ERROR, ceylonTree.toString());
}
}
}
if (isVerbose("code")) {
for (JCCompilationUnit packageInfo : packageInfos) {
log.printRawLines(WriterKind.ERROR, packageInfo.toString());
}
}
if (sp != null) {
sp.clearLine();
}
timer.startTask("Ceylon error generation");
printGeneratorErrors();
timer.endTask();
// write some stats
if (verbose)
modelLoader.printStats();
return packageInfos;
}
Aggregations