本文整理汇总了Java中org.eclipse.jdt.core.compiler.CategorizedProblem类的典型用法代码示例。如果您正苦于以下问题:Java CategorizedProblem类的具体用法?Java CategorizedProblem怎么用?Java CategorizedProblem使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
CategorizedProblem类属于org.eclipse.jdt.core.compiler包,在下文中一共展示了CategorizedProblem类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: addProblemToCompilationResult
import org.eclipse.jdt.core.compiler.CategorizedProblem; //导入依赖的package包/类
/**
* Adds a problem to the provided CompilationResult object so that it will show up
* in the Problems/Warnings view.
*/
public static void addProblemToCompilationResult(char[] fileNameArray, CompilationResult result,
boolean isWarning, String message, int sourceStart, int sourceEnd) {
if (result == null) return;
if (fileNameArray == null) fileNameArray = "(unknown).java".toCharArray();
int lineNumber = 0;
int columnNumber = 1;
int[] lineEnds = null;
lineNumber = sourceStart >= 0
? Util.getLineNumber(sourceStart, lineEnds = result.getLineSeparatorPositions(), 0, lineEnds.length-1)
: 0;
columnNumber = sourceStart >= 0
? Util.searchColumnNumber(result.getLineSeparatorPositions(), lineNumber,sourceStart)
: 0;
CategorizedProblem ecProblem = new LombokProblem(
fileNameArray, message, 0, new String[0],
isWarning ? ProblemSeverities.Warning : ProblemSeverities.Error,
sourceStart, sourceEnd, lineNumber, columnNumber);
result.record(ecProblem, null);
}
示例2: reportProblems
import org.eclipse.jdt.core.compiler.CategorizedProblem; //导入依赖的package包/类
/**
* Report working copy problems to a given requestor.
*
* @param workingCopy
* @param problemRequestor
*/
private void reportProblems(CompilationUnit workingCopy, IProblemRequestor problemRequestor) {
try {
problemRequestor.beginReporting();
for (Iterator iteraror = this.problems.values().iterator(); iteraror.hasNext(); ) {
CategorizedProblem[] categorizedProblems = (CategorizedProblem[]) iteraror.next();
if (categorizedProblems == null) continue;
for (int i = 0, length = categorizedProblems.length; i < length; i++) {
CategorizedProblem problem = categorizedProblems[i];
if (JavaModelManager.VERBOSE) {
System.out.println(
"PROBLEM FOUND while reconciling : " + problem.getMessage()); // $NON-NLS-1$
}
if (this.progressMonitor != null && this.progressMonitor.isCanceled()) break;
problemRequestor.acceptProblem(problem);
}
}
} finally {
problemRequestor.endReporting();
}
}
示例3: testDependentTypeIsNotSyncInterface
import org.eclipse.jdt.core.compiler.CategorizedProblem; //导入依赖的package包/类
public void testDependentTypeIsNotSyncInterface() throws JavaModelException {
JavaProjectUtilities.createCompilationUnit(javaProject,
"com.google.TestService",
"package com.google;\npublic interface TestService { void foo(); }\n");
ICompilationUnit asyncInterface = JavaProjectUtilities.createCompilationUnit(
javaProject,
"com.google.TestServiceAsync",
"package com.google;\nimport com.google.gwt.user.client.rpc.AsyncCallback;\npublic interface TestServiceAsync { void foo(AsyncCallback foo); }\n");
RemoteServiceValidator rsv = new RemoteServiceValidator();
ValidationResult validationResults;
ASTNode asyncAst = newAST(asyncInterface);
// Test that no errors are reported on the "Async" interface since the sync
// interface does not extend RemoteService
validationResults = rsv.validate(asyncAst);
assertProblemsEqual(Collections.<CategorizedProblem> emptyList(),
validationResults.getProblems());
assertEquals(Arrays.asList("com.google.TestService"),
validationResults.getTypeDependencies());
}
示例4: doValidateMethodOnDependentInterface
import org.eclipse.jdt.core.compiler.CategorizedProblem; //导入依赖的package包/类
@Override
protected List<CategorizedProblem> doValidateMethodOnDependentInterface(
IMethodBinding dependentMethodBinding, TypeDeclaration changedInterface,
ITypeBinding dependentTypeBinding) {
String[] parameters = RemoteServiceUtilities.computeSyncParameterTypes(dependentMethodBinding);
if (Bindings.findMethodInHierarchy(changedInterface.resolveBinding(),
dependentMethodBinding.getName(), parameters) == null) {
CategorizedProblem problem1 = RemoteServiceProblemFactory.newMissingSyncMethodOnSync(
changedInterface, dependentMethodBinding);
if (problem1 != null) {
return Collections.singletonList(problem1);
}
}
return Collections.emptyList();
}
示例5: doValidateMethodOnDependentInterface
import org.eclipse.jdt.core.compiler.CategorizedProblem; //导入依赖的package包/类
@Override
protected List<CategorizedProblem> doValidateMethodOnDependentInterface(
IMethodBinding methodBinding, TypeDeclaration changedInterface,
ITypeBinding dependentInterfaceBinding) {
String[] parameters = RemoteServiceUtilities.computeAsyncParameterTypes(methodBinding);
String methodName = methodBinding.getName();
if (Bindings.findMethodInHierarchy(changedInterface.resolveBinding(),
methodName, parameters) == null) {
CategorizedProblem problem = RemoteServiceProblemFactory.newMissingAsyncMethodOnAsync(
methodBinding, changedInterface);
if (problem != null) {
return Collections.singletonList(problem);
}
}
return Collections.emptyList();
}
示例6: reportProblems
import org.eclipse.jdt.core.compiler.CategorizedProblem; //导入依赖的package包/类
/**
* Report working copy problems to a given requestor.
*
* @param workingCopy
* @param problemRequestor
*/
private void reportProblems(CompilationUnit workingCopy, IProblemRequestor problemRequestor) {
try {
problemRequestor.beginReporting();
for (Iterator iteraror = this.problems.values().iterator(); iteraror.hasNext();) {
CategorizedProblem[] categorizedProblems = (CategorizedProblem[]) iteraror.next();
if (categorizedProblems == null) continue;
for (int i = 0, length = categorizedProblems.length; i < length; i++) {
CategorizedProblem problem = categorizedProblems[i];
if (JavaModelManager.VERBOSE){
System.out.println("PROBLEM FOUND while reconciling : " + problem.getMessage());//$NON-NLS-1$
}
if (this.progressMonitor != null && this.progressMonitor.isCanceled()) break;
problemRequestor.acceptProblem(problem);
}
}
} finally {
problemRequestor.endReporting();
}
}
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:26,代码来源:ReconcileWorkingCopyOperation.java
示例7: generateMissingAbstractMethods
import org.eclipse.jdt.core.compiler.CategorizedProblem; //导入依赖的package包/类
/**
* INTERNAL USE-ONLY
* Generate the byte for problem method infos that correspond to missing abstract methods.
* http://dev.eclipse.org/bugs/show_bug.cgi?id=3179
*
* @param methodDeclarations Array of all missing abstract methods
*/
public void generateMissingAbstractMethods(MethodDeclaration[] methodDeclarations, CompilationResult compilationResult) {
if (methodDeclarations != null) {
TypeDeclaration currentDeclaration = this.referenceBinding.scope.referenceContext;
int typeDeclarationSourceStart = currentDeclaration.sourceStart();
int typeDeclarationSourceEnd = currentDeclaration.sourceEnd();
for (int i = 0, max = methodDeclarations.length; i < max; i++) {
MethodDeclaration methodDeclaration = methodDeclarations[i];
MethodBinding methodBinding = methodDeclaration.binding;
String readableName = new String(methodBinding.readableName());
CategorizedProblem[] problems = compilationResult.problems;
int problemsCount = compilationResult.problemCount;
for (int j = 0; j < problemsCount; j++) {
CategorizedProblem problem = problems[j];
if (problem != null
&& problem.getID() == IProblem.AbstractMethodMustBeImplemented
&& problem.getMessage().indexOf(readableName) != -1
&& problem.getSourceStart() >= typeDeclarationSourceStart
&& problem.getSourceEnd() <= typeDeclarationSourceEnd) {
// we found a match
addMissingAbstractProblemMethod(methodDeclaration, methodBinding, problem, compilationResult);
}
}
}
}
}
示例8: record
import org.eclipse.jdt.core.compiler.CategorizedProblem; //导入依赖的package包/类
public void record(CategorizedProblem newProblem, ReferenceContext referenceContext, boolean mandatoryError) {
//new Exception("VERBOSE PROBLEM REPORTING").printStackTrace();
if(newProblem.getID() == IProblem.Task) {
recordTask(newProblem);
return;
}
if (this.problemCount == 0) {
this.problems = new CategorizedProblem[5];
} else if (this.problemCount == this.problems.length) {
System.arraycopy(this.problems, 0, (this.problems = new CategorizedProblem[this.problemCount * 2]), 0, this.problemCount);
}
this.problems[this.problemCount++] = newProblem;
if (referenceContext != null){
if (this.problemsMap == null) this.problemsMap = new HashMap(5);
if (this.firstErrors == null) this.firstErrors = new HashSet(5);
if (newProblem.isError() && !referenceContext.hasErrors()) this.firstErrors.add(newProblem);
this.problemsMap.put(newProblem, referenceContext);
}
if (newProblem.isError()) {
this.numberOfErrors++;
if (mandatoryError) this.hasMandatoryErrors = true;
if ((newProblem.getID() & IProblem.Syntax) != 0) {
this.hasSyntaxError = true;
}
}
}
示例9: isSuppressed
import org.eclipse.jdt.core.compiler.CategorizedProblem; //导入依赖的package包/类
public boolean isSuppressed(CategorizedProblem problem) {
if (this.suppressWarningsCount == 0) return false;
int irritant = ProblemReporter.getIrritant(problem.getID());
if (irritant == 0) return false;
int start = problem.getSourceStart();
int end = problem.getSourceEnd();
nextSuppress: for (int iSuppress = 0, suppressCount = this.suppressWarningsCount; iSuppress < suppressCount; iSuppress++) {
long position = this.suppressWarningScopePositions[iSuppress];
int startSuppress = (int) (position >>> 32);
int endSuppress = (int) position;
if (start < startSuppress) continue nextSuppress;
if (end > endSuppress) continue nextSuppress;
if (this.suppressWarningIrritants[iSuppress].isSet(irritant))
return true;
}
return false;
}
示例10: getProblems
import org.eclipse.jdt.core.compiler.CategorizedProblem; //导入依赖的package包/类
/**
* Answer the problems (errors and warnings) encountered during compilation.
*
* This is not a compiler internal API - it has side-effects !
* It is intended to be used only once all problems have been detected,
* and makes sure the problems slot as the exact size of the number of
* problems.
*/
public CategorizedProblem[] getProblems() {
// Re-adjust the size of the problems if necessary.
if (this.problems != null) {
if (this.problemCount != this.problems.length) {
System.arraycopy(this.problems, 0, (this.problems = new CategorizedProblem[this.problemCount]), 0, this.problemCount);
}
if (this.maxProblemPerUnit > 0 && this.problemCount > this.maxProblemPerUnit){
quickPrioritize(this.problems, 0, this.problemCount - 1);
this.problemCount = this.maxProblemPerUnit;
System.arraycopy(this.problems, 0, (this.problems = new CategorizedProblem[this.problemCount]), 0, this.problemCount);
}
// Stable sort problems per source positions.
Arrays.sort(this.problems, 0, this.problems.length, CompilationResult.PROBLEM_COMPARATOR);
//quickSort(problems, 0, problems.length-1);
}
return this.problems;
}
示例11: quickPrioritize
import org.eclipse.jdt.core.compiler.CategorizedProblem; //导入依赖的package包/类
private void quickPrioritize(CategorizedProblem[] problemList, int left, int right) {
if (left >= right) return;
// sort the problems by their priority... starting with the highest priority
int original_left = left;
int original_right = right;
int mid = computePriority(problemList[left + (right - left) / 2]);
do {
while (computePriority(problemList[right]) < mid)
right--;
while (mid < computePriority(problemList[left]))
left++;
if (left <= right) {
CategorizedProblem tmp = problemList[left];
problemList[left] = problemList[right];
problemList[right] = tmp;
left++;
right--;
}
} while (left <= right);
if (original_left < right)
quickPrioritize(problemList, original_left, right);
if (left < original_right)
quickPrioritize(problemList, left, original_right);
}
示例12: createProblem
import org.eclipse.jdt.core.compiler.CategorizedProblem; //导入依赖的package包/类
public CategorizedProblem createProblem(
char[] fileName,
int problemId,
String[] problemArguments,
String[] messageArguments,
int severity,
int problemStartPosition,
int problemEndPosition,
int lineNumber,
int columnNumber) {
return this.problemFactory.createProblem(
fileName,
problemId,
problemArguments,
messageArguments,
severity,
problemStartPosition,
problemEndPosition,
lineNumber,
columnNumber);
}
示例13: report
import org.eclipse.jdt.core.compiler.CategorizedProblem; //导入依赖的package包/类
protected void report(Environment environment, CategorizedProblem problem) {
if (problem == null) {
throw new IllegalArgumentException("problem cannot be null");
}
File file = new File(new String(problem.getOriginatingFileName()));
String filename = file.getAbsolutePath();
String message = problem.getMessage() + " at " + filename + ":"
+ problem.getSourceLineNumber();
if (problem.isError()) {
if (!environment.getNoClasspath()) {
// by default, compilation errors are notified as exception
throw new ModelBuildingException(message);
}
}
}
示例14: getEcjAST
import org.eclipse.jdt.core.compiler.CategorizedProblem; //导入依赖的package包/类
/**
* Returns the ECJ AST for the given class element. This allows to specify
* compiler options.
*
* <I>Note</I>: We do not cache the AST as it is not immutable.
*
* @return the AST or null if nothing compilable was found (such as
* interfaces).
*/
public static EcjCompilationResult getEcjAST(IJavaElement element,
EcjCompilerOptions options) throws ConQATException {
String content = element.getTextContent();
UnmodifiableList<String> scopeClasspath = element.getJavaContext()
.getClassPath();
String[] classpath = EcjUtils.obtainClasspath(CollectionUtils.toArray(
scopeClasspath, String.class));
ErrorAwareCompilerRequestor requestor = new ErrorAwareCompilerRequestor(
element.getUniformPath());
CompilationUnitDeclaration result = EcjASTAccess.compileAST(element
.getUniformPath(), content, classpath, element.getEncoding()
.name(), options, requestor);
return new EcjCompilationResult(result, CollectionUtils.toArray(
requestor.getErrors(), CategorizedProblem.class));
}
示例15: testWithBootClasspath
import org.eclipse.jdt.core.compiler.CategorizedProblem; //导入依赖的package包/类
/**
* When only the boot class path is provided the compiler should be able to
* find all system classes but not our referenced classes.
*/
public void testWithBootClasspath() throws IOException {
CollectingCompilerRequestor requestor = compile(EcjUtils
.obtainClasspath());
assertEquals(1, requestor.getClassFiles().size());
assertEquals("MainClass", EcjUtils.getFQName(CollectionUtils.getAny(
requestor.getClassFiles()).getCompoundName()));
// the compiler should be able to find all system classes but not our
// referenced classes
assertEquals(3, requestor.getErrors().size());
for (CategorizedProblem problem : requestor.getErrors()) {
assertEquals(50, problem.getCategoryID());
}
}