@Override protected void report(Environment environment, CategorizedProblem problem) { if (problem.isError()) { throw new SnippetCompilationError(problem.getMessage() + "at line " + problem.getSourceLineNumber()); } }
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); } else { // in noclasspath mode, errors are only reported // but undefined import, type, and name errors are irrelevant int problemId = problem.getID(); if (problemId != IProblem.UndefinedType && problemId != IProblem.UndefinedName && problemId != IProblem.ImportNotFound) { environment.report(null, Level.WARN, message); } } } }
public boolean hasErrors() { if (this.problems != null) for (int i = 0; i < this.problemCount; i++) { if (this.problems[i].isError()) return true; } return false; }
protected void updateProblemCounts(CategorizedProblem[] newProblems) { for (int i = 0, l = newProblems.length; i < l; i++) if (newProblems[i].isError()) this.newErrorCount++; else this.newWarningCount++; }
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--; } public CompilationResult tagAsAccepted(){
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--; } public CompilationResult tagAsAccepted(){
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--; } public CompilationResult tagAsAccepted(){
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--; } public CompilationResult tagAsAccepted(){
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--; } public CompilationResult tagAsAccepted(){
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--; } public CompilationResult tagAsAccepted(){
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--; } public CompilationResult tagAsAccepted(){
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--; } public CompilationResult tagAsAccepted(){
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--; } public CompilationResult tagAsAccepted(){
@Override public Kind getKind() { if (problem.isError()) { return Diagnostic.Kind.ERROR; } if (problem.isWarning()) { return Diagnostic.Kind.WARNING; } return Diagnostic.Kind.OTHER; } @Override
private static Kind getKind(CategorizedProblem problem) { Kind kind = Kind.OTHER; if(problem.isError()) { kind = Kind.ERROR; } else if(problem.isWarning()) { kind = Kind.WARNING; } else if (problem instanceof DefaultProblem && ((DefaultProblem) problem).isInfo()) { kind = Kind.NOTE; } return kind; }
private static Kind getKind(CategorizedProblem problem) { Kind kind = Kind.OTHER; if(problem.isError()) { kind = Kind.ERROR; } else if(problem.isWarning()) { kind = Kind.WARNING; } else if (problem instanceof DefaultProblem && ((DefaultProblem) problem).isInfo()) { kind = Kind.NOTE; } return kind; }
@Override public Kind getKind() { if (problem.isError()) { return Diagnostic.Kind.ERROR; } if (problem.isWarning()) { return Diagnostic.Kind.WARNING; } else if (problem instanceof DefaultProblem && ((DefaultProblem) problem).isInfo()) { return Diagnostic.Kind.NOTE; } return Diagnostic.Kind.OTHER; } @Override
public boolean isSuccess() { for (final CompilationResult res : results) { if (res.getProblems() != null) { for (final CategorizedProblem problem : res.getProblems()) { if (problem.isError()) { return false; } } } } return true; }
@Override public Kind getKind() { if (problem.isError()) { return Diagnostic.Kind.ERROR; } if (problem.isWarning()) { return Diagnostic.Kind.WARNING; } else if (problem instanceof DefaultProblem && ((DefaultProblem) problem).isInfo()) { return Diagnostic.Kind.NOTE; } return Diagnostic.Kind.OTHER; } @Override
private static void createProblemMarker(final IFile file, final CategorizedProblem prob) throws CoreException { IMarker marker = file.createMarker(MARKER); marker.setAttribute(IMarker.TRANSIENT, true); marker.setAttribute(IMarker.MESSAGE, prob.getMessage()); marker.setAttribute(IMarker.LINE_NUMBER, prob.getSourceLineNumber()); marker.setAttribute(IMarker.CHAR_START, prob.getSourceStart()); marker.setAttribute(IMarker.CHAR_END, prob.getSourceEnd()); marker.setAttribute(IMarker.SEVERITY, prob.isError()?SEVERITY_ERROR:SEVERITY_WARNING); } }