mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
Fixed escaping backslash and quotes when replacing string concatenation with formatting (PY-8366)
This commit is contained in:
+4
-2
@@ -15,7 +15,9 @@ import com.jetbrains.python.PyTokenTypes;
|
||||
import com.jetbrains.python.PythonStringUtil;
|
||||
import com.jetbrains.python.psi.*;
|
||||
import com.jetbrains.python.psi.impl.PyBuiltinCache;
|
||||
import com.jetbrains.python.psi.types.*;
|
||||
import com.jetbrains.python.psi.types.PyType;
|
||||
import com.jetbrains.python.psi.types.PyTypeChecker;
|
||||
import com.jetbrains.python.psi.types.TypeEvalContext;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.ArrayList;
|
||||
@@ -108,7 +110,7 @@ public class PyStringConcatenationToFormatIntention extends BaseIntentionAction
|
||||
}
|
||||
final LanguageLevel languageLevel = LanguageLevel.forElement(element);
|
||||
|
||||
NotNullFunction<String,String> escaper = StringUtil.escaper(false, null);
|
||||
NotNullFunction<String,String> escaper = StringUtil.escaper(false, "\"\'\\");
|
||||
StringBuilder stringLiteral = new StringBuilder();
|
||||
List<String> parameters = new ArrayList<String>();
|
||||
Pair<String, String> quotes = new Pair<String, String>("\"", "\"");
|
||||
|
||||
@@ -0,0 +1,2 @@
|
||||
string = "string"
|
||||
some_string = "some \\ \" escaping {0}".format(string)
|
||||
@@ -0,0 +1,2 @@
|
||||
string = "string"
|
||||
some_string = "some \\ \" escaping " <caret>+ string
|
||||
@@ -353,6 +353,11 @@ public class PyIntentionTest extends PyTestCase {
|
||||
doTest(PyBundle.message("INTN.replace.plus.with.format.operator"));
|
||||
}
|
||||
|
||||
// PY-8366
|
||||
public void testStringConcatToFormatEscapingPy3() {
|
||||
doTest(PyBundle.message("INTN.replace.plus.with.str.format"), LanguageLevel.PYTHON33);
|
||||
}
|
||||
|
||||
private void doDocStubTest(LanguageLevel languageLevel) {
|
||||
PythonLanguageLevelPusher.setForcedLanguageLevel(myFixture.getProject(), languageLevel);
|
||||
try {
|
||||
|
||||
Reference in New Issue
Block a user