inplace introduce parameter: ensure that only param refs would be replaced with old expr

This commit is contained in:
anna
2011-03-01 11:56:48 +01:00
parent 494db43540
commit ec6d894db4
@@ -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;