protected void flow(Env<AttrContext> env, Queue<Env<AttrContext>> results) { if (env.toplevel.sourcefile instanceof CeylonFileObject) { try { sourceLanguage.push(Language.CEYLON); super.flow(env, results); return; } finally { sourceLanguage.pop(); } } super.flow(env, results); }
protected void desugar( final Env<AttrContext> env, Queue<Pair<Env<AttrContext>, JCClassDecl>> results) { if (env.toplevel.sourcefile instanceof CeylonFileObject) { try { sourceLanguage.push(Language.CEYLON); super.desugar(env, results); return; } finally { sourceLanguage.pop(); } } super.desugar(env, results); }
@Override public void initProcessAnnotations(Iterable<? extends Processor> processors) { java.util.List<String> aptModules = options.getMulti(Option.CEYLONAPT); if (aptModules != null) { CeyloncFileManager dfm = (CeyloncFileManager) fileManager; RepositoryManager repositoryManager = dfm.getRepositoryManager(); final Set<ModuleSpec> visited = new HashSet<>(); StatusPrinterAptProgressListener progressListener = null; if (sp != null) { progressListener = new StatusPrinterAptProgressListener(sp) { @Override protected long getNumberOfModulesResolved() { return visited.size(); } }; sp.clearLine(); sp.log("Starting APT resolving"); } for (String aptModule : aptModules) { ModuleSpec moduleSpec = ModuleSpec.parse(aptModule); addDependenciesToAptPath(repositoryManager, moduleSpec, visited, progressListener); } if (sp != null) { sp.clearLine(); sp.log("Done APT resolving"); } // we only run APT if asked explicitly with the --apt flag super.initProcessAnnotations(processors); } // else don't do anything, which will leave the "processAnnotations" field to false }
@Override public void generate( Queue<Pair<Env<AttrContext>, JCClassDecl>> queue, Queue<JavaFileObject> results) { timer.startTask("Generate"); super.generate(queue, results); timer.endTask(); }
@Override public void close(boolean disposeNames) { if (resourceFileObjects != null) { addResources(); resourceFileObjects = null; } super.close(disposeNames); }
@Override public void complete(ClassSymbol c) throws CompletionFailure { try { sourceLanguage.push(Language.JAVA); super.complete(c); } catch (RunTwiceException e) { hadRunTwiceException = true; throw new CompletionFailure(c, e.getLocalizedMessage()); } finally { sourceLanguage.pop(); } }
@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); } } }
@Override public void compile( List<JavaFileObject> fileObjects, List<String> classnames, Iterable<? extends Processor> processors) { // Now we first split the files into sources/modules and resources List<JavaFileObject> sourceFiles = List.nil(); List<JavaFileObject> resourceFiles = List.nil(); for (JavaFileObject fo : fileObjects) { if (isResource(fo)) { resourceFiles = resourceFiles.append(fo); } else { sourceFiles = sourceFiles.append(fo); } } this.resourceFileObjects = resourceFiles; // Add any module files for the resources (if needed) sourceFiles = addModuleDescriptors(sourceFiles, resourceFiles); // And then continue to the compilation of the source files super.compile(sourceFiles, classnames, processors); }