SearchScope (@NotNull List<ScopeOptimizer> optimizers, @NotNull PsiElement element) { boolean seen = false; SearchScope acc = null; for (ScopeOptimizer optimizer : optimizers) { ProgressManager.checkCanceled(); SearchScope scope = optimizer.getRestrictedUseScope(element); if (scope != null) { if (!seen) { seen = true; acc = scope; } else { acc = acc.intersectWith(scope); } } } return seen ? acc : null; }