1 14 15 package org.eclipse.jdt.core.compiler; 16 17 import java.util.HashMap ; 18 19 import org.eclipse.jdt.core.ICompilationUnit; 20 import org.eclipse.jdt.core.IJavaElementDelta; 21 import org.eclipse.jdt.core.IJavaModelMarker; 22 import org.eclipse.jdt.core.JavaModelException; 23 import org.eclipse.jdt.core.dom.AST; 24 import org.eclipse.jdt.core.dom.ASTParser; 25 import org.eclipse.jdt.internal.core.CompilationUnit; 26 import org.eclipse.jdt.internal.core.JavaProject; 27 import org.eclipse.jdt.internal.core.ReconcileWorkingCopyOperation; 28 29 49 public class ReconcileContext { 50 51 private ReconcileWorkingCopyOperation operation; 52 private CompilationUnit workingCopy; 53 54 62 public ReconcileContext(ReconcileWorkingCopyOperation operation, CompilationUnit workingCopy) { 63 this.operation = operation; 64 this.workingCopy = workingCopy; 65 } 66 67 89 public org.eclipse.jdt.core.dom.CompilationUnit getAST3() throws JavaModelException { 90 if (this.operation.astLevel != AST.JLS3 || !this.operation.resolveBindings) { 91 ASTParser parser = ASTParser.newParser(AST.JLS3); 93 parser.setCompilerOptions(workingCopy.getJavaProject().getOptions(true)); 94 if (JavaProject.hasJavaNature(workingCopy.getJavaProject().getProject())) 95 parser.setResolveBindings(true); 96 parser.setStatementsRecovery((this.operation.reconcileFlags & ICompilationUnit.ENABLE_STATEMENTS_RECOVERY) != 0); 97 parser.setBindingsRecovery((this.operation.reconcileFlags & ICompilationUnit.ENABLE_BINDINGS_RECOVERY) != 0); 98 parser.setSource(workingCopy); 99 return (org.eclipse.jdt.core.dom.CompilationUnit) parser.createAST(this.operation.progressMonitor); 100 } 101 return this.operation.makeConsistent(this.workingCopy); 102 } 103 104 110 public int getASTLevel() { 111 return this.operation.astLevel; 112 } 113 114 119 public boolean isResolvingBindings() { 120 return this.operation.resolveBindings; 121 } 122 123 131 public IJavaElementDelta getDelta() { 132 return this.operation.deltaBuilder.delta; 133 } 134 135 143 public CategorizedProblem[] getProblems(String markerType) { 144 if (this.operation.problems == null) return null; 145 return (CategorizedProblem[]) this.operation.problems.get(markerType); 146 } 147 148 153 public ICompilationUnit getWorkingCopy() { 154 return this.workingCopy; 155 } 156 157 169 public void resetAST() { 170 this.operation.ast = null; 171 putProblems(IJavaModelMarker.JAVA_MODEL_PROBLEM_MARKER, null); 172 putProblems(IJavaModelMarker.TASK_MARKER, null); 173 } 174 175 188 public void putProblems(String markerType, CategorizedProblem[] problems) { 189 if (this.operation.problems == null) 190 this.operation.problems = new HashMap (); 191 this.operation.problems.put(markerType, problems); 192 } 193 194 } 195 | Popular Tags |