mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
PY-9176 Converting % to format() doesn't handle multiline string literals
This commit is contained in:
+4
-1
@@ -290,7 +290,10 @@ public class ConvertFormatOperatorToMethodIntention extends BaseIntentionAction
|
||||
}
|
||||
}
|
||||
else target.append("(").append(paramText).append(")"); // tuple is ok as is
|
||||
element.replace(elementGenerator.createExpressionFromText(LanguageLevel.forElement(element), target.toString()));
|
||||
// Correctly handle multiline implicitly concatenated string literals (PY-9176)
|
||||
target.insert(0, '(').append(')');
|
||||
final PyExpression parenthesized = elementGenerator.createExpressionFromText(LanguageLevel.forElement(element), target.toString());
|
||||
element.replace(sure(((PyParenthesizedExpression)parenthesized).getContainedExpression()));
|
||||
}
|
||||
|
||||
private static String getSeparator(PyStringLiteralExpression leftExpression) {
|
||||
|
||||
+2
@@ -0,0 +1,2 @@
|
||||
print('<caret>%(quantity)s pounds of '
|
||||
'%(type)s' % dict(quantity=42, type='spam'))
|
||||
+2
@@ -0,0 +1,2 @@
|
||||
print('{quantity:s} pounds of '
|
||||
'{type:s}'.format(quantity=42, type='spam'))
|
||||
+5
@@ -38,4 +38,9 @@ public class PyConvertFormatOperatorToMethodIntentionTest extends PyIntentionTes
|
||||
public void testUnicode() {
|
||||
doTest(PyBundle.message("INTN.replace.with.method"), LanguageLevel.PYTHON26);
|
||||
}
|
||||
|
||||
// PY-9176
|
||||
public void testConcatenated() {
|
||||
doTest(PyBundle.message("INTN.replace.with.method"), LanguageLevel.PYTHON26);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user