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);
+ }
}
private boolean myCurrentSelection = true;
private boolean myUsageView = true;
private Condition<ScopeDescriptor> myScopeFilter;
+ private boolean myShowEmptyScopes = false;
public ScopeChooserCombo() {
super(new IgnoringComboBox(){
@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)) {
}
}
+ public void setShowEmptyScopes(boolean showEmptyScopes) {
+ myShowEmptyScopes = showEmptyScopes;
+ }
@Nullable
public SearchScope getSelectedScope() {
boolean suggestSearchInLibs,
boolean prevSearchFiles,
boolean currentSelection,
- boolean usageView) {
+ boolean usageView,
+ boolean showEmptyScopes) {
Collection<SearchScope> result = ContainerUtil.newLinkedHashSet();
result.add(GlobalSearchScope.projectScope(project));
if (suggestSearchInLibs) {
: 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);
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()) {