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:
Ekaterina Tuzova
2013-02-26 14:41:59 +04:00
parent 494c538ecf
commit 8278ad5e3a
4 changed files with 11 additions and 1 deletions
@@ -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"));
}