mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-10-01 11:20:44 +07:00
ability to show "Current File" always (WEB-20644)
This commit is contained in:
+17
-1
@@ -33,5 +33,21 @@ public abstract class PredefinedSearchScopeProvider {
|
||||
boolean suggestSearchInLibs,
|
||||
boolean prevSearchFiles,
|
||||
boolean currentSelection,
|
||||
boolean usageView);
|
||||
boolean usageView,
|
||||
boolean showEmptyScopes);
|
||||
|
||||
public final List<SearchScope> getPredefinedScopes(@NotNull final Project project,
|
||||
@Nullable final DataContext dataContext,
|
||||
boolean suggestSearchInLibs,
|
||||
boolean prevSearchFiles,
|
||||
boolean currentSelection,
|
||||
boolean usageView) {
|
||||
return getPredefinedScopes(project,
|
||||
dataContext,
|
||||
suggestSearchInLibs,
|
||||
prevSearchFiles,
|
||||
currentSelection,
|
||||
usageView,
|
||||
false);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -52,6 +52,7 @@ public class ScopeChooserCombo extends ComboboxWithBrowseButton implements Dispo
|
||||
private boolean myCurrentSelection = true;
|
||||
private boolean myUsageView = true;
|
||||
private Condition<ScopeDescriptor> myScopeFilter;
|
||||
private boolean myShowEmptyScopes = false;
|
||||
|
||||
public ScopeChooserCombo() {
|
||||
super(new IgnoringComboBox(){
|
||||
@@ -230,7 +231,7 @@ public class ScopeChooserCombo extends ComboboxWithBrowseButton implements Dispo
|
||||
@SuppressWarnings("deprecation") final DataContext context = DataManager.getInstance().getDataContext();
|
||||
for (SearchScope scope : PredefinedSearchScopeProvider.getInstance().getPredefinedScopes(myProject, context, mySuggestSearchInLibs,
|
||||
myPrevSearchFiles, myCurrentSelection,
|
||||
myUsageView)) {
|
||||
myUsageView, myShowEmptyScopes)) {
|
||||
addScopeDescriptor(model, new ScopeDescriptor(scope));
|
||||
}
|
||||
for (ScopeDescriptorProvider provider : Extensions.getExtensions(ScopeDescriptorProvider.EP_NAME)) {
|
||||
@@ -248,6 +249,9 @@ public class ScopeChooserCombo extends ComboboxWithBrowseButton implements Dispo
|
||||
}
|
||||
}
|
||||
|
||||
public void setShowEmptyScopes(boolean showEmptyScopes) {
|
||||
myShowEmptyScopes = showEmptyScopes;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public SearchScope getSelectedScope() {
|
||||
|
||||
+10
-6
@@ -66,7 +66,8 @@ public class PredefinedSearchScopeProviderImpl extends PredefinedSearchScopeProv
|
||||
boolean suggestSearchInLibs,
|
||||
boolean prevSearchFiles,
|
||||
boolean currentSelection,
|
||||
boolean usageView) {
|
||||
boolean usageView,
|
||||
boolean showEmptyScopes) {
|
||||
Collection<SearchScope> result = ContainerUtil.newLinkedHashSet();
|
||||
result.add(GlobalSearchScope.projectScope(project));
|
||||
if (suggestSearchInLibs) {
|
||||
@@ -85,9 +86,7 @@ public class PredefinedSearchScopeProviderImpl extends PredefinedSearchScopeProv
|
||||
: null;
|
||||
final PsiFile psiFile =
|
||||
(selectedTextEditor != null) ? PsiDocumentManager.getInstance(project).getPsiFile(selectedTextEditor.getDocument()) : null;
|
||||
if (psiFile != null) {
|
||||
result.add(new LocalSearchScope(psiFile, IdeBundle.message("scope.current.file")));
|
||||
}
|
||||
PsiFile currentFile = psiFile;
|
||||
|
||||
if (dataContext != null) {
|
||||
PsiElement dataContextElement = CommonDataKeys.PSI_FILE.getData(dataContext);
|
||||
@@ -109,12 +108,17 @@ public class PredefinedSearchScopeProviderImpl extends PredefinedSearchScopeProv
|
||||
result.add(module.getModuleScope());
|
||||
}
|
||||
}
|
||||
if (psiFile == null && dataContextElement.getContainingFile() != null) {
|
||||
result.add(new LocalSearchScope(dataContextElement, IdeBundle.message("scope.current.file")));
|
||||
if (currentFile == null) {
|
||||
currentFile = dataContextElement.getContainingFile();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (currentFile != null || showEmptyScopes) {
|
||||
PsiElement[] scope = currentFile != null ? new PsiElement[] {currentFile} : PsiElement.EMPTY_ARRAY;
|
||||
result.add(new LocalSearchScope(scope, IdeBundle.message("scope.current.file")));
|
||||
}
|
||||
|
||||
if (currentSelection && selectedTextEditor != null && psiFile != null) {
|
||||
SelectionModel selectionModel = selectedTextEditor.getSelectionModel();
|
||||
if (selectionModel.hasSelection()) {
|
||||
|
||||
Reference in New Issue
Block a user