SearchScope () { ApplicationManager.getApplication().assertReadAccessAllowed(); return switch (myType) { case CUSTOM -> myScope; case DIRECTORY -> GlobalSearchScopesCore.directoryScope((PsiDirectory)myElement, true); case FILE -> GlobalSearchScope.fileScope((PsiFile)myElement); case INVALID -> LocalSearchScope.EMPTY; case MODULE -> { GlobalSearchScope moduleScope = GlobalSearchScope.moduleScope(myModule); yield myIncludeTestSource ? moduleScope : GlobalSearchScope.notScope(GlobalSearchScopesCore.projectTestScope(myModule.getProject())).intersectWith(moduleScope); } case MODULES -> GlobalSearchScope.union(myModules.stream().map(m -> GlobalSearchScope.moduleScope(m)).toArray(GlobalSearchScope[]::new)); case PROJECT -> myIncludeTestSource ? GlobalSearchScope.projectScope(myProject) : GlobalSearchScopesCore.projectProductionScope(myProject); case VIRTUAL_FILES -> new GlobalSearchScope() { @Override public boolean contains(@NotNull VirtualFile file) { return getFileSet().contains(file); } @Override public boolean isSearchInModuleContent(@NotNull Module aModule) { return false; } @Override public boolean isSearchInLibraries() { return false; } }; default -> { LOG.error("invalid type " + myType); yield LocalSearchScope.EMPTY; } }; }