GlobalSearchScope (@NotNull Project project, @Nullable RunProfile runProfile) { return new DelegatingGlobalSearchScope(project) { private final NotNullLazyValue<GlobalSearchScope> myLazyValue = NotNullLazyValue.lazy(() -> { if (runProfile instanceof SearchScopeProvidingRunProfile) { GlobalSearchScope scope = ((SearchScopeProvidingRunProfile)runProfile).getSearchScope(); if (scope != null) return scope; } return GlobalSearchScope.allScope(project); }); @Override public @NotNull GlobalSearchScope getDelegate() { return myLazyValue.get(); } }; }