mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
ScopeOptimizer: rename getScopeToRestrict to getRestrictedUseScope
This commit is contained in:
@@ -40,7 +40,7 @@ import java.util.stream.Stream;
|
||||
public interface ScopeOptimizer {
|
||||
|
||||
/**
|
||||
* Please use {@link ScopeOptimizer#getScopeToRestrict(PsiElement)} instead
|
||||
* Please use {@link ScopeOptimizer#getRestrictedUseScope(PsiElement)} instead
|
||||
*/
|
||||
@Deprecated
|
||||
@Nullable("is null when given optimizer can't provide a scope to exclude")
|
||||
@@ -49,18 +49,18 @@ public interface ScopeOptimizer {
|
||||
}
|
||||
|
||||
@Nullable("is null when given optimizer can't provide a scope to restrict")
|
||||
default SearchScope getScopeToRestrict(@NotNull PsiElement element) {
|
||||
default SearchScope getRestrictedUseScope(@NotNull PsiElement element) {
|
||||
GlobalSearchScope scopeToExclude = getScopeToExclude(element);
|
||||
|
||||
return scopeToExclude == null ? null : GlobalSearchScope.notScope(scopeToExclude);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
static SearchScope calculateScopeToRestrict(@NotNull ScopeOptimizer[] optimizers, @NotNull PsiElement element) {
|
||||
static SearchScope calculateOverallRestrictedUseScope(@NotNull ScopeOptimizer[] optimizers, @NotNull PsiElement element) {
|
||||
return Stream
|
||||
.of(optimizers)
|
||||
.peek(optimizer -> ProgressManager.checkCanceled())
|
||||
.map(optimizer -> optimizer.getScopeToRestrict(element))
|
||||
.map(optimizer -> optimizer.getRestrictedUseScope(element))
|
||||
.filter(Objects::nonNull)
|
||||
.reduce((s1, s2) -> s1.intersectWith(s2))
|
||||
.orElse(null);
|
||||
|
||||
@@ -81,7 +81,7 @@ public class SearchRequestCollector {
|
||||
searchScope instanceof GlobalSearchScope &&
|
||||
((searchContext & UsageSearchContext.IN_CODE) != 0 || searchContext == UsageSearchContext.ANY)) {
|
||||
|
||||
final SearchScope restrictedCodeUsageSearchScope = ScopeOptimizer.calculateScopeToRestrict(CODE_USAGE_SCOPE_OPTIMIZER_EP_NAME.getExtensions(), searchTarget);
|
||||
final SearchScope restrictedCodeUsageSearchScope = ScopeOptimizer.calculateOverallRestrictedUseScope(CODE_USAGE_SCOPE_OPTIMIZER_EP_NAME.getExtensions(), searchTarget);
|
||||
if (restrictedCodeUsageSearchScope != null) {
|
||||
short exceptCodeSearchContext = searchContext == UsageSearchContext.ANY
|
||||
? UsageSearchContext.IN_COMMENTS |
|
||||
|
||||
@@ -88,7 +88,7 @@ public class PsiSearchHelperImpl implements PsiSearchHelper {
|
||||
}
|
||||
}
|
||||
|
||||
SearchScope scopeToRestrict = ScopeOptimizer.calculateScopeToRestrict(USE_SCOPE_OPTIMIZER_EP_NAME.getExtensions(), element);
|
||||
SearchScope scopeToRestrict = ScopeOptimizer.calculateOverallRestrictedUseScope(USE_SCOPE_OPTIMIZER_EP_NAME.getExtensions(), element);
|
||||
if (scopeToRestrict != null) {
|
||||
scope = scope.intersectWith(scopeToRestrict);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user