summaryrefslogtreecommitdiff
path: root/platform/usageView/src/com/intellij/usages/impl/SearchForUsagesRunnable.java
diff options
context:
space:
mode:
Diffstat (limited to 'platform/usageView/src/com/intellij/usages/impl/SearchForUsagesRunnable.java')
-rw-r--r--platform/usageView/src/com/intellij/usages/impl/SearchForUsagesRunnable.java64
1 files changed, 43 insertions, 21 deletions
diff --git a/platform/usageView/src/com/intellij/usages/impl/SearchForUsagesRunnable.java b/platform/usageView/src/com/intellij/usages/impl/SearchForUsagesRunnable.java
index 8b065b30d167..170d1802eee4 100644
--- a/platform/usageView/src/com/intellij/usages/impl/SearchForUsagesRunnable.java
+++ b/platform/usageView/src/com/intellij/usages/impl/SearchForUsagesRunnable.java
@@ -19,6 +19,7 @@ import com.intellij.find.FindManager;
import com.intellij.icons.AllIcons;
import com.intellij.openapi.actionSystem.KeyboardShortcut;
import com.intellij.openapi.application.ApplicationManager;
+import com.intellij.openapi.application.ApplicationNamesInfo;
import com.intellij.openapi.application.ModalityState;
import com.intellij.openapi.editor.Editor;
import com.intellij.openapi.editor.colors.CodeInsightColors;
@@ -71,6 +72,7 @@ class SearchForUsagesRunnable implements Runnable {
@NonNls private static final String FIND_OPTIONS_HREF_TARGET = "FindOptions";
@NonNls private static final String SEARCH_IN_PROJECT_HREF_TARGET = "SearchInProject";
@NonNls private static final String LARGE_FILES_HREF_TARGET = "LargeFiles";
+ @NonNls private static final String SHOW_PROJECT_FILE_OCCURRENCES_HREF_TARGET = "SHOW_PROJECT_FILE_OCCURRENCES";
private final AtomicInteger myUsageCountWithoutDefinition = new AtomicInteger(0);
private final AtomicReference<Usage> myFirstUsage = new AtomicReference<Usage>();
@NotNull
@@ -80,7 +82,7 @@ class SearchForUsagesRunnable implements Runnable {
private final UsageTarget[] mySearchFor;
private final Factory<UsageSearcher> mySearcherFactory;
private final FindUsagesProcessPresentation myProcessPresentation;
- @NotNull private final SearchScope mySearchScope;
+ @NotNull private final SearchScope mySearchScopeToWarnOfFallingOutOf;
private final UsageViewManager.UsageViewStateListener myListener;
private final UsageViewManagerImpl myUsageViewManager;
private final AtomicInteger myOutOfScopeUsages = new AtomicInteger();
@@ -92,7 +94,7 @@ class SearchForUsagesRunnable implements Runnable {
@NotNull UsageTarget[] searchFor,
@NotNull Factory<UsageSearcher> searcherFactory,
@NotNull FindUsagesProcessPresentation processPresentation,
- @NotNull SearchScope scope,
+ @NotNull SearchScope searchScopeToWarnOfFallingOutOf,
@Nullable UsageViewManager.UsageViewStateListener listener) {
myProject = project;
myUsageViewRef = usageViewRef;
@@ -100,7 +102,7 @@ class SearchForUsagesRunnable implements Runnable {
mySearchFor = searchFor;
mySearcherFactory = searcherFactory;
myProcessPresentation = processPresentation;
- mySearchScope = scope;
+ mySearchScopeToWarnOfFallingOutOf = searchScopeToWarnOfFallingOutOf;
myListener = listener;
myUsageViewManager = usageViewManager;
}
@@ -135,25 +137,43 @@ class SearchForUsagesRunnable implements Runnable {
+ UsageViewBundle.message("large.files.were.ignored", largeFiles.size()) + "</a>)";
resultLines.add(shortMessage);
- resultListener = new HyperlinkAdapter(){
- @Override
- protected void hyperlinkActivated(HyperlinkEvent e) {
- if (e.getDescription().equals(LARGE_FILES_HREF_TARGET)) {
- String detailedMessage = detailedLargeFilesMessage(largeFiles);
- List<String> strings = new ArrayList<String>(lines);
- strings.add(detailedMessage);
- ToolWindowManager.getInstance(project).notifyByBalloon(ToolWindowId.FIND, info, wrapInHtml(strings), AllIcons.Actions.Find, listener);
- }
- else if (listener != null) {
- listener.hyperlinkUpdate(e);
- }
+ resultListener = addHrefHandling(resultListener, LARGE_FILES_HREF_TARGET, new Runnable() {
+ public void run() {
+ String detailedMessage = detailedLargeFilesMessage(largeFiles);
+ List<String> strings = new ArrayList<String>(lines);
+ strings.add(detailedMessage);
+ //noinspection SSBasedInspection
+ ToolWindowManager.getInstance(project).notifyByBalloon(ToolWindowId.FIND, info, wrapInHtml(strings), AllIcons.Actions.Find, listener);
}
- };
+ });
}
+ Runnable searchIncludingProjectFileUsages = processPresentation.searchIncludingProjectFileUsages();
+ if (searchIncludingProjectFileUsages != null) {
+ resultLines.add("Occurrences in " + ApplicationNamesInfo.getInstance().getProductName() + " project files are skipped. " +
+ "<a href='" + SHOW_PROJECT_FILE_OCCURRENCES_HREF_TARGET + "'>Include them</a>");
+ resultListener = addHrefHandling(resultListener, SHOW_PROJECT_FILE_OCCURRENCES_HREF_TARGET, searchIncludingProjectFileUsages);
+ }
+
+ //noinspection SSBasedInspection
ToolWindowManager.getInstance(project).notifyByBalloon(ToolWindowId.FIND, info, wrapInHtml(resultLines), AllIcons.Actions.Find, resultListener);
}
+ private static HyperlinkListener addHrefHandling(@Nullable final HyperlinkListener listener,
+ @NotNull final String hrefTarget, @NotNull final Runnable handler) {
+ return new HyperlinkAdapter() {
+ @Override
+ protected void hyperlinkActivated(HyperlinkEvent e) {
+ if (e.getDescription().equals(hrefTarget)) {
+ handler.run();
+ }
+ else if (listener != null) {
+ listener.hyperlinkUpdate(e);
+ }
+ }
+ };
+ }
+
@NotNull
private static String wrapInHtml(@NotNull List<String> strings) {
return XmlStringUtil.wrapInHtml(StringUtil.join(strings, "<br>"));
@@ -319,7 +339,7 @@ class SearchForUsagesRunnable implements Runnable {
ProgressIndicator indicator = ProgressWrapper.unwrap(ProgressManager.getInstance().getProgressIndicator());
if (indicator != null && indicator.isCanceled()) return false;
- if (!UsageViewManagerImpl.isInScope(usage, mySearchScope)) {
+ if (!UsageViewManagerImpl.isInScope(usage, mySearchScopeToWarnOfFallingOutOf)) {
myOutOfScopeUsages.incrementAndGet();
return true;
}
@@ -389,7 +409,7 @@ class SearchForUsagesRunnable implements Runnable {
List<String> lines = new ArrayList<String>();
lines.add(StringUtil.escapeXml(message));
if (myOutOfScopeUsages.get() != 0) {
- lines.add(UsageViewManagerImpl.outOfScopeMessage(myOutOfScopeUsages.get(), mySearchScope));
+ lines.add(UsageViewManagerImpl.outOfScopeMessage(myOutOfScopeUsages.get(), mySearchScopeToWarnOfFallingOutOf));
}
if (myProcessPresentation.isShowFindOptionsPrompt()) {
lines.add(createOptionsHtml(mySearchFor));
@@ -432,7 +452,7 @@ class SearchForUsagesRunnable implements Runnable {
lines.add("Only one usage found.");
if (myOutOfScopeUsages.get() != 0) {
- lines.add(UsageViewManagerImpl.outOfScopeMessage(myOutOfScopeUsages.get(), mySearchScope));
+ lines.add(UsageViewManagerImpl.outOfScopeMessage(myOutOfScopeUsages.get(), mySearchScopeToWarnOfFallingOutOf));
}
lines.add(createOptionsHtml(mySearchFor));
MessageType type = myOutOfScopeUsages.get() == 0 ? MessageType.INFO : MessageType.WARNING;
@@ -456,11 +476,13 @@ class SearchForUsagesRunnable implements Runnable {
hyperlinkListener = null;
}
else {
- lines = Arrays.asList(UsageViewManagerImpl.outOfScopeMessage(myOutOfScopeUsages.get(), mySearchScope), createSearchInProjectHtml());
+ lines = Arrays.asList(UsageViewManagerImpl.outOfScopeMessage(myOutOfScopeUsages.get(), mySearchScopeToWarnOfFallingOutOf), createSearchInProjectHtml());
hyperlinkListener = createSearchInProjectListener();
}
- if (!myProcessPresentation.getLargeFiles().isEmpty() || myOutOfScopeUsages.get() != 0) {
+ if (!myProcessPresentation.getLargeFiles().isEmpty() ||
+ myOutOfScopeUsages.get() != 0 ||
+ myProcessPresentation.searchIncludingProjectFileUsages() != null) {
ApplicationManager.getApplication().invokeLater(new Runnable() {
@Override
public void run() {