List of usage examples for org.eclipse.jdt.internal.compiler.util Util searchColumnNumber
public static final int searchColumnNumber(int[] startLineIndexes, int lineNumber, int position)
From source file:com.google.gwt.dev.javac.GWTProblem.java
License:Open Source License
public static void recordProblem(ASTNode node, CompilationResult compResult, String message, HelpInfo helpInfo, int problemSeverity) { int[] lineEnds = compResult.getLineSeparatorPositions(); int startLine = Util.getLineNumber(node.sourceStart(), lineEnds, 0, lineEnds.length - 1); int startColumn = Util.searchColumnNumber(lineEnds, startLine, node.sourceStart()); recordProblem(node.sourceStart(), node.sourceEnd(), startLine, startColumn, compResult, message, helpInfo, problemSeverity);/* w w w. jav a 2s . com*/ }
From source file:com.google.gwt.dev.javac.JsniCollector.java
License:Open Source License
private static void reportJsniProblem(SourceInfo info, AbstractMethodDeclaration methodDeclaration, String message, int problemSeverity) { // TODO: provide helpInfo for how to write JSNI methods? HelpInfo jsniHelpInfo = null;//from www . j a v a 2 s. com CompilationResult compResult = methodDeclaration.compilationResult(); // recalculate startColumn, because SourceInfo does not hold it int startColumn = Util.searchColumnNumber(compResult.getLineSeparatorPositions(), info.getStartLine(), info.getStartPos()); GWTProblem.recordProblem(info, startColumn, compResult, message, jsniHelpInfo, problemSeverity); }
From source file:org.eclipse.jdt.internal.compiler.problem.ProblemHandler.java
License:Open Source License
public void handle(int problemId, String[] problemArguments, int elaborationId, String[] messageArguments, int severity, int problemStartPosition, int problemEndPosition, ReferenceContext referenceContext, CompilationResult unitResult) {/*from w w w. j a va 2s .co m*/ if (severity == ProblemSeverities.Ignore) return; // if no reference context, we need to abort from the current compilation process if (referenceContext == null) { if ((severity & ProblemSeverities.Error) != 0) { // non reportable error is fatal CategorizedProblem problem = this.createProblem(null, problemId, problemArguments, elaborationId, messageArguments, severity, 0, 0, 0, 0); throw new AbortCompilation(null, problem); } else { return; // ignore non reportable warning } } int[] lineEnds; int lineNumber = problemStartPosition >= 0 ? Util.getLineNumber(problemStartPosition, lineEnds = unitResult.getLineSeparatorPositions(), 0, lineEnds.length - 1) : 0; int columnNumber = problemStartPosition >= 0 ? Util.searchColumnNumber(unitResult.getLineSeparatorPositions(), lineNumber, problemStartPosition) : 0; CategorizedProblem problem = this.createProblem(unitResult.getFileName(), problemId, problemArguments, elaborationId, messageArguments, severity, problemStartPosition, problemEndPosition, lineNumber, columnNumber); if (problem == null) return; // problem couldn't be created, ignore switch (severity & ProblemSeverities.Error) { case ProblemSeverities.Error: record(problem, unitResult, referenceContext); if ((severity & ProblemSeverities.Fatal) != 0) { referenceContext.tagAsHavingErrors(); // should abort ? int abortLevel; if ((abortLevel = this.policy.stopOnFirstError() ? ProblemSeverities.AbortCompilation : severity & ProblemSeverities.Abort) != 0) { referenceContext.abort(abortLevel, problem); } } break; case ProblemSeverities.Warning: // GROOVY start - still required? if ((this.options.groovyFlags & 0x01) != 0) { if ((unitResult.compilationUnit instanceof SourceFile) && ((SourceFile) unitResult.compilationUnit).isInLinkedSourceFolder()) { return; } } // GROOVY end record(problem, unitResult, referenceContext); break; } }