use of com.intellij.openapi.application.ReadActionProcessor in project intellij-community by JetBrains.
the class ContributorsBasedGotoByModel method processNames.
@Override
public void processNames(final Processor<String> nameProcessor, final boolean checkBoxState) {
long start = System.currentTimeMillis();
List<ChooseByNameContributor> liveContribs = filterDumb(myContributors);
ProgressIndicator indicator = ProgressManager.getInstance().getProgressIndicator();
Processor<ChooseByNameContributor> processor = new ReadActionProcessor<ChooseByNameContributor>() {
@Override
public boolean processInReadAction(@NotNull ChooseByNameContributor contributor) {
try {
if (!myProject.isDisposed()) {
long contributorStarted = System.currentTimeMillis();
final TIntHashSet filter = new TIntHashSet(1000);
myContributorToItsSymbolsMap.put(contributor, filter);
if (contributor instanceof ChooseByNameContributorEx) {
((ChooseByNameContributorEx) contributor).processNames(s -> {
if (nameProcessor.process(s)) {
filter.add(s.hashCode());
}
return true;
}, FindSymbolParameters.searchScopeFor(myProject, checkBoxState), getIdFilter(checkBoxState));
} else {
String[] names = contributor.getNames(myProject, checkBoxState);
for (String element : names) {
if (nameProcessor.process(element)) {
filter.add(element.hashCode());
}
}
}
if (LOG.isDebugEnabled()) {
LOG.debug(contributor + " for " + (System.currentTimeMillis() - contributorStarted));
}
}
} catch (ProcessCanceledException | IndexNotReadyException ex) {
// index corruption detected, ignore
} catch (Exception ex) {
LOG.error(ex);
}
return true;
}
};
if (!JobLauncher.getInstance().invokeConcurrentlyUnderProgress(liveContribs, indicator, true, processor)) {
throw new ProcessCanceledException();
}
if (indicator != null) {
indicator.checkCanceled();
}
long finish = System.currentTimeMillis();
if (LOG.isDebugEnabled()) {
LOG.debug("processNames(): " + (finish - start) + "ms;");
}
}
Aggregations