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
This commit is contained in:
peter
2014-09-11 17:22:09 +02:00
parent ff66019d1c
commit 41127c8405
3 changed files with 28 additions and 2 deletions
@@ -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<PsiFile> 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()) {
@@ -43,6 +43,7 @@ public class FindUsagesProcessPresentation {
private Collection<PsiFile> 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;
}
}
@@ -122,7 +122,7 @@ class SearchForUsagesRunnable implements Runnable {
return "<a href='" + SEARCH_IN_PROJECT_HREF_TARGET + "'>Search in Project</a>";
}
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<Action> notFoundActions = myProcessPresentation.getNotFoundActions();
final String message = UsageViewBundle.message("dialog.no.usages.found.in",
StringUtil.decapitalize(myPresentation.getUsagesString()),