1 11 package org.eclipse.jdt.internal.core; 12 13 import org.eclipse.core.runtime.IProgressMonitor; 14 import org.eclipse.core.runtime.OperationCanceledException; 15 import org.eclipse.jdt.core.JavaModelException; 16 import org.eclipse.jdt.core.WorkingCopyOwner; 17 import org.eclipse.jdt.internal.codeassist.ISearchRequestor; 18 import org.eclipse.jdt.internal.compiler.env.NameEnvironmentAnswer; 19 import org.eclipse.jdt.internal.compiler.problem.AbortCompilation; 20 21 22 public class CancelableNameEnvironment extends SearchableEnvironment { 23 public IProgressMonitor monitor; 24 25 public CancelableNameEnvironment(JavaProject project, WorkingCopyOwner owner, IProgressMonitor monitor) throws JavaModelException { 26 super(project, owner); 27 this.monitor = monitor; 28 } 29 30 private void checkCanceled() { 31 if (this.monitor != null && this.monitor.isCanceled()) { 32 if (NameLookup.VERBOSE) 33 System.out.println(Thread.currentThread() + " CANCELLING LOOKUP "); throw new AbortCompilation(true, new OperationCanceledException()); 35 } 36 } 37 38 public void findPackages(char[] prefix, ISearchRequestor requestor) { 39 checkCanceled(); 40 super.findPackages(prefix, requestor); 41 } 42 43 public NameEnvironmentAnswer findType(char[] name, char[][] packageName) { 44 checkCanceled(); 45 return super.findType(name, packageName); 46 } 47 48 public NameEnvironmentAnswer findType(char[][] compoundTypeName) { 49 checkCanceled(); 50 return super.findType(compoundTypeName); 51 } 52 53 public void findTypes(char[] prefix, boolean findMembers, boolean camelCaseMatch, int searchFor, ISearchRequestor storage) { 54 checkCanceled(); 55 super.findTypes(prefix, findMembers, camelCaseMatch, searchFor, storage); 56 } 57 } 58 | Popular Tags |