1 11 package org.eclipse.jdt.internal.compiler.problem; 12 13 import org.eclipse.jdt.core.compiler.CategorizedProblem; 14 import org.eclipse.jdt.internal.compiler.CompilationResult; 15 import org.eclipse.jdt.internal.compiler.ast.ASTNode; 16 import org.eclipse.jdt.internal.compiler.lookup.InvocationSite; 17 import org.eclipse.jdt.internal.compiler.util.Util; 18 19 25 public class AbortCompilation extends RuntimeException { 26 27 public CompilationResult compilationResult; 28 public Throwable exception; 29 public CategorizedProblem problem; 30 31 32 public boolean isSilent; 33 public RuntimeException silentException; 34 35 private static final long serialVersionUID = -2047226595083244852L; 37 public AbortCompilation() { 38 } 40 41 public AbortCompilation(CompilationResult compilationResult, CategorizedProblem problem) { 42 this(); 43 this.compilationResult = compilationResult; 44 this.problem = problem; 45 } 46 47 public AbortCompilation(CompilationResult compilationResult, Throwable exception) { 48 this(); 49 this.compilationResult = compilationResult; 50 this.exception = exception; 51 } 52 53 public AbortCompilation(boolean isSilent, RuntimeException silentException) { 54 this(); 55 this.isSilent = isSilent; 56 this.silentException = silentException; 57 } 58 59 public void updateContext(InvocationSite invocationSite, CompilationResult unitResult) { 60 if (this.problem == null) return; 61 if (this.problem.getSourceStart() != 0 || this.problem.getSourceEnd() != 0) return; 62 this.problem.setSourceStart(invocationSite.sourceStart()); 63 this.problem.setSourceEnd(invocationSite.sourceEnd()); 64 int[] lineEnds = unitResult.getLineSeparatorPositions(); 65 this.problem.setSourceLineNumber(Util.getLineNumber(invocationSite.sourceStart(), lineEnds, 0, lineEnds.length-1)); 66 this.compilationResult = unitResult; 67 } 68 69 public void updateContext(ASTNode astNode, CompilationResult unitResult) { 70 if (this.problem == null) return; 71 if (this.problem.getSourceStart() != 0 || this.problem.getSourceEnd() != 0) return; 72 this.problem.setSourceStart(astNode.sourceStart()); 73 this.problem.setSourceEnd(astNode.sourceEnd()); 74 int[] lineEnds = unitResult.getLineSeparatorPositions(); 75 this.problem.setSourceLineNumber(Util.getLineNumber(astNode.sourceStart(), lineEnds, 0, lineEnds.length-1)); 76 this.compilationResult = unitResult; 77 } 78 } 79 | Popular Tags |