private static ThreeState hasUsages(@NotNull PsiElement element,
                                      @NotNull String name,
                                      @NotNull PsiSearchHelper psiSearchHelper,
                                      @NotNull SearchScope searchScope) {
    PsiSearchHelper.SearchCostResult cheapEnough 
      = searchScope instanceof GlobalSearchScope ?
        psiSearchHelper.isCheapEnoughToSearch(name, (GlobalSearchScope)searchScope, null) : null;
    if (cheapEnough == PsiSearchHelper.SearchCostResult.ZERO_OCCURRENCES) {
      return ThreeState.NO;
    }

    if (cheapEnough == PsiSearchHelper.SearchCostResult.TOO_MANY_OCCURRENCES) {
      return ThreeState.UNSURE;
    }

    return ThreeState.fromBoolean(ReferencesSearch.search(element, searchScope, false)
      .anyMatch(reference -> {
        PsiElement referenceElement = reference.getElement();
        return PsiTreeUtil.getParentOfType(referenceElement, PsiImportStatementBase.class) == null &&
               !DeprecationInspectionBase.isElementInsideDeprecated(referenceElement) &&
               !PsiUtil.isInsideJavadocComment(referenceElement);
      }));
  }
private static ThreeState hasUsages(@NotNull PsiElement element,
                                      @NotNull String name,
                                      @NotNull PsiSearchHelper psiSearchHelper,
                                      @NotNull SearchScope searchScope)