IDEA-166464 Be able to merge usage from the same line in the "find in path" preview pane dialog

This commit is contained in:
Vassiliy.Kudryashov
2017-05-29 23:36:17 +03:00
parent ff965f80c4
commit 9d8386ef7e
@@ -824,6 +824,7 @@ public class FindPopupPanel extends JBPanel implements FindUI, DataProvider {
final FindUsagesProcessPresentation processPresentation =
FindInProjectUtil.setupProcessPresentation(myProject, showPanelIfOnlyOneUsage, presentation);
Ref<VirtualFile> lastUsageFileRef = new Ref<>();
Ref<Usage> recentUsageRef = new Ref<>();
FindInProjectUtil.findUsages(myHelper.getModel().clone(), myProject, info -> {
if(isCancelled()) {
@@ -838,12 +839,26 @@ public class FindPopupPanel extends JBPanel implements FindUI, DataProvider {
resultsFilesCount.incrementAndGet();
lastUsageFileRef.set(usageFile);
}
final boolean merged;
Usage recent = recentUsageRef.get();
UsageInfo2UsageAdapter recentAdapter =
recent != null && recent instanceof UsageInfo2UsageAdapter ? (UsageInfo2UsageAdapter)recent : null;
UsageInfo2UsageAdapter currentAdapter = usage instanceof UsageInfo2UsageAdapter ? (UsageInfo2UsageAdapter)usage : null;
if (currentAdapter != null && recentAdapter != null && recentAdapter.getFile().equals(usageFile) && recentAdapter.getLine() == currentAdapter.getLine()) {
merged = recentAdapter.merge(currentAdapter);
} else {
merged = false;
}
recentUsageRef.set(usage);
ApplicationManager.getApplication().invokeLater(() -> {
if(isCancelled()) {
return;
}
model.addRow(new Object[]{usage});
if (!merged) {
model.addRow(new Object[]{usage});
}
myCodePreviewComponent.setVisible(true);
if (model.getRowCount() == 1 && myResultsPreviewTable.getModel() == model) {
myResultsPreviewTable.setRowSelectionInterval(0, 0);