mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
Scopes like "Current file" and "Changed files" should be different event if empty
This commit is contained in:
@@ -115,12 +115,14 @@ public class LocalSearchScope extends SearchScope {
|
||||
if (this == o) return true;
|
||||
if (!(o instanceof LocalSearchScope)) return false;
|
||||
|
||||
final LocalSearchScope localSearchScope = (LocalSearchScope)o;
|
||||
LocalSearchScope other = (LocalSearchScope)o;
|
||||
|
||||
if (other.myIgnoreInjectedPsi != myIgnoreInjectedPsi) return false;
|
||||
if (other.myScope.length != myScope.length) return false;
|
||||
if (!Comparing.strEqual(myDisplayName, other.myDisplayName)) return false; // scopes like "Current file" and "Changed files" should be different event if empty
|
||||
|
||||
if (localSearchScope.myIgnoreInjectedPsi != myIgnoreInjectedPsi) return false;
|
||||
if (localSearchScope.myScope.length != myScope.length) return false;
|
||||
for (final PsiElement scopeElement : myScope) {
|
||||
final PsiElement[] thatScope = localSearchScope.myScope;
|
||||
final PsiElement[] thatScope = other.myScope;
|
||||
for (final PsiElement thatScopeElement : thatScope) {
|
||||
if (!Comparing.equal(scopeElement, thatScopeElement)) return false;
|
||||
}
|
||||
|
||||
+6
-7
@@ -68,7 +68,7 @@ public class PredefinedSearchScopeProviderImpl extends PredefinedSearchScopeProv
|
||||
boolean currentSelection,
|
||||
boolean usageView,
|
||||
boolean showEmptyScopes) {
|
||||
Collection<SearchScope> result = showEmptyScopes ? ContainerUtil.newArrayList() : ContainerUtil.newLinkedHashSet();
|
||||
Collection<SearchScope> result = ContainerUtil.newLinkedHashSet();
|
||||
result.add(GlobalSearchScope.projectScope(project));
|
||||
if (suggestSearchInLibs) {
|
||||
result.add(GlobalSearchScope.allScope(project));
|
||||
@@ -90,8 +90,7 @@ public class PredefinedSearchScopeProviderImpl extends PredefinedSearchScopeProv
|
||||
final Editor selectedTextEditor = ApplicationManager.getApplication().isDispatchThread()
|
||||
? FileEditorManager.getInstance(project).getSelectedTextEditor()
|
||||
: null;
|
||||
final PsiFile psiFile =
|
||||
(selectedTextEditor != null) ? PsiDocumentManager.getInstance(project).getPsiFile(selectedTextEditor.getDocument()) : null;
|
||||
PsiFile psiFile = selectedTextEditor == null ? null : PsiDocumentManager.getInstance(project).getPsiFile(selectedTextEditor.getDocument());
|
||||
PsiFile currentFile = psiFile;
|
||||
|
||||
if (dataContext != null) {
|
||||
@@ -136,7 +135,7 @@ public class PredefinedSearchScopeProviderImpl extends PredefinedSearchScopeProv
|
||||
if (endElement != null) {
|
||||
final PsiElement parent = PsiTreeUtil.findCommonParent(startElement, endElement);
|
||||
if (parent != null) {
|
||||
final List<PsiElement> elements = new ArrayList<PsiElement>();
|
||||
final List<PsiElement> elements = new ArrayList<>();
|
||||
final PsiElement[] children = parent.getChildren();
|
||||
TextRange selection = new TextRange(start, end);
|
||||
for (PsiElement child : children) {
|
||||
@@ -162,13 +161,12 @@ public class PredefinedSearchScopeProviderImpl extends PredefinedSearchScopeProv
|
||||
if (selectedUsageView != null && !selectedUsageView.isSearchInProgress()) {
|
||||
final Set<Usage> usages = ContainerUtil.newTroveSet(selectedUsageView.getUsages());
|
||||
usages.removeAll(selectedUsageView.getExcludedUsages());
|
||||
final List<PsiElement> results = new ArrayList<PsiElement>(usages.size());
|
||||
|
||||
if (prevSearchFiles) {
|
||||
final Set<VirtualFile> files = collectFiles(usages, true);
|
||||
if (!files.isEmpty()) {
|
||||
GlobalSearchScope prev = new GlobalSearchScope(project) {
|
||||
private Set<VirtualFile> myFiles = null;
|
||||
private Set<VirtualFile> myFiles;
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
@@ -203,6 +201,7 @@ public class PredefinedSearchScopeProviderImpl extends PredefinedSearchScopeProv
|
||||
}
|
||||
}
|
||||
else {
|
||||
final List<PsiElement> results = new ArrayList<>(usages.size());
|
||||
for (Usage usage : usages) {
|
||||
if (usage instanceof PsiElementUsage) {
|
||||
final PsiElement element = ((PsiElementUsage)usage).getElement();
|
||||
@@ -294,7 +293,7 @@ public class PredefinedSearchScopeProviderImpl extends PredefinedSearchScopeProv
|
||||
}
|
||||
|
||||
protected static Set<VirtualFile> collectFiles(Set<Usage> usages, boolean findFirst) {
|
||||
final Set<VirtualFile> files = new HashSet<VirtualFile>();
|
||||
final Set<VirtualFile> files = new HashSet<>();
|
||||
for (Usage usage : usages) {
|
||||
if (usage instanceof PsiElementUsage) {
|
||||
PsiElement psiElement = ((PsiElementUsage)usage).getElement();
|
||||
|
||||
Reference in New Issue
Block a user