コード例 #1
0
 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;
 }
コード例 #2
0
  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");
  }