mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
fixed PY-8202 Introduce parameter: breaks code when introducing parameter for last ineffective statement
This commit is contained in:
+7
@@ -11,6 +11,7 @@ import com.intellij.refactoring.introduce.inplace.InplaceVariableIntroducer;
|
||||
import com.intellij.refactoring.util.CommonRefactoringUtil;
|
||||
import com.jetbrains.python.PyBundle;
|
||||
import com.jetbrains.python.psi.*;
|
||||
import com.jetbrains.python.psi.impl.PyPsiUtils;
|
||||
import com.jetbrains.python.refactoring.introduce.IntroduceHandler;
|
||||
import com.jetbrains.python.refactoring.introduce.IntroduceOperation;
|
||||
import com.jetbrains.python.refactoring.introduce.variable.VariableValidator;
|
||||
@@ -53,6 +54,12 @@ public class PyIntroduceParameterHandler extends IntroduceHandler {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
protected PsiElement replaceExpression(PsiElement expression, PyExpression newExpression, IntroduceOperation operation) {
|
||||
return PyPsiUtils.replaceExpression(expression, newExpression);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean checkIntroduceContext(PsiFile file, Editor editor, PsiElement element) {
|
||||
if (element != null) {
|
||||
|
||||
@@ -0,0 +1,2 @@
|
||||
def f(a=False):
|
||||
a
|
||||
@@ -0,0 +1,2 @@
|
||||
def f():
|
||||
<selection>False</selection>
|
||||
@@ -27,6 +27,10 @@ public class PyIntroduceParameterTest extends PyIntroduceTestCase {
|
||||
doTest();
|
||||
}
|
||||
|
||||
public void testLastStatement() {
|
||||
doTest();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getTestDataPath() {
|
||||
return super.getTestDataPath() + "/refactoring/introduceParameter";
|
||||
|
||||
Reference in New Issue
Block a user