public static boolean isTooExpensiveToSearch(PsiNamedElement element, boolean zeroResult) {
   final String name = element.getName();
   if (name == null) {
     return true;
   }
   final ProgressManager progressManager = ProgressManager.getInstance();
   final PsiSearchHelper searchHelper = PsiSearchHelper.SERVICE.getInstance(element.getProject());
   final SearchScope useScope = element.getUseScope();
   if (!(useScope instanceof GlobalSearchScope)) {
     return zeroResult;
   }
   final PsiSearchHelper.SearchCostResult cost =
       searchHelper.isCheapEnoughToSearch(
           name, (GlobalSearchScope) useScope, null, progressManager.getProgressIndicator());
   if (cost == PsiSearchHelper.SearchCostResult.ZERO_OCCURRENCES) {
     return zeroResult;
   }
   return cost == PsiSearchHelper.SearchCostResult.TOO_MANY_OCCURRENCES;
 }
  public MemberInplaceRenamer(
      @NotNull PsiNamedElement elementToRename,
      PsiElement substituted,
      Editor editor,
      String initialName,
      String oldName) {
    super(elementToRename, editor, elementToRename.getProject(), initialName, oldName);
    mySubstituted = substituted;
    if (mySubstituted != null
        && mySubstituted != myElementToRename
        && mySubstituted.getTextRange() != null) {
      final PsiFile containingFile = mySubstituted.getContainingFile();
      if (!notSameFile(containingFile.getVirtualFile(), containingFile)) {
        mySubstitutedRange = myEditor.getDocument().createRangeMarker(mySubstituted.getTextRange());
      }
    } else {
      mySubstitutedRange = null;
    }

    showDialogAdvertisement("RenameElement");
  }