public static boolean isTooExpensiveToSearch(PsiNamedElement element, boolean zeroResult) {
    final String name = element.getName();
    if (name == null) {
      return true;
    }
    final SearchScope useScope = element.getUseScope();
    if (!(useScope instanceof GlobalSearchScope globalSearchScope)) {
      return false;
    }
    final PsiSearchHelper searchHelper = PsiSearchHelper.getInstance(element.getProject());
    final PsiSearchHelper.SearchCostResult cost = searchHelper.isCheapEnoughToSearch(name, globalSearchScope, null);
    return cost == PsiSearchHelper.SearchCostResult.ZERO_OCCURRENCES
           ? zeroResult
           : cost == PsiSearchHelper.SearchCostResult.TOO_MANY_OCCURRENCES;
  }
public static boolean isTooExpensiveToSearch(PsiNamedElement element, boolean zeroResult)