本文整理汇总了Java中org.eclipse.jdt.internal.compiler.IProblemFactory类的典型用法代码示例。如果您正苦于以下问题:Java IProblemFactory类的具体用法?Java IProblemFactory怎么用?Java IProblemFactory使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
IProblemFactory类属于org.eclipse.jdt.internal.compiler包,在下文中一共展示了IProblemFactory类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: CodeSnippetCompiler
import org.eclipse.jdt.internal.compiler.IProblemFactory; //导入依赖的package包/类
/**
* Creates a new code snippet compiler initialized with a code snippet parser.
*/
public CodeSnippetCompiler(
INameEnvironment environment,
IErrorHandlingPolicy policy,
CompilerOptions compilerOptions,
ICompilerRequestor requestor,
IProblemFactory problemFactory,
EvaluationContext evaluationContext,
int codeSnippetStart,
int codeSnippetEnd) {
super(environment, policy, compilerOptions, requestor, problemFactory);
this.codeSnippetStart = codeSnippetStart;
this.codeSnippetEnd = codeSnippetEnd;
this.evaluationContext = evaluationContext;
this.parser =
new CodeSnippetParser(
this.problemReporter,
evaluationContext,
this.options.parseLiteralExpressionsAsConstants,
codeSnippetStart,
codeSnippetEnd);
this.parseThreshold = 1;
// fully parse only the code snippet compilation unit
}
示例2: compile
import org.eclipse.jdt.internal.compiler.IProblemFactory; //导入依赖的package包/类
@Override
public CompilationResult compile(final Collection<String> sourceNames) {
final Map<String, byte[]> compiled = new HashMap<String, byte[]>();
final List<CompilationProblem> problems = new ArrayList<CompilationProblem>();
final List<ICompilationUnit> compilationUnits = collectCompilationUnits(sourceNames, problems);
// Exit if problems
if (! problems.isEmpty()) {
return new CompilationResult(problems);
}
// Setup compiler environment
final IErrorHandlingPolicy policy = DefaultErrorHandlingPolicies.proceedWithAllProblems();
final IProblemFactory problemFactory = new DefaultProblemFactory(Locale.getDefault());
final INameEnvironment nameEnvironment = new NameEnvironment();
final ICompilerRequestor compilerRequestor = new CompilerRequestor(problems, compiled);
// Compile
final Compiler compiler = new Compiler(nameEnvironment, policy, new CompilerOptions(STANDARD_OPTIONS),
compilerRequestor, problemFactory);
compiler.compile(compilationUnits.toArray(new ICompilationUnit[0]));
return new CompilationResult(problems, compiled);
}
示例3: compileUnits
import org.eclipse.jdt.internal.compiler.IProblemFactory; //导入依赖的package包/类
@Override
protected String compileUnits(final JRCompilationUnit[] units, String classpath, File tempDirFile)
{
final INameEnvironment env = getNameEnvironment(units);
final IErrorHandlingPolicy policy =
DefaultErrorHandlingPolicies.proceedWithAllProblems();
final Map<String,String> settings = getJdtSettings();
final IProblemFactory problemFactory =
new DefaultProblemFactory(Locale.getDefault());
final CompilerRequestor requestor = getCompilerRequestor(units);
final Compiler compiler = new Compiler(env, policy, settings, requestor, problemFactory);
do
{
CompilationUnit[] compilationUnits = requestor.processCompilationUnits();
compiler.compile(compilationUnits);
}
while (requestor.hasMissingMethods());
requestor.processProblems();
return requestor.getFormattedProblems();
}
示例4: NonGeneratingCompiler
import org.eclipse.jdt.internal.compiler.IProblemFactory; //导入依赖的package包/类
public NonGeneratingCompiler(INameEnvironment environment, IErrorHandlingPolicy policy,
CompilerOptions options, ICompilerRequestor requestor,
IProblemFactory problemFactory,
Map<ICompilationUnit, CompilationUnitDeclaration> units) {
super(environment, policy, options, requestor, problemFactory, null, null);
mUnits = units;
}
示例5: HierarchyResolver
import org.eclipse.jdt.internal.compiler.IProblemFactory; //导入依赖的package包/类
public HierarchyResolver(INameEnvironment nameEnvironment, Map settings, HierarchyBuilder builder, IProblemFactory problemFactory) {
// create a problem handler with the 'exit after all problems' handling policy
this.options = new CompilerOptions(settings);
IErrorHandlingPolicy policy = DefaultErrorHandlingPolicies.exitAfterAllProblems();
ProblemReporter problemReporter = new ProblemReporter(policy, this.options, problemFactory);
LookupEnvironment environment = new LookupEnvironment(this, this.options, problemReporter, nameEnvironment);
environment.mayTolerateMissingType = true;
setEnvironment(environment, builder);
}
示例6: Evaluator
import org.eclipse.jdt.internal.compiler.IProblemFactory; //导入依赖的package包/类
/**
* Creates a new evaluator.
*/
Evaluator(EvaluationContext context, INameEnvironment environment, Map options, IRequestor requestor, IProblemFactory problemFactory) {
this.context = context;
this.environment = environment;
this.options = options;
this.requestor = requestor;
this.problemFactory = problemFactory;
}
示例7: evaluate
import org.eclipse.jdt.internal.compiler.IProblemFactory; //导入依赖的package包/类
/**
* @see org.eclipse.jdt.core.eval.IEvaluationContext
* @exception org.eclipse.jdt.internal.eval.InstallException if the code snippet class files could not be deployed.
*/
public void evaluate(char[] codeSnippet, INameEnvironment environment, Map options, final IRequestor requestor, IProblemFactory problemFactory) throws InstallException {
this.evaluate(
codeSnippet,
null,
null,
null,
null,
true,
false,
environment,
options,
requestor,
problemFactory);
}
示例8: evaluateVariables
import org.eclipse.jdt.internal.compiler.IProblemFactory; //导入依赖的package包/类
/**
* @see org.eclipse.jdt.core.eval.IEvaluationContext
* @exception org.eclipse.jdt.internal.eval.InstallException if the code snippet class files could not be deployed.
*/
public void evaluateVariables(INameEnvironment environment, Map options, IRequestor requestor, IProblemFactory problemFactory) throws InstallException {
deployCodeSnippetClassIfNeeded(requestor);
VariablesEvaluator evaluator = new VariablesEvaluator(this, environment, options, requestor, problemFactory);
ClassFile[] classes = evaluator.getClasses();
if (classes != null) {
if (classes.length > 0) {
// Sort classes so that enclosing types are cached before nested types
// otherwise an AbortCompilation is thrown in 1.5 mode since the enclosing type
// is needed to resolve a nested type
Util.sort(classes, new Util.Comparer() {
public int compare(Object a, Object b) {
if (a == b) return 0;
ClassFile enclosing = ((ClassFile) a).enclosingClassFile;
while (enclosing != null) {
if (enclosing == b)
return 1;
enclosing = enclosing.enclosingClassFile;
}
return -1;
}
});
// Send classes
if (!requestor.acceptClassFiles(classes, null)) {
throw new InstallException();
}
// Remember that the variables have been installed
int count = this.variableCount;
GlobalVariable[] variablesCopy = new GlobalVariable[count];
System.arraycopy(this.variables, 0, variablesCopy, 0, count);
this.installedVars = new VariablesInfo(evaluator.getPackageName(), evaluator.getClassName(), classes, variablesCopy, count);
VAR_CLASS_COUNTER++;
}
this.varsChanged = false;
}
}
示例9: testBinaryOriginatingElements
import org.eclipse.jdt.internal.compiler.IProblemFactory; //导入依赖的package包/类
@Test
public void testBinaryOriginatingElements() throws Exception {
// the point of this test is to assert Filer#createSourceFile does not puke when originatingElements are not sources
// originating source elements are used to cleanup generated outputs when corresponding sources change
// originating binary elements are not currently fully supported and are not tracked during incremental build
Classpath namingEnvironment = createClasspath();
IErrorHandlingPolicy errorHandlingPolicy = DefaultErrorHandlingPolicies.exitAfterAllProblems();
IProblemFactory problemFactory = ProblemFactory.getProblemFactory(Locale.getDefault());
CompilerOptions compilerOptions = new CompilerOptions();
ICompilerRequestor requestor = null;
Compiler compiler = new Compiler(namingEnvironment, errorHandlingPolicy, compilerOptions, requestor, problemFactory);
EclipseFileManager fileManager = new EclipseFileManager(null, Charsets.UTF_8);
File outputDir = temp.newFolder();
fileManager.setLocation(StandardLocation.SOURCE_OUTPUT, Collections.singleton(outputDir));
CompilerBuildContext context = null;
Map<String, String> processorOptions = null;
CompilerJdt incrementalCompiler = null;
ProcessingEnvImpl env = new ProcessingEnvImpl(context, fileManager, processorOptions, compiler, incrementalCompiler);
TypeElement typeElement = env.getElementUtils().getTypeElement("java.lang.Object");
FilerImpl filer = new FilerImpl(null /* context */, fileManager, null /* compiler */, null /* env */);
filer.createSourceFile("test.Source", typeElement);
}
示例10: parse
import org.eclipse.jdt.internal.compiler.IProblemFactory; //导入依赖的package包/类
/** Parse the given source units and class path and store it into the given output map */
public static INameEnvironment parse(
CompilerOptions options,
@NonNull List<ICompilationUnit> sourceUnits,
@NonNull List<String> classPath,
@NonNull Map<ICompilationUnit, CompilationUnitDeclaration> outputMap,
@Nullable LintClient client) {
INameEnvironment environment = new FileSystem(
classPath.toArray(new String[classPath.size()]), new String[0],
options.defaultEncoding);
IErrorHandlingPolicy policy = DefaultErrorHandlingPolicies.proceedWithAllProblems();
IProblemFactory problemFactory = new DefaultProblemFactory(Locale.getDefault());
ICompilerRequestor requestor = new ICompilerRequestor() {
@Override
public void acceptResult(CompilationResult result) {
// Not used; we need the corresponding CompilationUnitDeclaration for the source
// units (the AST parsed from source) which we don't get access to here, so we
// instead subclass AST to get our hands on them.
}
};
NonGeneratingCompiler compiler = new NonGeneratingCompiler(environment, policy, options,
requestor, problemFactory, outputMap);
try {
compiler.compile(sourceUnits.toArray(new ICompilationUnit[sourceUnits.size()]));
} catch (OutOfMemoryError e) {
environment.cleanup();
// Since we're running out of memory, if it's all still held we could potentially
// fail attempting to log the failure. Actively get rid of the large ECJ data
// structure references first so minimize the chance of that
//noinspection UnusedAssignment
compiler = null;
//noinspection UnusedAssignment
environment = null;
//noinspection UnusedAssignment
requestor = null;
//noinspection UnusedAssignment
problemFactory = null;
//noinspection UnusedAssignment
policy = null;
String msg = "Ran out of memory analyzing .java sources with ECJ: Some lint checks "
+ "may not be accurate (missing type information from the compiler)";
if (client != null) {
// Don't log exception too; this isn't a compiler error per se where we
// need to pin point the exact unlucky code that asked for memory when it
// had already run out
client.log(null, msg);
} else {
System.out.println(msg);
}
} catch (Throwable t) {
if (client != null) {
CompilationUnitDeclaration currentUnit = compiler.getCurrentUnit();
if (currentUnit == null || currentUnit.getFileName() == null) {
client.log(t, "ECJ compiler crashed");
} else {
client.log(t, "ECJ compiler crashed processing %1$s",
new String(currentUnit.getFileName()));
}
} else {
t.printStackTrace();
}
environment.cleanup();
environment = null;
}
return environment;
}
示例11: compileUnits
import org.eclipse.jdt.internal.compiler.IProblemFactory; //导入依赖的package包/类
/**
*
*/
protected String compileUnits(final JRCompilationUnit[] units, String classpath, File tempDirFile) {
final INameEnvironment env = getNameEnvironment(units);
final IProblemFactory problemFactory = new DefaultProblemFactory(Locale.getDefault());
final CompilerRequestor requestor = getCompilerRequestor(units);
final Compiler compiler = new Compiler(env, policy, getJdtSettings(), requestor, problemFactory);
do {
CompilationUnit[] compilationUnits = requestor.processCompilationUnits();
compiler.compile(compilationUnits);
} while (requestor.hasMissingMethods());
requestor.processProblems();
return requestor.getFormattedProblems();
}
示例12: IndexingParser
import org.eclipse.jdt.internal.compiler.IProblemFactory; //导入依赖的package包/类
public IndexingParser(ISourceElementRequestor requestor, IProblemFactory problemFactory, CompilerOptions options, boolean reportLocalDeclarations, boolean optimizeStringLiterals, boolean useSourceJavadocParser) {
super(requestor, problemFactory, options, reportLocalDeclarations,
optimizeStringLiterals, useSourceJavadocParser);
}
示例13: getProblemFactory
import org.eclipse.jdt.internal.compiler.IProblemFactory; //导入依赖的package包/类
/**
* Returns the problem factory to be used during evaluation.
*/
protected IProblemFactory getProblemFactory() {
return ProblemFactory.getProblemFactory(Locale.getDefault());
}
示例14: VariablesEvaluator
import org.eclipse.jdt.internal.compiler.IProblemFactory; //导入依赖的package包/类
/**
* Creates a new global variables evaluator.
*/
VariablesEvaluator(EvaluationContext context, INameEnvironment environment, Map options, IRequestor requestor, IProblemFactory problemFactory) {
super(context, environment, options, requestor, problemFactory);
}
示例15: CodeSnippetEvaluator
import org.eclipse.jdt.internal.compiler.IProblemFactory; //导入依赖的package包/类
/**
* Creates a new code snippet evaluator.
*/
CodeSnippetEvaluator(char[] codeSnippet, EvaluationContext context, INameEnvironment environment, Map options, IRequestor requestor, IProblemFactory problemFactory) {
super(context, environment, options, requestor, problemFactory);
this.codeSnippet = codeSnippet;
}