mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
Took into account Parenthesized Expressions
fixed PY-7151 Convert triple-quoted string to single-quoted string: do not wrap string with parenthesis if initial string is already inside them
This commit is contained in:
+2
-1
@@ -94,7 +94,8 @@ public class PyConvertTripleQuotedStringIntention extends BaseIntentionAction {
|
||||
PyExpressionStatement e = elementGenerator.createFromText(LanguageLevel.forElement(string), PyExpressionStatement.class, result.toString());
|
||||
|
||||
PyExpression expression = e.getExpression();
|
||||
if (parent instanceof PyTupleExpression && expression instanceof PyParenthesizedExpression)
|
||||
if ((parent instanceof PyParenthesizedExpression || parent instanceof PyTupleExpression)
|
||||
&& expression instanceof PyParenthesizedExpression)
|
||||
expression = ((PyParenthesizedExpression)expression).getContainedExpression();
|
||||
if (expression != null)
|
||||
string.replace(expression);
|
||||
|
||||
@@ -0,0 +1,2 @@
|
||||
t = ("string\n"
|
||||
"some\n")
|
||||
@@ -0,0 +1,3 @@
|
||||
t = ("""str<caret>ing
|
||||
some
|
||||
""")
|
||||
@@ -253,6 +253,10 @@ public class PyIntentionTest extends PyTestCase {
|
||||
doTest(PyBundle.message("INTN.triple.quoted.string"));
|
||||
}
|
||||
|
||||
public void testConvertTripleQuotedStringInParenthesized() { //PY-7883
|
||||
doTest(PyBundle.message("INTN.triple.quoted.string"));
|
||||
}
|
||||
|
||||
public void testConvertTripleQuotedUnicodeString() { //PY-7152
|
||||
doTest(PyBundle.message("INTN.triple.quoted.string"));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user