mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
Merge branch 'master' of git.labs.intellij.net:idea/ultimate
This commit is contained in:
@@ -16,18 +16,21 @@ public class PyReplaceExpressionUtil implements PyElementTypes {
|
||||
|
||||
public static boolean isNeedParenthesis(@NotNull final PyElement oldExpr, @NotNull final PyElement newExpr) {
|
||||
final PyElement parentExpr = (PyElement)oldExpr.getParent();
|
||||
if (!(parentExpr instanceof PyExpression)) {
|
||||
return false;
|
||||
}
|
||||
int newPriority = getExpressionPriority(newExpr);
|
||||
int parentPriority = getExpressionPriority(parentExpr);
|
||||
if (parentPriority > newPriority) {
|
||||
return true;
|
||||
} else if (parentPriority == newPriority && parentPriority != 0) {
|
||||
if (parentExpr instanceof PyBinaryExpression) {
|
||||
PyBinaryExpression binaryExpression = (PyBinaryExpression) parentExpr;
|
||||
if (isNotAssociative(binaryExpression) && oldExpr.equals(binaryExpression.getRightExpression())) {
|
||||
return true;
|
||||
}
|
||||
return true;
|
||||
} else if (parentPriority == newPriority && parentPriority != 0) {
|
||||
if (parentExpr instanceof PyBinaryExpression) {
|
||||
PyBinaryExpression binaryExpression = (PyBinaryExpression)parentExpr;
|
||||
if (isNotAssociative(binaryExpression) && oldExpr.equals(binaryExpression.getRightExpression())) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@@ -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,3 @@
|
||||
class C:
|
||||
def foo(self):
|
||||
return Conference()
|
||||
@@ -0,0 +1,4 @@
|
||||
class C:
|
||||
def foo(self):
|
||||
co<caret>nf = Conference()
|
||||
return conf
|
||||
@@ -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()
|
||||
@@ -55,4 +55,8 @@ public class PyInlineLocalTest extends LightMarkedTestCase {
|
||||
public void testMultiple() throws Exception {
|
||||
doTest();
|
||||
}
|
||||
|
||||
public void testPy994() throws Exception {
|
||||
doTest();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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