Search in sources :

Example 6 with CeylonCompilationUnit

use of com.redhat.ceylon.compiler.java.codegen.CeylonCompilationUnit in project ceylon-compiler by ceylon.

the class LanguageCompiler method loadCompiledModules.

private List<JCCompilationUnit> loadCompiledModules(List<JCCompilationUnit> trees, LinkedList<JCCompilationUnit> moduleTrees) {
    compilerDelegate.visitModules(phasedUnits);
    Modules modules = ceylonContext.getModules();
    // now make sure the phase units have their modules and packages set correctly
    for (PhasedUnit pu : phasedUnits.getPhasedUnits()) {
        Package pkg = pu.getPackage();
        loadModuleFromSource(pkg, modules, moduleTrees, trees);
    }
    // also make sure we have packages and modules set up for every Java file we compile
    for (JCCompilationUnit cu : trees) {
        // skip Ceylon CUs
        if (cu instanceof CeylonCompilationUnit)
            continue;
        String packageName = "";
        if (cu.pid != null)
            packageName = TreeInfo.fullName(cu.pid).toString();
        /*
             * Stef: see javadoc for findOrCreateModulelessPackage() for why this is here.
             */
        Package pkg = modelLoader.findOrCreateModulelessPackage(packageName);
        loadModuleFromSource(pkg, modules, moduleTrees, trees);
    }
    for (PhasedUnit phasedUnit : phasedUnits.getPhasedUnits()) {
        for (Tree.ModuleDescriptor modDescr : phasedUnit.getCompilationUnit().getModuleDescriptors()) {
            String name = phasedUnit.getPackage().getNameAsString();
            CeylonPhasedUnit cpu = (CeylonPhasedUnit) phasedUnit;
            CeylonFileObject cfo = (CeylonFileObject) cpu.getFileObject();
            moduleNamesToFileObjects.put(name, cfo);
        }
    }
    for (JCCompilationUnit moduleTree : moduleTrees) {
        trees = trees.append(moduleTree);
    }
    return trees;
}
Also used : JCCompilationUnit(com.sun.tools.javac.tree.JCTree.JCCompilationUnit) CeylonCompilationUnit(com.redhat.ceylon.compiler.java.codegen.CeylonCompilationUnit) ModuleDescriptor(com.redhat.ceylon.compiler.typechecker.tree.Tree.ModuleDescriptor) Modules(com.redhat.ceylon.model.typechecker.model.Modules) JCTree(com.sun.tools.javac.tree.JCTree) Tree(com.redhat.ceylon.compiler.typechecker.tree.Tree) Package(com.redhat.ceylon.model.typechecker.model.Package) CeylonFileObject(com.redhat.ceylon.compiler.java.codegen.CeylonFileObject) PhasedUnit(com.redhat.ceylon.compiler.typechecker.context.PhasedUnit)

Aggregations

CeylonCompilationUnit (com.redhat.ceylon.compiler.java.codegen.CeylonCompilationUnit)6 JCCompilationUnit (com.sun.tools.javac.tree.JCTree.JCCompilationUnit)4 PhasedUnit (com.redhat.ceylon.compiler.typechecker.context.PhasedUnit)2 ModuleDescriptor (com.redhat.ceylon.compiler.typechecker.tree.Tree.ModuleDescriptor)2 Package (com.redhat.ceylon.model.typechecker.model.Package)2 JavaFileObject (javax.tools.JavaFileObject)2 CeylonFileObject (com.redhat.ceylon.compiler.java.codegen.CeylonFileObject)1 CeylonPhasedUnit (com.redhat.ceylon.compiler.java.tools.CeylonPhasedUnit)1 Tree (com.redhat.ceylon.compiler.typechecker.tree.Tree)1 CompilationUnit (com.redhat.ceylon.compiler.typechecker.tree.Tree.CompilationUnit)1 Declaration (com.redhat.ceylon.compiler.typechecker.tree.Tree.Declaration)1 ImportModule (com.redhat.ceylon.compiler.typechecker.tree.Tree.ImportModule)1 PackageDescriptor (com.redhat.ceylon.compiler.typechecker.tree.Tree.PackageDescriptor)1 Timer (com.redhat.ceylon.model.loader.Timer)1 Module (com.redhat.ceylon.model.typechecker.model.Module)1 Modules (com.redhat.ceylon.model.typechecker.model.Modules)1 ModuleManager (com.redhat.ceylon.model.typechecker.util.ModuleManager)1 CompilationUnitTree (com.sun.source.tree.CompilationUnitTree)1 TaskEvent (com.sun.source.util.TaskEvent)1 JCTree (com.sun.tools.javac.tree.JCTree)1