mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
PY-995 fix introduce* incorrectly working with assignment left part
This commit is contained in:
@@ -175,7 +175,10 @@ abstract public class IntroduceHandler implements RefactoringActionHandler {
|
||||
return;
|
||||
}
|
||||
|
||||
final PyExpression expression = (PyExpression)element;
|
||||
final PsiElement parent = element.getParent();
|
||||
final PyExpression expression = parent instanceof PyAssignmentStatement ?
|
||||
((PyAssignmentStatement)parent).getAssignedValue() :
|
||||
(PyExpression)element;
|
||||
|
||||
final List<PsiElement> occurrences;
|
||||
if (expression.getUserData(PyPsiUtils.SELECTION_BREAKS_AST_NODE) == null && !(expression instanceof PyCallExpression)) {
|
||||
@@ -185,6 +188,7 @@ abstract public class IntroduceHandler implements RefactoringActionHandler {
|
||||
occurrences = Collections.emptyList();
|
||||
}
|
||||
String[] possibleNames = getSuggestedNames(expression);
|
||||
replaceAll &= occurrences.size() > 0;
|
||||
boolean initInConstructor = false;
|
||||
if (name == null) {
|
||||
PyIntroduceDialog dialog = new PyIntroduceDialog(project, expression, myDialogTitle, myValidator, occurrences.size(), possibleNames, getHelpId(), hasConstructor);
|
||||
|
||||
@@ -0,0 +1,4 @@
|
||||
class ConferenceTest(TestCase):
|
||||
def testSimple(self):
|
||||
a = Conference()
|
||||
c = a
|
||||
@@ -0,0 +1,3 @@
|
||||
class ConferenceTest(TestCase):
|
||||
def testSimple(self):
|
||||
<selection>c</selection> = Conference()
|
||||
@@ -13,9 +13,17 @@ public class PyIntroduceVariableTest extends PyLightFixtureTestCase {
|
||||
}
|
||||
|
||||
public void testSimple() throws Exception {
|
||||
myFixture.configureByFile("simple.py");
|
||||
doTest();
|
||||
}
|
||||
|
||||
public void testPy995() throws Exception {
|
||||
doTest();
|
||||
}
|
||||
|
||||
private void doTest() throws Exception {
|
||||
myFixture.configureByFile(getTestName(true) + ".py");
|
||||
VariableIntroduceHandler handler = new VariableIntroduceHandler();
|
||||
handler.performAction(myFixture.getProject(), myFixture.getEditor(), myFixture.getFile(), "a", true, false);
|
||||
myFixture.checkResultByFile("simple.after.py");
|
||||
myFixture.checkResultByFile(getTestName(true) + ".after.py");
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user