Skip to content

Commit

Permalink
Fix for issue #234: use cancel instead of force to prevent blocking
Browse files Browse the repository at this point in the history
  • Loading branch information
eric-milles committed Jan 7, 2017
1 parent e880081 commit 1ed9612
Showing 1 changed file with 3 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
import org.codehaus.groovy.eclipse.core.GroovyCore;
import org.codehaus.jdt.groovy.model.GroovyCompilationUnit;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.OperationCanceledException;
import org.eclipse.jdt.core.Flags;
import org.eclipse.jdt.core.IJavaElement;
import org.eclipse.jdt.core.ISourceRange;
Expand Down Expand Up @@ -78,7 +79,7 @@ public List<TypeNameMatch> getFoundInfos() {
*
* @see OrganizeImportsOperation.TypeReferenceProcessor#process(org.eclipse.core.runtime.IProgressMonitor)
*/
public void searchForTypes(GroovyCompilationUnit unit, Map<String, UnresolvedTypeData> missingTypes, IProgressMonitor monitor) throws JavaModelException {
public void searchForTypes(GroovyCompilationUnit unit, Map<String, UnresolvedTypeData> missingTypes, IProgressMonitor monitor) throws JavaModelException, OperationCanceledException {
char[][] allTypes = new char[missingTypes.size()][];
int i = 0;
for (String simpleName : missingTypes.keySet()) {
Expand All @@ -87,7 +88,7 @@ public void searchForTypes(GroovyCompilationUnit unit, Map<String, UnresolvedTyp
final List<TypeNameMatch> typesFound = new ArrayList<TypeNameMatch>();
TypeNameMatchCollector collector = new TypeNameMatchCollector(typesFound);
IJavaSearchScope scope = SearchEngine.createJavaSearchScope(new IJavaElement[] {unit.getJavaProject()});
int policy = (monitor == null ? IJavaSearchConstants.FORCE_IMMEDIATE_SEARCH : IJavaSearchConstants.WAIT_UNTIL_READY_TO_SEARCH);
int policy = (monitor == null ? IJavaSearchConstants.CANCEL_IF_NOT_READY_TO_SEARCH : IJavaSearchConstants.WAIT_UNTIL_READY_TO_SEARCH);
new SearchEngine().searchAllTypeNames(null, allTypes, scope, collector, policy, monitor);

for (TypeNameMatch match : typesFound) {
Expand Down

0 comments on commit 1ed9612

Please sign in to comment.