IDEA-80163 introduce constant in another class: do not dispose range markers too...
authorAnna Kozlova <anna.kozlova@jetbrains.com>
Tue, 24 Jan 2012 09:45:19 +0000 (13:45 +0400)
committerAnna Kozlova <anna.kozlova@jetbrains.com>
Tue, 24 Jan 2012 10:31:42 +0000 (14:31 +0400)
java/java-impl/src/com/intellij/refactoring/introduceField/InplaceIntroduceConstantPopup.java
platform/lang-impl/src/com/intellij/refactoring/introduce/inplace/InplaceVariableIntroducer.java

index 1c9bc6f99343821ce44996d7f6c21d3eb2e7b863..d94713c4e7e4cb195ded4cb2e1259c2312fa7277 100644 (file)
@@ -175,6 +175,7 @@ public class InplaceIntroduceConstantPopup extends AbstractInplaceIntroduceField
   protected boolean performRefactoring() {
     JavaRefactoringSettings.getInstance().INTRODUCE_CONSTANT_MOVE_TO_ANOTHER_CLASS = myMoveToAnotherClassCb.isSelected();
     if (myMoveToAnotherClassCb.isSelected()) {
+      myEditor.putUserData(INTRODUCE_RESTART, true);
       ApplicationManager.getApplication().invokeLater(new Runnable() {
         @Override
         public void run() {
@@ -190,7 +191,15 @@ public class InplaceIntroduceConstantPopup extends AbstractInplaceIntroduceField
             }
           }
           finally {
+            myEditor.putUserData(INTRODUCE_RESTART, false);
             myEditor.putUserData(ACTIVE_INTRODUCE, null);
+            releaseResources();
+            if (myLocalMarker != null) {
+              myLocalMarker.dispose();
+            }
+            if (myExprMarker != null) {
+              myExprMarker.dispose();
+            }
           }
         }
       });
index db458a9b5b269a7f02da66d7fab73835ea234272..8d7d0c7695214c38fc2272605cb8efc470a93584 100644 (file)
@@ -212,8 +212,7 @@ public abstract class InplaceVariableIntroducer<E extends PsiElement> extends In
   }
 
   protected void releaseIfNotRestart() {
-    final Boolean isRestart = myEditor.getUserData(INTRODUCE_RESTART);
-    if (isRestart == null || !isRestart.booleanValue()) {
+    if (!isRestart()) {
       releaseResources();
     }
   }
@@ -222,8 +221,7 @@ public abstract class InplaceVariableIntroducer<E extends PsiElement> extends In
   public void finish(boolean success) {
     super.finish(success);
     if (myBalloon != null) {
-      final Boolean isRestart = myEditor.getUserData(INTRODUCE_RESTART);
-      if (isRestart == null || !isRestart.booleanValue()) {
+      if (!isRestart()) {
         myBalloon.hide();
       }
     }