CPP-432 File references in CMakeLists.txt files
authorAlexey Utkin <alexey.utkin@jetbrains.com>
Thu, 11 Sep 2014 10:59:55 +0000 (14:59 +0400)
committerAlexey Utkin <alexey.utkin@jetbrains.com>
Thu, 11 Sep 2014 11:05:14 +0000 (15:05 +0400)
platform/core-impl/src/com/intellij/refactoring/rename/FragmentaryPsiReference.java [new file with mode: 0644]
platform/lang-impl/src/com/intellij/refactoring/rename/RenameUtil.java

diff --git a/platform/core-impl/src/com/intellij/refactoring/rename/FragmentaryPsiReference.java b/platform/core-impl/src/com/intellij/refactoring/rename/FragmentaryPsiReference.java
new file mode 100644 (file)
index 0000000..49a3c5a
--- /dev/null
@@ -0,0 +1,21 @@
+/*
+ * Copyright 2000-2014 JetBrains s.r.o.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package com.intellij.refactoring.rename;
+
+public interface FragmentaryPsiReference extends BindablePsiReference {
+  boolean isReadOnlyFragment();
+  boolean isFragmentOnlyRename();
+}
index 59595bcc81d036239e6a1e0a977154e3f3b8bb6b..490efeea17348def3ee2193ad548f0c48baa2f2b 100644 (file)
@@ -240,10 +240,17 @@ public class RenameUtil {
       for (UsageInfo usage : usages) {
         final PsiReference ref = usage.getReference();
         if (ref instanceof BindablePsiReference) {
-          try {
-            ref.bindToElement(namedElement);
+          boolean fallback = true;
+          if (!(ref instanceof FragmentaryPsiReference
+                && ((FragmentaryPsiReference)ref).isFragmentOnlyRename())) {
+            try {
+              ref.bindToElement(namedElement);
+              fallback = false;
+            }
+            catch (IncorrectOperationException ignored) {
+            }
           }
-          catch (IncorrectOperationException e) {//fall back to old scheme
+          if (fallback) {//fall back to old scheme
             ref.handleElementRename(newName);
           }
         }