CPP-22673 - fixed compile-time error / extracted new method
authorVladimir Plyashkun <vladimir.plyashkun@jetbrains.com>
Tue, 25 May 2021 11:38:45 +0000 (14:38 +0300)
committerintellij-monorepo-bot <intellij-monorepo-bot-no-reply@jetbrains.com>
Mon, 20 Sep 2021 11:12:28 +0000 (11:12 +0000)
GitOrigin-RevId: 6f84b813fa6d5c1266114548b3d14e0cb2fe7bb2

platform/analysis-impl/src/com/intellij/refactoring/rename/RenameUtilBase.java

index 143b165332b63fa0d3bfc2bb96d14956e12598c4..510983465ad64493888615fc72f51aab3613d01a 100644 (file)
@@ -61,21 +61,8 @@ public final class RenameUtilBase {
     if (hasBindables) {
       for (UsageInfo usage : usages) {
         final PsiReference ref = usage.getReference();
-        if (ref instanceof BindablePsiReference) {
-          boolean fallback = true;
-          if (!(ref instanceof FragmentaryPsiReference
-                && ((FragmentaryPsiReference)ref).isFragmentOnlyRename())) {
-            try {
-              ref.bindToElement(namedElement);
-              fallback = false;
-            }
-            catch (IncorrectOperationException ignored) {
-            }
-          }
-          if (fallback) {//fall back to old scheme
-            ref.handleElementRename(newName);
-          }
-        }
+        if(ref != null)
+          renameReference(namedElement, newName, ref);
       }
     }
     if (listener != null) {
@@ -83,6 +70,23 @@ public final class RenameUtilBase {
     }
   }
 
+  public static void renameReference(@NotNull PsiElement namedElement, String newName, @NotNull PsiReference ref) {
+    if (ref instanceof BindablePsiReference) {
+      boolean fallback = true;
+      if (!(ref instanceof FragmentaryPsiReference && ((FragmentaryPsiReference)ref).isFragmentOnlyRename())) {
+        try {
+          ref.bindToElement(namedElement);
+          fallback = false;
+        }
+        catch (IncorrectOperationException ignored) {
+        }
+      }
+      if (fallback) {//fall back to old scheme
+        ref.handleElementRename(newName);
+      }
+    }
+  }
+
   static void rename(UsageInfo info, String newName) {
     if (info.getElement() == null) return;
     PsiReference ref = info.getReference();