From 41127c84052455a49ca1fa4c2dc0298716fda46d Mon Sep 17 00:00:00 2001 From: peter Date: Thu, 11 Sep 2014 16:15:35 +0200 Subject: [PATCH] debugging IDEA-127750 (Sometimes find in path is working after second invocation only) * Show a separate balloon when the usage search is canceled (instead of '0 usages found') * Add debug logging --- .../com/intellij/find/impl/FindInProjectTask.java | 12 +++++++++++- .../usages/FindUsagesProcessPresentation.java | 10 ++++++++++ .../usages/impl/SearchForUsagesRunnable.java | 8 +++++++- 3 files changed, 28 insertions(+), 2 deletions(-) diff --git a/platform/lang-impl/src/com/intellij/find/impl/FindInProjectTask.java b/platform/lang-impl/src/com/intellij/find/impl/FindInProjectTask.java index 3ff6408f61a4..822ffbb64037 100644 --- a/platform/lang-impl/src/com/intellij/find/impl/FindInProjectTask.java +++ b/platform/lang-impl/src/com/intellij/find/impl/FindInProjectTask.java @@ -128,6 +128,9 @@ class FindInProjectTask { } }); myProgress.setIndeterminate(false); + if (LOG.isDebugEnabled()) { + LOG.debug("Searching for " + myFindModel.getStringToFind() + " in " + filesForFastWordSearch.size() + " indexed files"); + } searchInFiles(filesForFastWordSearch, processPresentation, consumer); @@ -137,6 +140,10 @@ class FindInProjectTask { final Collection otherFiles = collectFilesInScope(filesForFastWordSearch, skipIndexed); myProgress.setIndeterminate(false); + if (LOG.isDebugEnabled()) { + LOG.debug("Searching for " + myFindModel.getStringToFind() + " in " + otherFiles.size() + " non-indexed files"); + } + long start = System.currentTimeMillis(); searchInFiles(otherFiles, processPresentation, consumer); if (skipIndexed && otherFiles.size() > 1000) { @@ -144,7 +151,10 @@ class FindInProjectTask { } } catch (ProcessCanceledException e) { - // fine + processPresentation.setCanceled(true); + if (LOG.isDebugEnabled()) { + LOG.debug("Usage search canceled", e); + } } if (!myLargeFiles.isEmpty()) { diff --git a/platform/usageView/src/com/intellij/usages/FindUsagesProcessPresentation.java b/platform/usageView/src/com/intellij/usages/FindUsagesProcessPresentation.java index 2248182a3c5c..c303c7fd0496 100644 --- a/platform/usageView/src/com/intellij/usages/FindUsagesProcessPresentation.java +++ b/platform/usageView/src/com/intellij/usages/FindUsagesProcessPresentation.java @@ -43,6 +43,7 @@ public class FindUsagesProcessPresentation { private Collection myLargeFiles; private boolean myShowFindOptionsPrompt = true; private Runnable mySearchWithProjectFiles; + private boolean myCanceled; public FindUsagesProcessPresentation(@NotNull UsageViewPresentation presentation) { myUsageViewPresentation = presentation; @@ -112,6 +113,15 @@ public class FindUsagesProcessPresentation { public void setShowFindOptionsPrompt(boolean showFindOptionsPrompt) { myShowFindOptionsPrompt = showFindOptionsPrompt; } + + + public void setCanceled(boolean canceled) { + myCanceled = canceled; + } + + public boolean isCanceled() { + return myCanceled; + } } diff --git a/platform/usageView/src/com/intellij/usages/impl/SearchForUsagesRunnable.java b/platform/usageView/src/com/intellij/usages/impl/SearchForUsagesRunnable.java index 8771ef75502b..6e5e93f3ed96 100644 --- a/platform/usageView/src/com/intellij/usages/impl/SearchForUsagesRunnable.java +++ b/platform/usageView/src/com/intellij/usages/impl/SearchForUsagesRunnable.java @@ -122,7 +122,7 @@ class SearchForUsagesRunnable implements Runnable { return "Search in Project"; } - private static void notifyByFindBalloon(final HyperlinkListener listener, + private static void notifyByFindBalloon(@Nullable final HyperlinkListener listener, @NotNull final MessageType info, @NotNull FindUsagesProcessPresentation processPresentation, @NotNull final Project project, @@ -400,6 +400,12 @@ class SearchForUsagesRunnable implements Runnable { ApplicationManager.getApplication().invokeLater(new Runnable() { @Override public void run() { + if (myProcessPresentation.isCanceled()) { + notifyByFindBalloon(null, MessageType.WARNING, myProcessPresentation, myProject, Arrays.asList("Usage search was canceled")); + findStartedBalloonShown.set(false); + return; + } + final List notFoundActions = myProcessPresentation.getNotFoundActions(); final String message = UsageViewBundle.message("dialog.no.usages.found.in", StringUtil.decapitalize(myPresentation.getUsagesString()),