GlobalSearchScope () { GlobalSearchScope scope = GlobalSearchScope.allScope(myProject); if (myExcludeStdlibTests) { scope = scope.intersectWith(GlobalSearchScope.notScope(buildStdlibTestsScope())); } if (myExcludeThirdPartyTypeShedStubs) { scope = scope.intersectWith(GlobalSearchScope.notScope(buildThirdPartyTypeShedStubsScope())); } if (myExcludePythonSkeletonsStubs) { scope = scope.intersectWith(GlobalSearchScope.notScope(buildPythonSkeletonsStubsScope())); } if (myExcludeThirdPartyTests || myExcludeThirdPartyBundledDeps) { scope = scope.intersectWith(GlobalSearchScope.notScope(new QualifiedNameFinder.QualifiedNameBasedScope(myProject) { @Override protected boolean containsQualifiedNameInRoot(@NotNull VirtualFile root, @NotNull QualifiedName qName) { if (THIRD_PARTY_PACKAGE_ROOT_NAMES.contains(root.getName())) { List<String> internalQNameComponents = qName.removeHead(1).getComponents(); if (myExcludeThirdPartyTests && ContainerUtil.exists(internalQNameComponents, TEST_ROOT_NAMES::contains)) { return true; } if (myExcludeThirdPartyBundledDeps && ContainerUtil.exists(internalQNameComponents, BUNDLED_DEPS_ROOT_NAMES::contains)) { return true; } } return false; } })); } return scope; }