1 11 package org.eclipse.jdt.internal.corext.refactoring; 12 13 import org.eclipse.core.runtime.CoreException; 14 15 import org.eclipse.jdt.core.ICompilationUnit; 16 import org.eclipse.jdt.core.IJavaProject; 17 import org.eclipse.jdt.core.JavaCore; 18 import org.eclipse.jdt.core.ToolFactory; 19 import org.eclipse.jdt.core.compiler.IScanner; 20 import org.eclipse.jdt.core.search.SearchMatch; 21 22 import org.eclipse.jdt.internal.corext.util.SearchUtils; 23 24 28 public abstract class CuCollectingSearchRequestor extends CollectingSearchRequestor { 29 30 private ICompilationUnit fCuCache; 31 private IScanner fScannerCache; 32 33 protected IScanner getScanner(ICompilationUnit unit) { 34 if (unit.equals(fCuCache)) 35 return fScannerCache; 36 37 fCuCache= unit; 38 IJavaProject project= unit.getJavaProject(); 39 String sourceLevel= project.getOption(JavaCore.COMPILER_SOURCE, true); 40 String complianceLevel= project.getOption(JavaCore.COMPILER_COMPLIANCE, true); 41 fScannerCache= ToolFactory.createScanner(false, false, false, sourceLevel, complianceLevel); 42 return fScannerCache; 43 } 44 45 52 public final void acceptSearchMatch(SearchMatch match) throws CoreException { 53 ICompilationUnit unit= SearchUtils.getCompilationUnit(match); 54 if (unit == null) 55 return; 56 acceptSearchMatch(unit, match); 57 } 58 59 public void collectMatch(SearchMatch match) throws CoreException { 60 super.acceptSearchMatch(match); 61 } 62 63 protected abstract void acceptSearchMatch(ICompilationUnit unit, SearchMatch match) throws CoreException; 64 65 public void endReporting() { 66 fCuCache= null; 67 fScannerCache= null; 68 } 69 } 70 71 72 | Popular Tags |