Ejemplo n.º 1
0
 @Override
 public void initRound(JavaCompiler prev) {
   super.initRound(prev);
   // round compilers don't add module trees, it's already done by the first one
   addModuleTrees = false;
   PhasedUnits oldPUs = ((LanguageCompiler) prev).phasedUnits;
   ModuleManager moduleManager = phasedUnits.getModuleManager();
   ModuleSourceMapper moduleSourceMapper = phasedUnits.getModuleSourceMapper();
   for (PhasedUnit pu : oldPUs.getPhasedUnits()) {
     if (pu instanceof CeylonPhasedUnit) {
       CeylonPhasedUnit cpu = (CeylonPhasedUnit) pu;
       // FIXME: this is bad in many ways
       String pkgName;
       try {
         pkgName = getPackage(((CeylonPhasedUnit) pu).getFileObject());
       } catch (IOException e) {
         // TODO Auto-generated catch block
         e.printStackTrace();
         continue;
       }
       // make a Package with no module yet, we will resolve them later
       /*
        * Stef: see javadoc for findOrCreateModulelessPackage() for why this is here.
        */
       com.redhat.ceylon.model.typechecker.model.Package p =
           modelLoader.findOrCreateModulelessPackage(pkgName == null ? "" : pkgName);
       CeylonPhasedUnit newPu =
           new CeylonPhasedUnit(
               pu.getUnitFile(),
               pu.getSrcDir(),
               pu.getCompilationUnit(),
               p,
               moduleManager,
               moduleSourceMapper,
               ceylonContext,
               cpu.getFileObject(),
               cpu.getLineMap());
       phasedUnits.addPhasedUnit(pu.getUnitFile(), newPu);
     } else {
       phasedUnits.addPhasedUnit(pu.getUnitFile(), pu);
     }
   }
 }