Search in sources :

Example 1 with ProjectFilesScope

use of com.intellij.psi.search.scope.ProjectFilesScope in project intellij-community by JetBrains.

the class ScopeChooserUtils method findScopeByName.

@NotNull
public static GlobalSearchScope findScopeByName(@NotNull Project project, @Nullable String scopeName) {
    NamedScope namedScope = scopeName == null ? null : ChangeListsScopesProvider.getInstance(project).getCustomScope(scopeName);
    if (namedScope == null) {
        namedScope = NamedScopesHolder.getScope(project, scopeName);
    }
    if (namedScope == null && OPEN_FILES_SCOPE_NAME.equals(scopeName)) {
        return intersectWithContentScope(project, GlobalSearchScopes.openFilesScope(project));
    }
    if (namedScope == null && CURRENT_FILE_SCOPE_NAME.equals(scopeName)) {
        VirtualFile[] array = FileEditorManager.getInstance(project).getSelectedFiles();
        List<VirtualFile> files = ContainerUtil.createMaybeSingletonList(ArrayUtil.getFirstElement(array));
        GlobalSearchScope scope = GlobalSearchScope.filesScope(project, files, CURRENT_FILE_SCOPE_NAME);
        return intersectWithContentScope(project, scope);
    }
    if (namedScope == null) {
        namedScope = new ProjectFilesScope();
    }
    GlobalSearchScope scope = GlobalSearchScopesCore.filterScope(project, namedScope);
    if (namedScope instanceof ProjectFilesScope || namedScope instanceof ProjectProductionScope) {
        return scope;
    }
    return intersectWithContentScope(project, scope);
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) NamedScope(com.intellij.psi.search.scope.packageSet.NamedScope) GlobalSearchScope(com.intellij.psi.search.GlobalSearchScope) ProjectFilesScope(com.intellij.psi.search.scope.ProjectFilesScope) ProjectProductionScope(com.intellij.psi.search.scope.ProjectProductionScope) NotNull(org.jetbrains.annotations.NotNull)

Aggregations

VirtualFile (com.intellij.openapi.vfs.VirtualFile)1 GlobalSearchScope (com.intellij.psi.search.GlobalSearchScope)1 ProjectFilesScope (com.intellij.psi.search.scope.ProjectFilesScope)1 ProjectProductionScope (com.intellij.psi.search.scope.ProjectProductionScope)1 NamedScope (com.intellij.psi.search.scope.packageSet.NamedScope)1 NotNull (org.jetbrains.annotations.NotNull)1