本文整理了Java中org.eclipse.jdt.internal.compiler.Compiler
类的一些代码示例,展示了Compiler
类的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Compiler
类的具体详情如下:
包路径:org.eclipse.jdt.internal.compiler.Compiler
类名称:Compiler
暂无
代码示例来源:origin: org.eclipse.jdt.core.compiler/ecj
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);
代码示例来源:origin: org.eclipse.jdt/org.eclipse.jdt.core
/**
* 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);
}
/**
代码示例来源:origin: io.takari.maven.plugins/takari-lifecycle-plugin
@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);
}
}
代码示例来源:origin: org.eclipse.tycho/org.eclipse.jdt.core
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();
}
代码示例来源:origin: org.eclipse.jdt.core.compiler/ecj
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) {
代码示例来源:origin: org.eclipse.jdt.core.compiler/ecj
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[] {
代码示例来源:origin: org.eclipse.jetty.orbit/org.eclipse.jdt.core
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 {
代码示例来源:origin: OpenNMS/opennms
@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();
}
代码示例来源:origin: org.eclipse.tycho/org.eclipse.jdt.core
public void compile(ICompilationUnit[] sourceUnits) {
compile(sourceUnits, false);
}
/**
代码示例来源:origin: org.eclipse.jdt/org.eclipse.jdt.core
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 {
代码示例来源:origin: org.eclipse.jdt/org.eclipse.jdt.core
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;
}
代码示例来源:origin: org.frege-lang/frege-interpreter-java-support
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);
}
代码示例来源:origin: actframework/actframework
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();
}
代码示例来源:origin: com.ovea.tajin.server/tajin-server-tomcat7
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 {
代码示例来源:origin: org.eclipse.jdt/org.eclipse.jdt.core
@Override
protected void handleInternalException(
Throwable internalException,
CompilationUnitDeclaration unit,
CompilationResult result) {
super.handleInternalException(internalException, unit, result);
if (unit != null) {
removeUnresolvedBindings(unit);
}
}
代码示例来源:origin: com.android.tools.lint/lint
@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();
}
}
}
代码示例来源:origin: org.eclipse.jdt.core.compiler/ecj
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();
}
代码示例来源:origin: org.eclipse.jdt.core.compiler/ecj
if (this.options.verbose) {
String count = String.valueOf(this.totalUnits + 1);
this.out.println(
Messages.bind(Messages.compilation_request,
new String[] {
addCompilationUnit(sourceUnit, parsedUnit);
代码示例来源:origin: org.eclipse.jdt/org.eclipse.jdt.core
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[] {
代码示例来源:origin: com.vaadin/vaadin-client-compiler-deps
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 {
内容来源于网络,如有侵权,请联系作者删除!