Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
import org.eclipse.core.resources.IProject;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.ProgressMonitorWrapper;
import org.eclipse.core.runtime.SubMonitor;
import org.eclipse.jdt.core.IJavaProject;
import org.eclipse.jdt.core.JavaCore;
Expand Down Expand Up @@ -187,8 +188,27 @@ private boolean isPackageReferenced(ImportPackageObject pkg, IJavaProject javaPr
SearchPattern pattern = SearchPattern.createPattern(packageName, IJavaSearchConstants.PACKAGE,
IJavaSearchConstants.REFERENCES, SearchPattern.R_EXACT_MATCH);
if (pattern != null) {
engine.search(pattern, new SearchParticipant[] { SearchEngine.getDefaultSearchParticipant() },
searchScope, requestor, monitor);
ProgressMonitorWrapper wrapper = new ProgressMonitorWrapper(monitor) {

@Override
public boolean isCanceled() {
return monitor.isCanceled() || requestor.used;
}

@Override
public void setCanceled(boolean b) {
}
};
try {
engine.search(pattern, new SearchParticipant[] { SearchEngine.getDefaultSearchParticipant() },
searchScope, requestor, wrapper);
} catch (org.eclipse.core.runtime.OperationCanceledException e) {
if (monitor.isCanceled()) {
// the the user really canceled, rethrow it here,
// otherwise we just found a match!
throw e;
}
}
return requestor.used;
}
} catch (CoreException e) {
Expand Down Expand Up @@ -352,10 +372,10 @@ private void minimizeDependencies(Map<String, IPluginImport> usedPlugins, List<I
}

private static class Requestor extends SearchRequestor {
boolean used;
volatile boolean used;

@Override
public void acceptSearchMatch(SearchMatch match) throws CoreException {
public void acceptSearchMatch(SearchMatch match) {
used = true;
}
}
Expand Down
Loading