GlobalSearchScope (final @NotNull LocalSearchScope scope) { PsiElement[] localScopeElements = scope.getScope(); if (localScopeElements.length == 0) { return this; } return new GlobalSearchScope(localScopeElements[0].getProject()) { @Override public boolean contains(@NotNull VirtualFile file) { return GlobalSearchScope.this.contains(file) || scope.isInScope(file); } @Override public int compare(@NotNull VirtualFile file1, @NotNull VirtualFile file2) { return GlobalSearchScope.this.contains(file1) && GlobalSearchScope.this.contains(file2) ? GlobalSearchScope.this.compare(file1, file2) : 0; } @Override public boolean isSearchInModuleContent(@NotNull Module aModule) { return GlobalSearchScope.this.isSearchInModuleContent(aModule); } @Override public boolean isSearchInLibraries() { return GlobalSearchScope.this.isSearchInLibraries(); } @Override public @NotNull Collection<UnloadedModuleDescription> getUnloadedModulesBelongingToScope() { return GlobalSearchScope.this.getUnloadedModulesBelongingToScope(); } @Override public @NonNls String toString() { return "UnionToLocal: (" + GlobalSearchScope.this + ", " + scope + ")"; } }; }