PY-13114 Inlining of method call does not add extra parenthesis

Fix prioritization problem: reference expressions should have the same
priority as indexing, slicing and function calls.
This commit is contained in:
Mikhail Golubev
2014-11-27 16:14:42 +03:00
parent db6410e9fc
commit e3fc0ee66a
4 changed files with 12 additions and 1 deletions
@@ -441,7 +441,10 @@ public class PyReplaceExpressionUtil implements PyElementTypes {
private static int getExpressionPriority(PyElement expr) {
int priority = 0;
if (expr instanceof PySubscriptionExpression || expr instanceof PySliceExpression || expr instanceof PyCallExpression) priority = 1;
if (expr instanceof PyReferenceExpression ||
expr instanceof PySubscriptionExpression ||
expr instanceof PySliceExpression ||
expr instanceof PyCallExpression) priority = 1;
else if (expr instanceof PyPrefixExpression) {
final IElementType opType = getOperationType(expr);
if (opType == PLUS || opType == MINUS || opType == TILDE) priority = 2;
@@ -0,0 +1 @@
a.method().strip()
@@ -0,0 +1,2 @@
res = a.method()
res.strip()
@@ -104,6 +104,11 @@ public class PyInlineLocalTest extends PyTestCase {
doTest();
}
// PY-13114
public void testMethodCallInlinedAsQualifier() {
doTest();
}
// PY-12409
public void testResultExceedsRightMargin() {
final CodeStyleSettings settings = CodeStyleSettingsManager.getSettings(myFixture.getProject());