Java Code Examples for org.eclipse.jdt.core.compiler.CategorizedProblem#getID()
The following examples show how to use
org.eclipse.jdt.core.compiler.CategorizedProblem#getID() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: CompilationResult.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 6 votes |
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; } } }
Example 2
Source File: Compiler.java From APDE with GNU General Public License v2.0 | 6 votes |
@Override public int logProblems(CategorizedProblem[] problems, char[] unitSource, Main currentMain) { int localErrorCount = 0; for (CategorizedProblem problem : problems) { if (problem != null) { handleProblem(problem); // These counters are necessary for ECJ to function properly if (problem.isError()) { localErrorCount++; currentMain.globalErrorsCount++; } else if (problem.getID() == IProblem.Task) { currentMain.globalTasksCount++; } else { currentMain.globalWarningsCount++; } } } return localErrorCount; }
Example 3
Source File: Main.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 5 votes |
/** * @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); }
Example 4
Source File: CompilationResult.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 5 votes |
/** * Same as getProblems() but don't answer problems that actually concern the enclosing package. */ public CategorizedProblem[] getCUProblems() { // Re-adjust the size of the problems if necessary and filter package problems if (this.problems != null) { CategorizedProblem[] filteredProblems = new CategorizedProblem[this.problemCount]; int keep = 0; for (int i=0; i< this.problemCount; i++) { CategorizedProblem problem = this.problems[i]; if (problem.getID() != IProblem.MissingNonNullByDefaultAnnotationOnPackage) { filteredProblems[keep++] = problem; } else if (this.compilationUnit != null) { if (CharOperation.equals(this.compilationUnit.getMainTypeName(), TypeConstants.PACKAGE_INFO_NAME)) { filteredProblems[keep++] = problem; } } } if (keep < this.problemCount) { System.arraycopy(filteredProblems, 0, filteredProblems = new CategorizedProblem[keep], 0, keep); this.problemCount = keep; } this.problems = filteredProblems; 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; }
Example 5
Source File: CompilationUnitStructureRequestor.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 4 votes |
public void acceptProblem(CategorizedProblem problem) { if ((problem.getID() & IProblem.Syntax) != 0){ this.hasSyntaxErrors = true; } }
Example 6
Source File: ASTRecoveryPropagator.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 4 votes |
private boolean markIncludedProblems(int start, int end) { boolean foundProblems = false; next: for (int i = 0, max = this.problems.length; i < max; i++) { CategorizedProblem problem = this.problems[i]; if(this.usedOrIrrelevantProblems[i]) continue next; switch(problem.getID()) { case IProblem.ParsingErrorOnKeywordNoSuggestion : case IProblem.ParsingErrorOnKeyword : case IProblem.ParsingError : case IProblem.ParsingErrorNoSuggestion : case IProblem.ParsingErrorInsertTokenBefore : case IProblem.ParsingErrorInsertTokenAfter : case IProblem.ParsingErrorDeleteToken : case IProblem.ParsingErrorDeleteTokens : case IProblem.ParsingErrorMergeTokens : case IProblem.ParsingErrorInvalidToken : case IProblem.ParsingErrorMisplacedConstruct : case IProblem.ParsingErrorReplaceTokens : case IProblem.ParsingErrorNoSuggestionForTokens : case IProblem.ParsingErrorUnexpectedEOF : case IProblem.ParsingErrorInsertToComplete : case IProblem.ParsingErrorInsertToCompleteScope : case IProblem.ParsingErrorInsertToCompletePhrase : case IProblem.EndOfSource : case IProblem.InvalidHexa : case IProblem.InvalidOctal : case IProblem.InvalidCharacterConstant : case IProblem.InvalidEscape : case IProblem.InvalidInput : case IProblem.InvalidUnicodeEscape : case IProblem.InvalidFloat : case IProblem.NullSourceString : case IProblem.UnterminatedString : case IProblem.UnterminatedComment : case IProblem.InvalidDigit : break; default: this.usedOrIrrelevantProblems[i] = true; continue next; } int problemStart = problem.getSourceStart(); int problemEnd = problem.getSourceEnd(); if ((start <= problemStart) && (problemStart <= end) || (start <= problemEnd) && (problemEnd <= end)) { this.usedOrIrrelevantProblems[i] = true; foundProblems = true; } } return foundProblems; }
Example 7
Source File: ASTSyntaxErrorPropagator.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 4 votes |
private boolean checkAndTagAsMalformed(ASTNode node) { boolean tagWithErrors = false; search: for (int i = 0, max = this.problems.length; i < max; i++) { CategorizedProblem problem = this.problems[i]; switch(problem.getID()) { case IProblem.ParsingErrorOnKeywordNoSuggestion : case IProblem.ParsingErrorOnKeyword : case IProblem.ParsingError : case IProblem.ParsingErrorNoSuggestion : case IProblem.ParsingErrorInsertTokenBefore : case IProblem.ParsingErrorInsertTokenAfter : case IProblem.ParsingErrorDeleteToken : case IProblem.ParsingErrorDeleteTokens : case IProblem.ParsingErrorMergeTokens : case IProblem.ParsingErrorInvalidToken : case IProblem.ParsingErrorMisplacedConstruct : case IProblem.ParsingErrorReplaceTokens : case IProblem.ParsingErrorNoSuggestionForTokens : case IProblem.ParsingErrorUnexpectedEOF : case IProblem.ParsingErrorInsertToComplete : case IProblem.ParsingErrorInsertToCompleteScope : case IProblem.ParsingErrorInsertToCompletePhrase : case IProblem.EndOfSource : case IProblem.InvalidHexa : case IProblem.InvalidOctal : case IProblem.InvalidCharacterConstant : case IProblem.InvalidEscape : case IProblem.InvalidInput : case IProblem.InvalidUnicodeEscape : case IProblem.InvalidFloat : case IProblem.NullSourceString : case IProblem.UnterminatedString : case IProblem.UnterminatedComment : case IProblem.InvalidDigit : break; default: continue search; } int position = problem.getSourceStart(); int start = node.getStartPosition(); int end = start + node.getLength(); if ((start <= position) && (position <= end)) { node.setFlags(node.getFlags() | ASTNode.MALFORMED); // clear the bits on parent ASTNode currentNode = node.getParent(); while (currentNode != null) { currentNode.setFlags(currentNode.getFlags() & ~ASTNode.MALFORMED); currentNode = currentNode.getParent(); } tagWithErrors = true; } } return tagWithErrors; }