if (visibleNodes.size() >= maxUsages) return false;
if (UsageViewManager.isSelfUsage(usage, new UsageTarget[] { myUsageTarget })) {
return true;
}
Usage usageToAdd = decider.shouldShow(myUsageTarget, usage) ? usage : null;
if (usageToAdd == null) return true;
UsageNode node = usageView.doAppendUsage(usageToAdd);
usages.add(usageToAdd);
if (node != null) {
visibleNodes.add(node);
boolean continueSearch = true;
if (visibleNodes.size() == maxUsages) {
visibleNodes.add(MORE_USAGES_SEPARATOR_NODE);
usages.add(MORE_USAGES_SEPARATOR);
continueSearch = false;
}
pingEDT.ping();
return continueSearch;
}
return true;
}
}
};
final ProgressIndicator indicator =
FindUsagesManager.startProcessUsages(handler, handler.getPrimaryElements(),
handler.getSecondaryElements(), collect, options, new Runnable() {
@Override
public void run() {
ApplicationManager.getApplication().invokeLater(new Runnable() {
@Override
public void run() {
Disposer.dispose(processIcon);
Container parent = processIcon.getParent();
parent.remove(processIcon);
parent.repaint();
pingEDT.ping(); // repaint title
synchronized (usages) {
if (visibleNodes.isEmpty()) {
if (usages.isEmpty()) {
String text = UsageViewBundle.message("no.usages.found.in",
searchScopePresentableName(options, project));
showHint(text, editor, popupPosition, handler, maxUsages, options);
popup.cancel();
} else {
// all usages filtered out
}
} else if (visibleNodes.size() == 1) {
if (usages.size() == 1) {
//the only usage
Usage usage = visibleNodes.iterator().next().getUsage();
usage.navigate(true);
//String message = UsageViewBundle.message("show.usages.only.usage", searchScopePresentableName(options, project));
//navigateAndHint(usage, message, handler, popupPosition, maxUsages, options);
popup.cancel();
} else {
assert usages.size() > 1 : usages;
// usage view can filter usages down to one
Usage visibleUsage = visibleNodes.iterator().next().getUsage();
if (areAllUsagesInOneLine(visibleUsage, usages)) {
String hint = UsageViewBundle.message("all.usages.are.in.this.line",
usages.size(), searchScopePresentableName(options, project));
navigateAndHint(visibleUsage, hint, handler, popupPosition, maxUsages,
options);