mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-01-05 01:50:56 +07:00
fixed PY-10964 Extract variable doesn't work as expected inside brackets
fixed PY-10221 Refactor->Extract->Variable may break square bracket symmetry and may break user input there are overlapped reference in python for slice expression (P['x']) one for the reference itself, one for the operator [
This commit is contained in:
@@ -0,0 +1,5 @@
|
||||
P = {'a': 0}
|
||||
M = [42]
|
||||
|
||||
a_ = P['a']
|
||||
M[a_] += 1
|
||||
@@ -0,0 +1,4 @@
|
||||
P = {'a': 0}
|
||||
M = [42]
|
||||
|
||||
M[<selection>P['a']</selection>] += 1
|
||||
@@ -5,6 +5,7 @@ import com.intellij.testFramework.TestDataPath;
|
||||
import com.jetbrains.python.psi.PyCallExpression;
|
||||
import com.jetbrains.python.psi.PyExpression;
|
||||
import com.jetbrains.python.refactoring.introduce.IntroduceHandler;
|
||||
import com.jetbrains.python.refactoring.introduce.IntroduceOperation;
|
||||
import com.jetbrains.python.refactoring.introduce.variable.PyIntroduceVariableHandler;
|
||||
|
||||
import java.util.Collection;
|
||||
@@ -208,6 +209,23 @@ public class PyIntroduceVariableTest extends PyIntroduceTestCase {
|
||||
doTest();
|
||||
}
|
||||
|
||||
// PY-10964
|
||||
public void testMultiReference() {
|
||||
myFixture.configureByFile(getTestName(true) + ".py");
|
||||
boolean inplaceEnabled = myFixture.getEditor().getSettings().isVariableInplaceRenameEnabled();
|
||||
try {
|
||||
myFixture.getEditor().getSettings().setVariableInplaceRenameEnabled(true);
|
||||
IntroduceHandler handler = createHandler();
|
||||
final IntroduceOperation operation = new IntroduceOperation(myFixture.getProject(), myFixture.getEditor(), myFixture.getFile(), "a_");
|
||||
operation.setReplaceAll(true);
|
||||
handler.performAction(operation);
|
||||
myFixture.checkResultByFile(getTestName(true) + ".after.py");
|
||||
}
|
||||
finally {
|
||||
myFixture.getEditor().getSettings().setVariableInplaceRenameEnabled(inplaceEnabled);
|
||||
}
|
||||
}
|
||||
|
||||
private void doTestCannotPerform() {
|
||||
boolean thrownExpectedException = false;
|
||||
try {
|
||||
|
||||
Reference in New Issue
Block a user