SearchScope (@NotNull PsiField field) { SearchScope scope = field.getUseScope(); if (scope instanceof LocalSearchScope) { return scope; } String name = field.getName(); Project project = field.getProject(); PsiSearchHelper searchHelper = PsiSearchHelper.getInstance(project); if (scope instanceof GlobalSearchScope && searchHelper.isCheapEnoughToSearch(name, (GlobalSearchScope)scope, null, null) == FEW_OCCURRENCES) { return scope; } return null; }