本文整理汇总了Java中org.eclipse.jdt.core.compiler.CategorizedProblem.isError方法的典型用法代码示例。如果您正苦于以下问题:Java CategorizedProblem.isError方法的具体用法?Java CategorizedProblem.isError怎么用?Java CategorizedProblem.isError使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.eclipse.jdt.core.compiler.CategorizedProblem
的用法示例。
在下文中一共展示了CategorizedProblem.isError方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: 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;
}
}
}
示例2: 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);
}
}
}
示例3: logXmlExtraProblem
import org.eclipse.jdt.core.compiler.CategorizedProblem; //导入方法依赖的package包/类
private void logXmlExtraProblem(CategorizedProblem problem, int globalErrorCount, int localErrorCount) {
final int sourceStart = problem.getSourceStart();
final int sourceEnd = problem.getSourceEnd();
boolean isError = problem.isError();
this.parameters.put(Logger.PROBLEM_SEVERITY, isError ? Logger.ERROR : Logger.WARNING);
this.parameters.put(Logger.PROBLEM_LINE, new Integer(problem.getSourceLineNumber()));
this.parameters.put(Logger.PROBLEM_SOURCE_START, new Integer(sourceStart));
this.parameters.put(Logger.PROBLEM_SOURCE_END, new Integer(sourceEnd));
printTag(Logger.EXTRA_PROBLEM_TAG, this.parameters, true, false);
this.parameters.put(Logger.VALUE, problem.getMessage());
printTag(Logger.PROBLEM_MESSAGE, this.parameters, true, true);
extractContext(problem, null);
endTag(Logger.EXTRA_PROBLEM_TAG);
}
示例4: logXmlProblem
import org.eclipse.jdt.core.compiler.CategorizedProblem; //导入方法依赖的package包/类
/**
* @param problem
* the given problem to log
* @param unitSource
* the given unit source
*/
private void logXmlProblem(CategorizedProblem problem, char[] unitSource) {
final int sourceStart = problem.getSourceStart();
final int sourceEnd = problem.getSourceEnd();
final int id = problem.getID();
this.parameters.put(Logger.ID, getFieldName(id)); // ID as field name
this.parameters.put(Logger.PROBLEM_ID, new Integer(id)); // ID as numeric value
boolean isError = problem.isError();
int severity = isError ? ProblemSeverities.Error : ProblemSeverities.Warning;
this.parameters.put(Logger.PROBLEM_SEVERITY, isError ? Logger.ERROR : Logger.WARNING);
this.parameters.put(Logger.PROBLEM_LINE, new Integer(problem.getSourceLineNumber()));
this.parameters.put(Logger.PROBLEM_SOURCE_START, new Integer(sourceStart));
this.parameters.put(Logger.PROBLEM_SOURCE_END, new Integer(sourceEnd));
String problemOptionKey = getProblemOptionKey(id);
if (problemOptionKey != null) {
this.parameters.put(Logger.PROBLEM_OPTION_KEY, problemOptionKey);
}
int categoryID = ProblemReporter.getProblemCategory(severity, id);
this.parameters.put(Logger.PROBLEM_CATEGORY_ID, new Integer(categoryID));
printTag(Logger.PROBLEM_TAG, this.parameters, true, false);
this.parameters.put(Logger.VALUE, problem.getMessage());
printTag(Logger.PROBLEM_MESSAGE, this.parameters, true, true);
extractContext(problem, unitSource);
String[] arguments = problem.getArguments();
final int length = arguments.length;
if (length != 0) {
printTag(Logger.PROBLEM_ARGUMENTS, null, true, false);
for (int i = 0; i < length; i++) {
this.parameters.put(Logger.PROBLEM_ARGUMENT_VALUE, arguments[i]);
printTag(Logger.PROBLEM_ARGUMENT, this.parameters, true, true);
}
endTag(Logger.PROBLEM_ARGUMENTS);
}
endTag(Logger.PROBLEM_TAG);
}
示例5: computePriority
import org.eclipse.jdt.core.compiler.CategorizedProblem; //导入方法依赖的package包/类
private int computePriority(CategorizedProblem problem){
final int P_STATIC = 10000;
final int P_OUTSIDE_METHOD = 40000;
final int P_FIRST_ERROR = 20000;
final int P_ERROR = 100000;
int priority = 10000 - problem.getSourceLineNumber(); // early problems first
if (priority < 0) priority = 0;
if (problem.isError()){
priority += P_ERROR;
}
ReferenceContext context = this.problemsMap == null ? null : (ReferenceContext) this.problemsMap.get(problem);
if (context != null){
if (context instanceof AbstractMethodDeclaration){
AbstractMethodDeclaration method = (AbstractMethodDeclaration) context;
if (method.isStatic()) {
priority += P_STATIC;
}
} else {
priority += P_OUTSIDE_METHOD;
}
if (this.firstErrors.contains(problem)){ // if context is null, firstErrors is null too
priority += P_FIRST_ERROR;
}
} else {
priority += P_OUTSIDE_METHOD;
}
return priority;
}
示例6: removeProblem
import org.eclipse.jdt.core.compiler.CategorizedProblem; //导入方法依赖的package包/类
public void removeProblem(CategorizedProblem problem) {
if (this.problemsMap != null) this.problemsMap.remove(problem);
if (this.firstErrors != null) this.firstErrors.remove(problem);
if (problem.isError()) {
this.numberOfErrors--;
}
this.problemCount--;
}
示例7: checkProblem
import org.eclipse.jdt.core.compiler.CategorizedProblem; //导入方法依赖的package包/类
private CategorizedProblem checkProblem(CategorizedProblem pb,
char[] originatingFileName, int severity, int start) {
int id = pb.getID();
if (CompletionEngine.this.actualCompletionPosition > start
&& this.lastErrorStart < start
&& pb.isError()
&& (id & IProblem.Syntax) == 0
&& (CompletionEngine.this.fileName == null || CharOperation.equals(CompletionEngine.this.fileName, originatingFileName))) {
CompletionEngine.this.problem = pb;
this.lastErrorStart = start;
}
if (this.checkProblems && !this.hasForbiddenProblems) {
switch (id) {
case IProblem.UsingDeprecatedType:
this.hasForbiddenProblems =
CompletionEngine.this.options.checkDeprecation;
break;
case IProblem.NotVisibleType:
this.hasForbiddenProblems =
CompletionEngine.this.options.checkVisibility;
break;
case IProblem.ForbiddenReference:
this.hasForbiddenProblems =
CompletionEngine.this.options.checkForbiddenReference;
break;
case IProblem.DiscouragedReference:
this.hasForbiddenProblems =
CompletionEngine.this.options.checkDiscouragedReference;
break;
default:
if ((severity & ProblemSeverities.Optional) != 0) {
this.hasAllowedProblems = true;
} else {
this.hasForbiddenProblems = true;
}
break;
}
}
return pb;
}
示例8: addProblemClinit
import org.eclipse.jdt.core.compiler.CategorizedProblem; //导入方法依赖的package包/类
/**
* INTERNAL USE-ONLY
* Generate the byte for a problem clinit method info that correspond to a boggus method.
*
* @param problems org.eclipse.jdt.internal.compiler.problem.Problem[]
*/
public void addProblemClinit(CategorizedProblem[] problems) {
generateMethodInfoHeaderForClinit();
// leave two spaces for the number of attributes
this.contentsOffset -= 2;
int attributeOffset = this.contentsOffset;
this.contentsOffset += 2;
int attributeNumber = 0;
int codeAttributeOffset = this.contentsOffset;
generateCodeAttributeHeader();
this.codeStream.resetForProblemClinit(this);
String problemString = "" ; //$NON-NLS-1$
int problemLine = 0;
if (problems != null) {
int max = problems.length;
StringBuffer buffer = new StringBuffer(25);
int count = 0;
for (int i = 0; i < max; i++) {
CategorizedProblem problem = problems[i];
if ((problem != null) && (problem.isError())) {
buffer.append("\t" +problem.getMessage() + "\n" ); //$NON-NLS-1$ //$NON-NLS-2$
count++;
if (problemLine == 0) {
problemLine = problem.getSourceLineNumber();
}
problems[i] = null;
}
} // insert the top line afterwards, once knowing how many problems we have to consider
if (count > 1) {
buffer.insert(0, Messages.compilation_unresolvedProblems);
} else {
buffer.insert(0, Messages.compilation_unresolvedProblem);
}
problemString = buffer.toString();
}
// return codeStream.generateCodeAttributeForProblemMethod(comp.options.runtimeExceptionNameForCompileError, "")
this.codeStream.generateCodeAttributeForProblemMethod(problemString);
attributeNumber++; // code attribute
completeCodeAttributeForClinit(
codeAttributeOffset,
problemLine);
if (this.contentsOffset + 2 >= this.contents.length) {
resizeContents(2);
}
this.contents[attributeOffset++] = (byte) (attributeNumber >> 8);
this.contents[attributeOffset] = (byte) attributeNumber;
}
示例9: addProblemConstructor
import org.eclipse.jdt.core.compiler.CategorizedProblem; //导入方法依赖的package包/类
/**
* INTERNAL USE-ONLY
* Generate the byte for a problem method info that correspond to a boggus constructor.
*
* @param method org.eclipse.jdt.internal.compiler.ast.AbstractMethodDeclaration
* @param methodBinding org.eclipse.jdt.internal.compiler.nameloopkup.MethodBinding
* @param problems org.eclipse.jdt.internal.compiler.problem.Problem[]
*/
public void addProblemConstructor(
AbstractMethodDeclaration method,
MethodBinding methodBinding,
CategorizedProblem[] problems) {
if (methodBinding.declaringClass.isInterface()) {
method.abort(ProblemSeverities.AbortType, null);
}
// always clear the strictfp/native/abstract bit for a problem method
generateMethodInfoHeader(methodBinding, methodBinding.modifiers & ~(ClassFileConstants.AccStrictfp | ClassFileConstants.AccNative | ClassFileConstants.AccAbstract));
int methodAttributeOffset = this.contentsOffset;
int attributesNumber = generateMethodInfoAttributes(methodBinding);
// Code attribute
attributesNumber++;
int codeAttributeOffset = this.contentsOffset;
generateCodeAttributeHeader();
this.codeStream.reset(method, this);
String problemString = "" ; //$NON-NLS-1$
int problemLine = 0;
if (problems != null) {
int max = problems.length;
StringBuffer buffer = new StringBuffer(25);
int count = 0;
for (int i = 0; i < max; i++) {
CategorizedProblem problem = problems[i];
if ((problem != null) && (problem.isError())) {
buffer.append("\t" +problem.getMessage() + "\n" ); //$NON-NLS-1$ //$NON-NLS-2$
count++;
if (problemLine == 0) {
problemLine = problem.getSourceLineNumber();
}
}
} // insert the top line afterwards, once knowing how many problems we have to consider
if (count > 1) {
buffer.insert(0, Messages.compilation_unresolvedProblems);
} else {
buffer.insert(0, Messages.compilation_unresolvedProblem);
}
problemString = buffer.toString();
}
// return codeStream.generateCodeAttributeForProblemMethod(comp.options.runtimeExceptionNameForCompileError, "")
this.codeStream.generateCodeAttributeForProblemMethod(problemString);
completeCodeAttributeForProblemMethod(
method,
methodBinding,
codeAttributeOffset,
((SourceTypeBinding) methodBinding.declaringClass)
.scope
.referenceCompilationUnit()
.compilationResult
.getLineSeparatorPositions(),
problemLine);
completeMethodInfo(methodBinding, methodAttributeOffset, attributesNumber);
}
示例10: addProblemMethod
import org.eclipse.jdt.core.compiler.CategorizedProblem; //导入方法依赖的package包/类
/**
* INTERNAL USE-ONLY
* Generate the byte for a problem method info that correspond to a boggus method.
*
* @param method org.eclipse.jdt.internal.compiler.ast.AbstractMethodDeclaration
* @param methodBinding org.eclipse.jdt.internal.compiler.nameloopkup.MethodBinding
* @param problems org.eclipse.jdt.internal.compiler.problem.Problem[]
*/
public void addProblemMethod(
AbstractMethodDeclaration method,
MethodBinding methodBinding,
CategorizedProblem[] problems) {
if (methodBinding.isAbstract() && methodBinding.declaringClass.isInterface()) {
method.abort(ProblemSeverities.AbortType, null);
}
// always clear the strictfp/native/abstract bit for a problem method
generateMethodInfoHeader(methodBinding, methodBinding.modifiers & ~(ClassFileConstants.AccStrictfp | ClassFileConstants.AccNative | ClassFileConstants.AccAbstract));
int methodAttributeOffset = this.contentsOffset;
int attributesNumber = generateMethodInfoAttributes(methodBinding);
// Code attribute
attributesNumber++;
int codeAttributeOffset = this.contentsOffset;
generateCodeAttributeHeader();
this.codeStream.reset(method, this);
String problemString = "" ; //$NON-NLS-1$
int problemLine = 0;
if (problems != null) {
int max = problems.length;
StringBuffer buffer = new StringBuffer(25);
int count = 0;
for (int i = 0; i < max; i++) {
CategorizedProblem problem = problems[i];
if ((problem != null)
&& (problem.isError())
&& (problem.getSourceStart() >= method.declarationSourceStart)
&& (problem.getSourceEnd() <= method.declarationSourceEnd)) {
buffer.append("\t" +problem.getMessage() + "\n" ); //$NON-NLS-1$ //$NON-NLS-2$
count++;
if (problemLine == 0) {
problemLine = problem.getSourceLineNumber();
}
problems[i] = null;
}
} // insert the top line afterwards, once knowing how many problems we have to consider
if (count > 1) {
buffer.insert(0, Messages.compilation_unresolvedProblems);
} else {
buffer.insert(0, Messages.compilation_unresolvedProblem);
}
problemString = buffer.toString();
}
// return codeStream.generateCodeAttributeForProblemMethod(comp.options.runtimeExceptionNameForCompileError, "")
this.codeStream.generateCodeAttributeForProblemMethod(problemString);
completeCodeAttributeForProblemMethod(
method,
methodBinding,
codeAttributeOffset,
((SourceTypeBinding) methodBinding.declaringClass)
.scope
.referenceCompilationUnit()
.compilationResult
.getLineSeparatorPositions(),
problemLine);
completeMethodInfo(methodBinding, methodAttributeOffset, attributesNumber);
}
示例11: addProblemConstructor
import org.eclipse.jdt.core.compiler.CategorizedProblem; //导入方法依赖的package包/类
/**
* INTERNAL USE-ONLY
* Generate the byte for a problem method info that correspond to a boggus constructor.
*
* @param method org.eclipse.jdt.internal.compiler.ast.AbstractMethodDeclaration
* @param methodBinding org.eclipse.jdt.internal.compiler.nameloopkup.MethodBinding
* @param problems org.eclipse.jdt.internal.compiler.problem.Problem[]
*/
public void addProblemConstructor(
AbstractMethodDeclaration method,
MethodBinding methodBinding,
CategorizedProblem[] problems) {
// always clear the strictfp/native/abstract bit for a problem method
generateMethodInfoHeader(methodBinding, methodBinding.modifiers & ~(ClassFileConstants.AccStrictfp | ClassFileConstants.AccNative | ClassFileConstants.AccAbstract));
int methodAttributeOffset = this.contentsOffset;
int attributesNumber = generateMethodInfoAttributes(methodBinding);
// Code attribute
attributesNumber++;
int codeAttributeOffset = this.contentsOffset;
generateCodeAttributeHeader();
this.codeStream.reset(method, this);
String problemString = "" ; //$NON-NLS-1$
int problemLine = 0;
if (problems != null) {
int max = problems.length;
StringBuffer buffer = new StringBuffer(25);
int count = 0;
for (int i = 0; i < max; i++) {
CategorizedProblem problem = problems[i];
if ((problem != null) && (problem.isError())) {
buffer.append("\t" +problem.getMessage() + "\n" ); //$NON-NLS-1$ //$NON-NLS-2$
count++;
if (problemLine == 0) {
problemLine = problem.getSourceLineNumber();
}
}
} // insert the top line afterwards, once knowing how many problems we have to consider
if (count > 1) {
buffer.insert(0, Messages.compilation_unresolvedProblems);
} else {
buffer.insert(0, Messages.compilation_unresolvedProblem);
}
problemString = buffer.toString();
}
// return codeStream.generateCodeAttributeForProblemMethod(comp.options.runtimeExceptionNameForCompileError, "")
this.codeStream.generateCodeAttributeForProblemMethod(problemString);
completeCodeAttributeForProblemMethod(
method,
methodBinding,
codeAttributeOffset,
((SourceTypeBinding) methodBinding.declaringClass)
.scope
.referenceCompilationUnit()
.compilationResult
.getLineSeparatorPositions(),
problemLine);
completeMethodInfo(methodBinding, methodAttributeOffset, attributesNumber);
}