GlobalSearchScope (@NotNull Project project, @Nullable String scopePresentableName) { // logic here is similar to ScopeChooserCombo if (scopePresentableName == null) return GlobalSearchScope.EMPTY_SCOPE; if (OpenFilesScope.getNameText().equals(scopePresentableName)) { return intersectWithContentScope(project, GlobalSearchScopes.openFilesScope(project)); } if (PredefinedSearchScopeProviderImpl.getCurrentFileScopeName().equals(scopePresentableName)) { VirtualFile[] array = FileEditorManager.getInstance(project).getSelectedFiles(); List<VirtualFile> files = ContainerUtil.createMaybeSingletonList(ArrayUtil.getFirstElement(array)); GlobalSearchScope scope = GlobalSearchScope.filesScope(project, files, PredefinedSearchScopeProviderImpl.getCurrentFileScopeName()); return intersectWithContentScope(project, scope); } PredefinedSearchScopeProvider scopeProvider = PredefinedSearchScopeProvider.getInstance(); for (SearchScope scope : scopeProvider.getPredefinedScopes(project, null, false, false, false, false, true)) { if (scope instanceof GlobalSearchScope && scope.getDisplayName().equals(scopePresentableName)) { if (scope instanceof ScratchesSearchScope) { return (ScratchesSearchScope)scope; } return intersectWithContentScope(project, (GlobalSearchScope)scope); } } for (FindInProjectExtension extension : FindInProjectExtension.EP_NAME.getExtensionList()) { for (NamedScope scope : extension.getFilteredNamedScopes(project)) { if (scope.getPresentableName().equals(scopePresentableName)) { return intersectWithContentScope(project, GlobalSearchScopesCore.filterScope(project, scope)); } } } for (NamedScopesHolder holder : NamedScopesHolder.getAllNamedScopeHolders(project)) { final NamedScope[] scopes = holder.getEditableScopes(); // predefined scopes already included for (NamedScope scope : scopes) { if (scope.getScopeId().equals(scopePresentableName)) { return intersectWithContentScope(project, GlobalSearchScopesCore.filterScope(project, scope)); } } } if (scopePresentableName.startsWith("Module '") && scopePresentableName.endsWith("'")) { // Backward compatibility with previous File Watchers behavior. // It never worked correctly for scopes like "Module 'foo'" and always returned ProjectFilesScope in such cases. return ProjectScope.getContentScope(project); } return GlobalSearchScope.EMPTY_SCOPE; }