diff --git a/java/java-impl/src/com/intellij/refactoring/introduceField/InplaceIntroduceConstantPopup.java b/java/java-impl/src/com/intellij/refactoring/introduceField/InplaceIntroduceConstantPopup.java index 1f2f0cee73c6..5f34e07a9ab3 100644 --- a/java/java-impl/src/com/intellij/refactoring/introduceField/InplaceIntroduceConstantPopup.java +++ b/java/java-impl/src/com/intellij/refactoring/introduceField/InplaceIntroduceConstantPopup.java @@ -418,11 +418,11 @@ public class InplaceIntroduceConstantPopup { } } - if (myAnchorIdxIfAll != -1) { + if (myAnchorIdxIfAll != -1 && myOccurrences[myAnchorIdxIfAll] != null) { myAnchorElementIfAll = myOccurrences[myAnchorIdxIfAll].getParent(); } - if (myAnchorIdx != -1) { + if (myAnchorIdx != -1 && myOccurrences[myAnchorIdx] != null) { myAnchorElement = myOccurrences[myAnchorIdx].getParent(); } myOccurrenceMarkers = null; diff --git a/java/java-impl/src/com/intellij/refactoring/introduceField/InplaceIntroduceFieldPopup.java b/java/java-impl/src/com/intellij/refactoring/introduceField/InplaceIntroduceFieldPopup.java index 7e2f140c9820..6a8f6e64a3eb 100644 --- a/java/java-impl/src/com/intellij/refactoring/introduceField/InplaceIntroduceFieldPopup.java +++ b/java/java-impl/src/com/intellij/refactoring/introduceField/InplaceIntroduceFieldPopup.java @@ -335,8 +335,8 @@ public class InplaceIntroduceFieldPopup { final BaseExpressionToFieldHandler.ConvertToFieldRunnable convertToFieldRunnable = new BaseExpressionToFieldHandler.ConvertToFieldRunnable(myInitializerExpression, settings, settings.getForcedType(), myOccurrences, myOccurenceManager, - myAnchorIdxIfAll != -1? myOccurrences[myAnchorIdxIfAll].getParent() : myAnchorElementIfAll, - myAnchorIdx != -1 ? myOccurrences[myAnchorIdx].getParent() : myAnchorElement, myEditor, + myAnchorIdxIfAll != -1 && myOccurrences[myAnchorIdxIfAll] != null ? myOccurrences[myAnchorIdxIfAll].getParent() : myAnchorElementIfAll, + myAnchorIdx != -1 && myOccurrences[myAnchorIdx] != null ? myOccurrences[myAnchorIdx].getParent() : myAnchorElement, myEditor, myParentClass); convertToFieldRunnable.run(); }