Refine search
try { reportProgress(Messages.compilation_beginningToCompile); beginToCompile(sourceUnits); } else { beginToCompile(sourceUnits); if (!lastRound) { processAnnotations(); backupAptProblems(); reset(); System.arraycopy(e.newAnnotationProcessorUnits, 0, combinedUnits, originalLength, newProcessedLength); this.annotationProcessorStartIndex = originalLength; compile(combinedUnits, e.isLastRound); return; restoreAptProblems(); processCompiledUnits(0, lastRound); } catch (AbortCompilation e) { this.handleInternalException(e, null);
/** * Creates and returns a compiler for this evaluator. */ Compiler getCompiler(ICompilerRequestor compilerRequestor) { CompilerOptions compilerOptions = new CompilerOptions(this.options); compilerOptions.performMethodsFullRecovery = true; compilerOptions.performStatementsRecovery = true; return new Compiler( this.environment, DefaultErrorHandlingPolicies.exitAfterAllProblems(), compilerOptions, compilerRequestor, this.problemFactory); } /**
@Override protected synchronized void addCompilationUnit(ICompilationUnit sourceUnit, CompilationUnitDeclaration parsedUnit) { if (sourceUnit instanceof SourcepathDirectory.ClasspathCompilationUnit) { // this compilation unit represents dependency .java file // it is used to resolve type references and must not be processed otherwise return; } // growth of the internal unitsToProcess array is handled via multiplication of it's current size, // so if size is 0, we should just go ahead and handle it here. if (this.unitsToProcess.length == 0) { // start out with a size other than 0, so that it can be doubled safely by the super method. // starting with 4 to prevent the first couple of doublings and corresponding copying. this.unitsToProcess = new CompilationUnitDeclaration[4]; this.unitsToProcess[0] = parsedUnit; // this tracks the units added, it must be incremented ever time a new type is added. this.totalUnits = 1; } else { super.addCompilationUnit(sourceUnit, parsedUnit); } }
public Compiler( INameEnvironment environment, IErrorHandlingPolicy policy, CompilerOptions options, final ICompilerRequestor requestor, IProblemFactory problemFactory, PrintWriter out, CompilationProgress progress) { this.options = options; this.progress = progress; // wrap requestor in DebugRequestor if one is specified if(DebugRequestor == null) { this.requestor = requestor; } else { this.requestor = new ICompilerRequestor(){ public void acceptResult(CompilationResult result){ if (DebugRequestor.isActive()){ DebugRequestor.acceptDebugResult(result); } requestor.acceptResult(result); } }; } this.problemReporter = new ProblemReporter(policy, this.options, problemFactory); this.lookupEnvironment = new LookupEnvironment(this, this.options, this.problemReporter, environment); this.out = out == null ? new PrintWriter(System.out, true) : out; this.stats = new CompilerStats(); initializeParser(); }
try { if (this.options.verbose) { this.out.println( Messages.bind(Messages.compilation_request, new String[] { addCompilationUnit(sourceUnits[i], parsedUnit); ImportReference currentPackage = parsedUnit.currentPackage; if (currentPackage != null) {
if (unit.compilationResult != null && unit.compilationResult.hasBeenAccepted) continue; reportProgress(Messages.bind(Messages.compilation_processing, new String(unit.getFileName()))); try { if (this.options.verbose) this.out.println( Messages.bind(Messages.compilation_process, new String[] { new String(this.unitsToProcess[i].getFileName()) })); process(unit, i); } finally { if (this.annotationProcessorManager == null || shouldCleanup(i)) unit.cleanUp(); reportWorked(1, i); this.stats.lineCount += unit.compilationResult.lineSeparatorPositions.length; long acceptStart = System.currentTimeMillis(); reportWorked(1, acceptedCount++); this.stats.lineCount += unit.compilationResult.lineSeparatorPositions.length; this.requestor.acceptResult(unit.compilationResult.tagAsAccepted()); if (this.options.verbose) this.out.println( Messages.bind(Messages.compilation_done, new String[] {
reportProgress(Messages.compilation_beginningToCompile); beginToCompile(sourceUnits); } else { beginToCompile(sourceUnits); processAnnotations(); if (!this.options.generateClassFiles) { reset(); System.arraycopy(e.newAnnotationProcessorUnits, 0, combinedUnits, originalLength, newProcessedLength); this.annotationProcessorStartIndex = originalLength; compile(combinedUnits); return; reportProgress(Messages.bind(Messages.compilation_processing, new String(unit.getFileName()))); try { if (this.options.verbose) this.out.println( Messages.bind(Messages.compilation_process, new String[] { new String(this.unitsToProcess[i].getFileName()) })); process(unit, i); } finally {
@Override protected String compileUnits(final JRCompilationUnit[] units, String classpath, File tempDirFile) { final INameEnvironment env = getNameEnvironment(units); final IErrorHandlingPolicy policy = DefaultErrorHandlingPolicies.proceedWithAllProblems(); final CompilerOptions options = getJdtSettings(); final IProblemFactory problemFactory = new DefaultProblemFactory(Locale.getDefault()); final CompilerRequestor requestor = getCompilerRequestor(units); final Compiler compiler = new Compiler(env, policy, options, requestor, problemFactory); do { CompilationUnit[] compilationUnits = requestor.processCompilationUnits(); compiler.compile(compilationUnits); } while (requestor.hasMissingMethods()); requestor.processProblems(); return requestor.getFormattedProblems(); }
public void compile(ICompilationUnit[] sourceUnits) { compile(sourceUnits, false); } /**
private static Compiler newCompiler(ModuleAccumulatorEnvironment environment, IJavaProject javaProject) { Map<String, String> projectOptions = javaProject.getOptions(true); CompilerOptions compilerOptions = new CompilerOptions(projectOptions); compilerOptions.performMethodsFullRecovery = true; compilerOptions.performStatementsRecovery = true; ICompilerRequestor requestor = new ICompilerRequestor() { @Override public void acceptResult(CompilationResult result) { // Nothing to do here } }; Compiler newCompiler = new Compiler( environment, DefaultErrorHandlingPolicies.proceedWithAllProblems(), compilerOptions, requestor, ProblemFactory.getProblemFactory(Locale.getDefault())); return newCompiler; } public static String[] getReferencedModules(IJavaProject project) throws CoreException {
public byte[] compileWithAttributes(IModuleDescription module, Map<String,String> classFileAttributes) throws JavaModelException { IJavaProject javaProject = module.getJavaProject(); NameEnvironment nameEnvironment = new NameEnvironment(javaProject, CompilationGroup.MAIN); addModuleUpdates(module, nameEnvironment.moduleUpdater, classFileAttributes); ClasspathMultiDirectory sourceLocation = getSourceLocation(javaProject, nameEnvironment, module); IFile file = (IFile) module.getCompilationUnit().getCorrespondingResource(); ICompilationUnit[] sourceUnits = { new SourceFile(file, sourceLocation) }; BytecodeCollector collector = new BytecodeCollector(); Compiler newCompiler = new Compiler( nameEnvironment, DefaultErrorHandlingPolicies.exitOnFirstError(), new CompilerOptions(javaProject.getOptions(true)), collector, ProblemFactory.getProblemFactory(Locale.getDefault())); newCompiler.compile(sourceUnits); return collector.bytes; }
public CompilationInfo compile(final Map<String, CharSequence> sources) { final ICompilationUnit[] compilationUnits = getCompilationUnits(sources); final CompilerRequestor resultListener = new CompilerRequestor(classLoader); final Compiler compiler = new Compiler(classLoader, errorHandlingPolicy, options, resultListener, problemFactory); compiler.compile(compilationUnits); return new CompilationInfo(resultListener.results(), classLoader.classes(), classLoader); }
public void compile(Collection<Source> sources) { Timer timer = metric.startTimer("act:classload:compile:_all"); int len = sources.size(); ICompilationUnit[] compilationUnits = new ICompilationUnit[len]; int i = 0; for (Source source: sources) { compilationUnits[i++] = source.compilationUnit(); } IErrorHandlingPolicy policy = DefaultErrorHandlingPolicies.exitOnFirstError(); IProblemFactory problemFactory = new DefaultProblemFactory(Locale.ENGLISH); org.eclipse.jdt.internal.compiler.Compiler jdtCompiler = new Compiler( nameEnv, policy, compilerOptions, requestor, problemFactory) { @Override protected void handleInternalException(Throwable e, CompilationUnitDeclaration ud, CompilationResult result) { } }; jdtCompiler.compile(compilationUnits); timer.stop(); }
beginToCompile(new ICompilationUnit[] { sourceUnit }); return unit; } catch (AbortCompilation e) { this.handleInternalException(e, unit); return unit == null ? this.unitsToProcess[0] : unit; } catch (Error e) { this.handleInternalException(e, unit, null); throw e; // rethrow } catch (RuntimeException e) { this.handleInternalException(e, unit, null); throw e; // rethrow } finally {
@Override protected void handleInternalException( Throwable internalException, CompilationUnitDeclaration unit, CompilationResult result) { super.handleInternalException(internalException, unit, result); if (unit != null) { removeUnresolvedBindings(unit); } }
@Override public void reset() { if (KEEP_LOOKUP_ENVIRONMENT) { // Same as super.reset() in ECJ 4.4.2, but omits the following statement: // this.lookupEnvironment.reset(); // because we need the lookup environment to stick around even after the // parse phase is done: at that point we're going to use the parse trees // from java detectors which may need to resolve types this.parser.scanner.source = null; this.unitsToProcess = null; if (DebugRequestor != null) DebugRequestor.reset(); this.problemReporter.reset(); } else { super.reset(); } } }
public Compiler( INameEnvironment environment, IErrorHandlingPolicy policy, CompilerOptions options, final ICompilerRequestor requestor, IProblemFactory problemFactory, PrintWriter out, CompilationProgress progress) { this.options = options; this.progress = progress; // wrap requestor in DebugRequestor if one is specified if(DebugRequestor == null) { this.requestor = requestor; } else { this.requestor = new ICompilerRequestor(){ public void acceptResult(CompilationResult result){ if (DebugRequestor.isActive()){ DebugRequestor.acceptDebugResult(result); } requestor.acceptResult(result); } }; } this.problemReporter = new ProblemReporter(policy, this.options, problemFactory); this.lookupEnvironment = new LookupEnvironment(this, this.options, this.problemReporter, environment); this.out = out == null ? new PrintWriter(System.out, true) : out; this.stats = new CompilerStats(); initializeParser(); }
if (this.options.verbose) { String count = String.valueOf(this.totalUnits + 1); this.out.println( Messages.bind(Messages.compilation_request, new String[] { addCompilationUnit(sourceUnit, parsedUnit);
if (unit.compilationResult != null && unit.compilationResult.hasBeenAccepted) continue; reportProgress(Messages.bind(Messages.compilation_processing, new String(unit.getFileName()))); try { if (this.options.verbose) this.out.println( Messages.bind(Messages.compilation_process, new String[] { new String(this.unitsToProcess[i].getFileName()) })); process(unit, i); } finally { if (this.annotationProcessorManager == null || shouldCleanup(i)) unit.cleanUp(); reportWorked(1, i); this.stats.lineCount += unit.compilationResult.lineSeparatorPositions.length; long acceptStart = System.currentTimeMillis(); reportWorked(1, acceptedCount++); this.stats.lineCount += unit.compilationResult.lineSeparatorPositions.length; this.requestor.acceptResult(unit.compilationResult.tagAsAccepted()); if (this.options.verbose) this.out.println( Messages.bind(Messages.compilation_done, new String[] {
reportProgress(Messages.compilation_beginningToCompile); beginToCompile(sourceUnits); } else { beginToCompile(sourceUnits); processAnnotations(); if (!this.options.generateClassFiles) { reset(); System.arraycopy(e.newAnnotationProcessorUnits, 0, combinedUnits, originalLength, newProcessedLength); this.annotationProcessorStartIndex = originalLength; compile(combinedUnits); return; reportProgress(Messages.bind(Messages.compilation_processing, new String(unit.getFileName()))); try { if (this.options.verbose) this.out.println( Messages.bind(Messages.compilation_process, new String[] { new String(this.unitsToProcess[i].getFileName()) })); process(unit, i); } finally {