From ec6d894db4ac99ee323e73d4ddf108b87db95b62 Mon Sep 17 00:00:00 2001 From: anna Date: Tue, 1 Mar 2011 11:10:44 +0100 Subject: [PATCH] inplace introduce parameter: ensure that only param refs would be replaced with old expr --- .../introduceParameter/InplaceIntroduceParameterPopup.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/java/java-impl/src/com/intellij/refactoring/introduceParameter/InplaceIntroduceParameterPopup.java b/java/java-impl/src/com/intellij/refactoring/introduceParameter/InplaceIntroduceParameterPopup.java index 24f3e1059162..895aa80e2892 100644 --- a/java/java-impl/src/com/intellij/refactoring/introduceParameter/InplaceIntroduceParameterPopup.java +++ b/java/java-impl/src/com/intellij/refactoring/introduceParameter/InplaceIntroduceParameterPopup.java @@ -293,9 +293,10 @@ class InplaceIntroduceParameterPopup extends IntroduceParameterSettingsUI { @Nullable private PsiExpression restoreExpression(PsiFile containingFile, PsiElementFactory elementFactory, RangeMarker marker) { if (myExprText == null) return null; + if (myParameter == null || !myParameter.isValid()) return null; final PsiElement refVariableElement = containingFile.findElementAt(marker.getStartOffset()); final PsiExpression expression = PsiTreeUtil.getParentOfType(refVariableElement, PsiReferenceExpression.class); - if (expression != null) { + if (expression instanceof PsiReferenceExpression && ((PsiReferenceExpression)expression).resolve() == myParameter) { return (PsiExpression)expression.replace(elementFactory.createExpressionFromText(myExprText, myMethod)); } return null;