do not wait for user dismiss "Too many usages" dialog under the read action

This commit is contained in:
Alexey Kudravtsev
2013-05-31 16:32:07 +04:00
parent 3c34b8073d
commit 079d29ffaf
7 changed files with 170 additions and 121 deletions
@@ -25,6 +25,7 @@ import com.intellij.openapi.diagnostic.Logger;
import com.intellij.openapi.progress.ProcessCanceledException;
import com.intellij.openapi.progress.ProgressIndicator;
import com.intellij.openapi.progress.ProgressIndicatorProvider;
import com.intellij.openapi.progress.util.FindUsagesIndicator;
import com.intellij.openapi.roots.FileIndexFacade;
import com.intellij.openapi.util.*;
import com.intellij.openapi.util.text.StringUtil;
@@ -202,8 +203,12 @@ public class PsiSearchHelperImpl implements PsiSearchHelper {
final AsyncFuture<Boolean> result = processPsiFileRootsAsync(fileSet, new Processor<PsiElement>() {
@Override
public boolean process(PsiElement psiRoot) {
return LowLevelSearchUtil.processElementsContainingWordInElement(processor, psiRoot, searcher, true, progress);
public boolean process(final PsiElement psiRoot) {
return ApplicationManager.getApplication().runReadAction(new Computable<Boolean>() {
public Boolean compute() {
return LowLevelSearchUtil.processElementsContainingWordInElement(processor, psiRoot, searcher, true, progress);
}
});
}
}, progress);
return new FinallyFuture<Boolean>(result, new Runnable() {
@@ -238,32 +243,37 @@ public class PsiSearchHelperImpl implements PsiSearchHelper {
});
if (file != null && !(file instanceof PsiBinaryFile)) {
file.getViewProvider().getContents(); // load contents outside readaction
ApplicationManager.getApplication().runReadAction(new Runnable() {
@Override
public void run() {
try {
if (myManager.getProject().isDisposed()) throw new ProcessCanceledException();
List<PsiFile> psiRoots = file.getViewProvider().getAllFiles();
Set<PsiElement> processed = new THashSet<PsiElement>(psiRoots.size() * 2, (float)0.5);
for (PsiElement psiRoot : psiRoots) {
if (progress != null) progress.checkCanceled();
assert psiRoot != null : "One of the roots of file " + file + " is null. All roots: " + psiRoots +
"; ViewProvider: " + file.getViewProvider() + "; Virtual file: " + file.getViewProvider().getVirtualFile();
if (!processed.add(psiRoot)) continue;
if (!psiRoot.isValid()) continue;
if (!psiRootProcessor.process(psiRoot)) {
canceled.set(true);
return;
}
}
myManager.dropResolveCaches();
try {
if (myManager.getProject().isDisposed()) throw new ProcessCanceledException();
List<PsiFile> psiRoots = ApplicationManager.getApplication().runReadAction(new Computable<List<PsiFile>>() {
public List<PsiFile> compute() {
return file.getViewProvider().getAllFiles();
}
catch (ProcessCanceledException e) {
});
Set<PsiElement> processed = new THashSet<PsiElement>(psiRoots.size() * 2, (float)0.5);
for (final PsiElement psiRoot : psiRoots) {
if (progress != null) progress.checkCanceled();
assert psiRoot != null : "One of the roots of file " + file + " is null. All roots: " + psiRoots +
"; ViewProvider: " + file.getViewProvider() + "; Virtual file: " + file.getViewProvider().getVirtualFile();
if (!processed.add(psiRoot)) continue;
if (!ApplicationManager.getApplication().runReadAction(new Computable<Boolean>() {
public Boolean compute() {
return psiRoot.isValid();
}
})) {
continue;
}
if (!psiRootProcessor.process(psiRoot)) {
canceled.set(true);
pceThrown.set(true);
break;
}
}
});
myManager.dropResolveCaches();
}
catch (ProcessCanceledException e) {
canceled.set(true);
pceThrown.set(true);
}
}
if (progress != null && progress.isRunning()) {
double fraction = (double)counter.incrementAndGet() / size;
@@ -396,6 +406,7 @@ public class PsiSearchHelperImpl implements PsiSearchHelper {
});
final StringSearcher searcher = new StringSearcher(qName, true, true, false);
final int patternLength = searcher.getPattern().length();
if (progress != null) {
progress.pushState();
@@ -417,25 +428,32 @@ public class PsiSearchHelperImpl implements PsiSearchHelper {
final PsiFile psiFile = files[i];
if (psiFile instanceof PsiBinaryFile) continue;
ApplicationManager.getApplication().runReadAction(new Runnable() {
@Override
public void run() {
CharSequence text = psiFile.getViewProvider().getContents();
final char[] textArray = CharArrayUtil.fromSequenceWithoutCopying(text);
for (int index = LowLevelSearchUtil.searchWord(text, textArray, 0, text.length(), searcher, progress); index >= 0;) {
PsiReference referenceAt = psiFile.findReferenceAt(index);
if (referenceAt == null || useScope == null ||
!PsiSearchScopeUtil.isInScope(useScope.intersectWith(initialScope), psiFile)) {
if (!processor.process(psiFile, index, index + searcher.getPattern().length())) {
cancelled.set(Boolean.TRUE);
return;
}
}
index = LowLevelSearchUtil.searchWord(text, textArray, index + searcher.getPattern().length(), text.length(), searcher, progress);
}
final CharSequence text = ApplicationManager.getApplication().runReadAction(new Computable<CharSequence>() {
public CharSequence compute() {
return psiFile.getViewProvider().getContents();
}
});
final char[] textArray = ApplicationManager.getApplication().runReadAction(new Computable<char[]>() {
public char[] compute() {
return CharArrayUtil.fromSequenceWithoutCopying(text);
}
});
for (int index = LowLevelSearchUtil.searchWord(text, textArray, 0, text.length(), searcher, progress); index >= 0;) {
final int finalIndex = index;
boolean isReferenceOK = ApplicationManager.getApplication().runReadAction(new Computable<Boolean>() {
public Boolean compute() {
PsiReference referenceAt = psiFile.findReferenceAt(finalIndex);
return referenceAt == null || useScope == null ||
!PsiSearchScopeUtil.isInScope(useScope.intersectWith(initialScope), psiFile);
}
});
if (isReferenceOK && !processor.process(psiFile, index, index + patternLength)) {
cancelled.set(Boolean.TRUE);
break;
}
index = LowLevelSearchUtil.searchWord(text, textArray, index + patternLength, text.length(), searcher, progress);
}
if (cancelled.get()) break;
if (progress != null) {
progress.setFraction((double)(i + 1) / files.length);
@@ -636,12 +654,23 @@ public class PsiSearchHelperImpl implements PsiSearchHelper {
final AsyncFuture<Boolean> result =
processPsiFileRootsAsync(new ArrayList<VirtualFile>(candidateFiles.keySet()), new Processor<PsiElement>() {
@Override
public boolean process(PsiElement psiRoot) {
final VirtualFile vfile = psiRoot.getContainingFile().getVirtualFile();
public boolean process(final PsiElement psiRoot) {
if (progress instanceof FindUsagesIndicator) {
((FindUsagesIndicator)progress).pauseProcessingIfTooManyUsages();
}
final VirtualFile vfile = ApplicationManager.getApplication().runReadAction(new Computable<VirtualFile>() {
public VirtualFile compute() {
return psiRoot.getContainingFile().getVirtualFile();
}
});
for (final RequestWithProcessor singleRequest : candidateFiles.get(vfile)) {
StringSearcher searcher = searchers.get(singleRequest);
TextOccurenceProcessor adapted = adaptProcessor(singleRequest.request, singleRequest.refProcessor);
if (!LowLevelSearchUtil.processElementsContainingWordInElement(adapted, psiRoot, searcher, true, progress)) {
final StringSearcher searcher = searchers.get(singleRequest);
final TextOccurenceProcessor adapted = adaptProcessor(singleRequest.request, singleRequest.refProcessor);
if (!ApplicationManager.getApplication().runReadAction(new Computable<Boolean>() {
public Boolean compute() {
return LowLevelSearchUtil.processElementsContainingWordInElement(adapted, psiRoot, searcher, true, progress);
}
})) {
return false;
}
}
@@ -40,6 +40,7 @@ import com.intellij.openapi.ui.popup.JBPopup;
import com.intellij.openapi.ui.popup.JBPopupFactory;
import com.intellij.openapi.ui.popup.PopupChooserBuilder;
import com.intellij.openapi.util.Comparing;
import com.intellij.openapi.util.Computable;
import com.intellij.openapi.util.Condition;
import com.intellij.openapi.util.Disposer;
import com.intellij.openapi.vfs.VirtualFile;
@@ -302,11 +303,15 @@ public class ShowUsagesAction extends AnAction implements PopupAction {
Processor<Usage> collect = new Processor<Usage>() {
private final UsageTarget[] myUsageTarget = {new PsiElement2UsageTargetAdapter(handler.getPsiElement())};
@Override
public boolean process(@NotNull Usage usage) {
public boolean process(@NotNull final Usage usage) {
synchronized (usages) {
if (visibleNodes.size() >= maxUsages) return false;
if(UsageViewManager.isSelfUsage(usage, myUsageTarget)) return true;
UsageNode node = usageView.doAppendUsage(usage);
UsageNode node = ApplicationManager.getApplication().runReadAction(new Computable<UsageNode>() {
public UsageNode compute() {
return usageView.doAppendUsage(usage);
}
});
usages.add(usage);
if (node != null) {
visibleNodes.add(node);
@@ -26,7 +26,6 @@ import com.intellij.openapi.actionSystem.ActionManager;
import com.intellij.openapi.actionSystem.AnAction;
import com.intellij.openapi.actionSystem.IdeActions;
import com.intellij.openapi.application.ApplicationManager;
import com.intellij.openapi.application.ReadActionProcessor;
import com.intellij.openapi.diagnostic.Logger;
import com.intellij.openapi.editor.Document;
import com.intellij.openapi.editor.Editor;
@@ -391,8 +390,13 @@ public class FindUsagesManager implements JDOMExternalizable {
}
final Processor<UsageInfo> usageInfoProcessor = new CommonProcessors.UniqueProcessor<UsageInfo>(new Processor<UsageInfo>() {
@Override
public boolean process(UsageInfo usageInfo) {
return processor.process(UsageInfoToUsageConverter.convert(descriptor, usageInfo));
public boolean process(final UsageInfo usageInfo) {
Usage usage = ApplicationManager.getApplication().runReadAction(new Computable<Usage>() {
public Usage compute() {
return UsageInfoToUsageConverter.convert(descriptor, usageInfo);
}
});
return processor.process(usage);
}
});
final List<? extends PsiElement> elements =
@@ -434,10 +438,16 @@ public class FindUsagesManager implements JDOMExternalizable {
}
});
PsiSearchHelper.SERVICE.getInstance(project)
.processRequests(options.fastTrack, new ReadActionProcessor<PsiReference>() {
.processRequests(options.fastTrack, new Processor<PsiReference>() {
@Override
public boolean processInReadAction(final PsiReference ref) {
return !ref.getElement().isValid() || usageInfoProcessor.process(new UsageInfo(ref));
public boolean process(final PsiReference ref) {
UsageInfo info = ApplicationManager.getApplication().runReadAction(new Computable<UsageInfo>() {
public UsageInfo compute() {
if (!ref.getElement().isValid()) return null;
return new UsageInfo(ref);
}
});
return info == null || usageInfoProcessor.process(info);
}
});
}
@@ -71,8 +71,12 @@ public class TextOccurrencesUtil {
return helper.processUsagesInNonJavaFiles(element, stringToSearch, new PsiNonJavaFileReferenceProcessor() {
@Override
public boolean process(PsiFile psiFile, int startOffset, int endOffset) {
UsageInfo usageInfo = factory.createUsageInfo(psiFile, startOffset, endOffset);
public boolean process(final PsiFile psiFile, final int startOffset, final int endOffset) {
UsageInfo usageInfo = ApplicationManager.getApplication().runReadAction(new Computable<UsageInfo>() {
public UsageInfo compute() {
return factory.createUsageInfo(psiFile, startOffset, endOffset);
}
});
return usageInfo == null || processor.process(usageInfo);
}
}, searchScope);
@@ -28,6 +28,7 @@ import com.intellij.openapi.ide.CopyPasteManager;
import com.intellij.openapi.progress.ProgressIndicator;
import com.intellij.openapi.progress.ProgressManager;
import com.intellij.openapi.progress.Task;
import com.intellij.openapi.progress.util.FindUsagesIndicator;
import com.intellij.openapi.project.DumbAware;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.ui.Messages;
@@ -73,8 +74,6 @@ import java.awt.event.*;
import java.util.*;
import java.util.List;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicInteger;
/**
@@ -257,9 +256,9 @@ public class UsageViewImpl implements UsageView, UsageModelTracker.UsageModelTra
protected boolean searchHasBeenCancelled() {
return false;
}
protected void setCurrentSearchCancelled(boolean flag){}
private void setupCentralPanel() {
myCentralPanel.removeAll();
disposeUsageContextPanels();
@@ -750,14 +749,14 @@ public class UsageViewImpl implements UsageView, UsageModelTracker.UsageModelTra
}
private void doReRun() {
final AtomicInteger tooManyUsages = new AtomicInteger();
final CountDownLatch waitWhileUserClick = new CountDownLatch(1);
final AtomicInteger usageCountWithoutDefinition = new AtomicInteger(0);
ProgressManager.getInstance().run(new Task.Backgroundable(myProject, UsageViewManagerImpl.getProgressTitle(myPresentation)) {
final Project project = myProject;
final FindUsagesIndicator findUsagesIndicator = new FindUsagesIndicator();
Task.Backgroundable task = new Task.Backgroundable(project, UsageViewManagerImpl.getProgressTitle(myPresentation)) {
@Override
public void run(@NotNull final ProgressIndicator indicator) {
setSearchInProgress(true);
final com.intellij.usages.UsageViewManager usageViewManager = com.intellij.usages.UsageViewManager.getInstance(myProject);
setCurrentSearchCancelled(false);
myChangesDetected = false;
@@ -766,32 +765,30 @@ public class UsageViewImpl implements UsageView, UsageModelTracker.UsageModelTra
@Override
public boolean process(final Usage usage) {
if (searchHasBeenCancelled()) return false;
if (tooManyUsages.get() == 1) {
try {
waitWhileUserClick.await(1, TimeUnit.SECONDS);
}
catch (InterruptedException ignored) {
}
}
boolean incrementCounter = !com.intellij.usages.UsageViewManager.isSelfUsage(usage, myTargets);
if (incrementCounter) {
final int usageCount = usageCountWithoutDefinition.incrementAndGet();
if (usageCount > UsageLimitUtil.USAGES_LIMIT && tooManyUsages.get() == 0 && tooManyUsages.compareAndSet(0, 1)) {
((UsageViewManagerImpl)usageViewManager)
.showTooManyUsagesWarning(indicator, waitWhileUserClick, usageCountWithoutDefinition.get(), UsageViewImpl.this);
if (usageCount > UsageLimitUtil.USAGES_LIMIT) {
if (findUsagesIndicator.switchTooManyUsagesStatus()) {
UsageViewManagerImpl.showTooManyUsagesWarning(project, findUsagesIndicator, usageCountWithoutDefinition.get(), UsageViewImpl.this);
}
}
appendUsage(usage);
ApplicationManager.getApplication().runReadAction(new Runnable() {
public void run() {
appendUsage(usage);
}
});
}
ProgressIndicator indicator = ProgressManager.getInstance().getProgressIndicator();
return indicator == null || !indicator.isCanceled();
return !findUsagesIndicator.isCanceled();
}
});
drainQueuedUsageNodes();
setSearchInProgress(false);
}
});
};
ProgressManager.getInstance().runProcessWithProgressAsynchronously(task, findUsagesIndicator);
}
private void reset() {
@@ -30,6 +30,8 @@ import com.intellij.openapi.progress.ProcessCanceledException;
import com.intellij.openapi.progress.ProgressIndicator;
import com.intellij.openapi.progress.ProgressManager;
import com.intellij.openapi.progress.Task;
import com.intellij.openapi.progress.util.FindUsagesIndicator;
import com.intellij.openapi.progress.util.ProgressWrapper;
import com.intellij.openapi.project.DumbModeAction;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.ui.MessageType;
@@ -65,8 +67,6 @@ import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.List;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicBoolean;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.concurrent.atomic.AtomicReference;
@@ -141,10 +141,10 @@ public class UsageViewManagerImpl extends UsageViewManager {
processPresentation.setShowNotFoundMessage(showNotFoundMessage);
processPresentation.setShowPanelIfOnlyOneUsage(showPanelIfOnlyOneUsage);
Task task = new Task.Backgroundable(myProject, getProgressTitle(presentation), true, new SearchInBackgroundOption()) {
Task.Backgroundable task = new Task.Backgroundable(myProject, getProgressTitle(presentation), true, new SearchInBackgroundOption()) {
@Override
public void run(@NotNull final ProgressIndicator indicator) {
new SearchForUsagesRunnable(usageView, presentation, searchFor, searcherFactory, processPresentation, listener).run();
new SearchForUsagesRunnable(UsageViewManagerImpl.this.myProject, usageView, presentation, searchFor, searcherFactory, processPresentation, listener).run();
}
@Override
@@ -159,7 +159,8 @@ public class UsageViewManagerImpl extends UsageViewManager {
return new NotificationInfo("Find Usages", "Find Usages Finished", notification);
}
};
ProgressManager.getInstance().run(task);
ProgressManager.getInstance().runProcessWithProgressAsynchronously(task, new FindUsagesIndicator());
//ProgressManager.getInstance().run(task);
return usageView.get();
}
@@ -170,7 +171,7 @@ public class UsageViewManagerImpl extends UsageViewManager {
@NotNull UsageViewPresentation presentation,
@Nullable UsageViewStateListener listener) {
final AtomicReference<UsageViewImpl> usageView = new AtomicReference<UsageViewImpl>();
final SearchForUsagesRunnable runnable = new SearchForUsagesRunnable(usageView, presentation, searchFor, searcherFactory, processPresentation, listener);
final SearchForUsagesRunnable runnable = new SearchForUsagesRunnable(myProject, usageView, presentation, searchFor, searcherFactory, processPresentation, listener);
final Factory<ProgressIndicator> progressIndicatorFactory = processPresentation.getProgressIndicatorFactory();
final ProgressIndicator progressIndicator = progressIndicatorFactory != null ? progressIndicatorFactory.create() : null;
@@ -236,21 +237,21 @@ public class UsageViewManagerImpl extends UsageViewManager {
}
public void showTooManyUsagesWarning(final ProgressIndicator indicator,
@NotNull final CountDownLatch waitWhileUserClick,
final int usageCount,
final UsageViewImpl usageView) {
public static void showTooManyUsagesWarning(@NotNull final Project project,
@NotNull final FindUsagesIndicator indicator,
final int usageCount,
final UsageViewImpl usageView) {
UIUtil.invokeLaterIfNeeded(new Runnable() {
@Override
public void run() {
if (usageView != null && usageView.searchHasBeenCancelled() || indicator != null && indicator.isCanceled()) return;
if (usageView != null && usageView.searchHasBeenCancelled() || indicator.isCanceled()) return;
String message = UsageViewBundle.message("find.excessive.usage.count.prompt", usageCount);
UsageLimitUtil.Result ret = UsageLimitUtil.showTooManyUsagesWarning(myProject, message);
UsageLimitUtil.Result ret = UsageLimitUtil.showTooManyUsagesWarning(project, message);
if (ret == UsageLimitUtil.Result.ABORT && usageView != null) {
usageView.setCurrentSearchCancelled(true);
if (indicator != null) indicator.cancel();
indicator.cancel();
}
waitWhileUserClick.countDown();
indicator.userResponded();
}
});
}
@@ -258,6 +259,7 @@ public class UsageViewManagerImpl extends UsageViewManager {
private class SearchForUsagesRunnable implements Runnable {
private final AtomicInteger myUsageCountWithoutDefinition = new AtomicInteger(0);
private final AtomicReference<Usage> myFirstUsage = new AtomicReference<Usage>();
@NotNull private final Project myProject;
private final AtomicReference<UsageViewImpl> myUsageViewRef;
private final UsageViewPresentation myPresentation;
private final UsageTarget[] mySearchFor;
@@ -266,12 +268,14 @@ public class UsageViewManagerImpl extends UsageViewManager {
private final UsageViewStateListener myListener;
private volatile boolean mySearchHasBeenCancelled;
private SearchForUsagesRunnable(@NotNull AtomicReference<UsageViewImpl> usageView,
private SearchForUsagesRunnable(@NotNull Project project,
@NotNull AtomicReference<UsageViewImpl> usageView,
@NotNull UsageViewPresentation presentation,
@NotNull UsageTarget[] searchFor,
@NotNull Factory<UsageSearcher> searcherFactory,
@NotNull FindUsagesProcessPresentation processPresentation,
@Nullable UsageViewStateListener listener) {
myProject = project;
myUsageViewRef = usageView;
myPresentation = presentation;
mySearchFor = searchFor;
@@ -286,7 +290,7 @@ public class UsageViewManagerImpl extends UsageViewManager {
if (usageView != null) return usageView;
int usageCount = myUsageCountWithoutDefinition.get();
if (usageCount >= 2 || usageCount == 1 && myProcessPresentation.isShowPanelIfOnlyOneUsage()) {
usageView = new MyUsageViewImpl();
usageView = new MyUsageViewImpl(myProject);
if (myUsageViewRef.compareAndSet(null, usageView)) {
openView(usageView);
Usage firstUsage = myFirstUsage.get();
@@ -327,26 +331,17 @@ public class UsageViewManagerImpl extends UsageViewManager {
findUsagesStartedBalloon.addRequest(new Runnable() {
@Override
public void run() {
notifyByFindBalloon(null, MessageType.WARNING, myProcessPresentation,"Find Usages in progress...");
notifyByFindBalloon(null, MessageType.WARNING, myProcessPresentation, UsageViewManagerImpl.this.myProject,"Find Usages in progress...");
findStartedBalloonShown.set(true);
}
}, 300, ModalityState.NON_MODAL);
UsageSearcher usageSearcher = mySearcherFactory.create();
final AtomicInteger tooManyUsages = new AtomicInteger();
// 0: ok, 1:warning dialog shown; 2:user closed dialog
final CountDownLatch waitWhileUserClick = new CountDownLatch(1);
usageSearcher.generate(new Processor<Usage>() {
@Override
public boolean process(final Usage usage) {
final ProgressIndicator indicator = ProgressManager.getInstance().getProgressIndicator();
ProgressIndicator indicator = ProgressWrapper.unwrap(ProgressManager.getInstance().getProgressIndicator());
if (searchHasBeenCancelled() || indicator != null && indicator.isCanceled()) return false;
if (tooManyUsages.get() == 1) {
try {
waitWhileUserClick.await(1, TimeUnit.SECONDS);
}
catch (InterruptedException ignored) {
}
}
boolean incrementCounter = !isSelfUsage(usage, mySearchFor);
@@ -358,12 +353,19 @@ public class UsageViewManagerImpl extends UsageViewManager {
final UsageViewImpl usageView = getUsageView();
if (usageCount > UsageLimitUtil.USAGES_LIMIT && tooManyUsages.get() == 0 && tooManyUsages.compareAndSet(0, 1)) {
showTooManyUsagesWarning(indicator, waitWhileUserClick, myUsageCountWithoutDefinition.get(), usageView);
if (usageCount > UsageLimitUtil.USAGES_LIMIT) {
if (indicator instanceof FindUsagesIndicator &&
((FindUsagesIndicator)indicator).switchTooManyUsagesStatus()) {
showTooManyUsagesWarning(myProject, (FindUsagesIndicator)indicator, myUsageCountWithoutDefinition.get(), usageView);
}
}
if (usageView != null) {
usageView.appendUsage(usage);
ApplicationManager.getApplication().runReadAction(new Runnable() {
public void run() {
usageView.appendUsage(usage);
}
});
}
}
return indicator == null || !indicator.isCanceled();
@@ -413,7 +415,7 @@ public class UsageViewManagerImpl extends UsageViewManager {
if (notFoundActions.isEmpty()) {
notifyByFindBalloon(createGotToOptionsListener(mySearchFor),
MessageType.INFO, myProcessPresentation, StringUtil.escapeXml(message), createOptionsHtml());
MessageType.INFO, myProcessPresentation, UsageViewManagerImpl.this.myProject, StringUtil.escapeXml(message), createOptionsHtml());
findStartedBalloonShown.set(false);
}
else {
@@ -446,7 +448,7 @@ public class UsageViewManagerImpl extends UsageViewManager {
flashUsageScriptaculously(usage);
}
notifyByFindBalloon(createGotToOptionsListener(mySearchFor),
MessageType.INFO, myProcessPresentation,"Only one usage found.", createOptionsHtml());
MessageType.INFO, myProcessPresentation, UsageViewManagerImpl.this.myProject,"Only one usage found.", createOptionsHtml());
}
}, ModalityState.NON_MODAL, myProject.getDisposed());
}
@@ -460,7 +462,7 @@ public class UsageViewManagerImpl extends UsageViewManager {
ApplicationManager.getApplication().invokeLater(new Runnable() {
@Override
public void run() {
notifyByFindBalloon(null, MessageType.INFO, myProcessPresentation);
notifyByFindBalloon(null, MessageType.INFO, myProcessPresentation, UsageViewManagerImpl.this.myProject);
}
}, ModalityState.NON_MODAL, myProject.getDisposed());
}
@@ -472,8 +474,8 @@ public class UsageViewManagerImpl extends UsageViewManager {
}
private class MyUsageViewImpl extends UsageViewImpl {
public MyUsageViewImpl() {
super(myProject, SearchForUsagesRunnable.this.myPresentation, mySearchFor, mySearcherFactory);
private MyUsageViewImpl(@NotNull Project project) {
super(project, SearchForUsagesRunnable.this.myPresentation, mySearchFor, mySearcherFactory);
}
@Override
@@ -494,11 +496,12 @@ public class UsageViewManagerImpl extends UsageViewManager {
}
}
private void notifyByFindBalloon(final HyperlinkListener listener,
@NotNull final MessageType info,
@NotNull FindUsagesProcessPresentation processPresentation,
@NotNull String... sLines) {
com.intellij.usageView.UsageViewManager.getInstance(myProject); // in case tool window not registered
private static void notifyByFindBalloon(final HyperlinkListener listener,
@NotNull final MessageType info,
@NotNull FindUsagesProcessPresentation processPresentation,
@NotNull final Project project,
@NotNull String... sLines) {
com.intellij.usageView.UsageViewManager.getInstance(project); // in case tool window not registered
final List<String> lines = new ArrayList<String>(Arrays.asList(sLines));
final Collection<PsiFile> largeFiles = processPresentation.getLargeFiles();
@@ -516,7 +519,7 @@ public class UsageViewManagerImpl extends UsageViewManager {
String detailedMessage = detailedLargeFilesMessage(largeFiles);
List<String> strings = new ArrayList<String>(lines);
strings.add(detailedMessage);
ToolWindowManager.getInstance(myProject).notifyByBalloon(ToolWindowId.FIND, info, wrapInHtml(strings), AllIcons.Actions.Find, listener);
ToolWindowManager.getInstance(project).notifyByBalloon(ToolWindowId.FIND, info, wrapInHtml(strings), AllIcons.Actions.Find, listener);
}
else if (listener != null) {
listener.hyperlinkUpdate(e);
@@ -525,7 +528,7 @@ public class UsageViewManagerImpl extends UsageViewManager {
};
}
ToolWindowManager.getInstance(myProject).notifyByBalloon(ToolWindowId.FIND, info, wrapInHtml(resultLines), AllIcons.Actions.Find, resultListener);
ToolWindowManager.getInstance(project).notifyByBalloon(ToolWindowId.FIND, info, wrapInHtml(resultLines), AllIcons.Actions.Find, resultListener);
}
@NotNull
+1
View File
@@ -8,6 +8,7 @@
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
<orderEntry type="module" module-name="lang-api" />
<orderEntry type="module" module-name="core-impl" />
</component>
</module>