mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
PY-24610 Exception because of Invalid TextRange in format string: use PyStringLiteralExpression#getText() instead of PyStringLiteralExpression#getStringValue()
This commit is contained in:
+2
-2
@@ -197,13 +197,13 @@ public class PyStringFormatCompletionContributor extends CompletionContributor {
|
||||
@NotNull
|
||||
private static List<LookupElement> getFormatLookupBuilders(@NotNull final PyStringLiteralExpression expression) {
|
||||
final Map<String, PyStringFormatParser.SubstitutionChunk> chunks = PyStringFormatParser.getKeywordSubstitutions(
|
||||
PyStringFormatParser.filterSubstitutions(PyStringFormatParser.parseNewStyleFormat(expression.getStringValue())));
|
||||
PyStringFormatParser.filterSubstitutions(PyStringFormatParser.parseNewStyleFormat(expression.getText())));
|
||||
return getLookupBuilders(chunks);
|
||||
}
|
||||
|
||||
private static List<LookupElement> getPercentLookupBuilders(@NotNull final PyStringLiteralExpression expression) {
|
||||
final Map<String, PyStringFormatParser.SubstitutionChunk> chunks = PyStringFormatParser.getKeywordSubstitutions(
|
||||
PyStringFormatParser.filterSubstitutions(PyStringFormatParser.parsePercentFormat(expression.getStringValue())));
|
||||
PyStringFormatParser.filterSubstitutions(PyStringFormatParser.parsePercentFormat(expression.getText())));
|
||||
return getLookupBuilders(chunks);
|
||||
}
|
||||
|
||||
|
||||
@@ -346,7 +346,7 @@ public class PyStringFormatInspection extends PyInspection {
|
||||
}
|
||||
|
||||
private void inspectPercentFormat(@NotNull final PyStringLiteralExpression formatExpression) {
|
||||
final String value = formatExpression.getStringValue();
|
||||
final String value = formatExpression.getText();
|
||||
final List<PyStringFormatParser.SubstitutionChunk> chunks = filterSubstitutions(parsePercentFormat(value));
|
||||
|
||||
myExpectedArguments = chunks.size();
|
||||
@@ -482,7 +482,7 @@ public class PyStringFormatInspection extends PyInspection {
|
||||
}
|
||||
|
||||
public void inspect() {
|
||||
final String value = myFormatExpression.getStringValue();
|
||||
final String value = myFormatExpression.getText();
|
||||
final List<PyStringFormatParser.SubstitutionChunk> chunks = filterSubstitutions(PyStringFormatParser.parseNewStyleFormat(value));
|
||||
|
||||
for (int i = 0; i < chunks.size(); i++) {
|
||||
|
||||
@@ -0,0 +1,2 @@
|
||||
u"{key}".format(key=1)
|
||||
<warning descr="Key 'k' has no corresponding argument">u"{k}"</warning>.format(key=1)
|
||||
@@ -193,6 +193,10 @@ public class PyStringFormatInspectionTest extends PyTestCase {
|
||||
doTest();
|
||||
}
|
||||
|
||||
public void testEscapedString() {
|
||||
doTest();
|
||||
}
|
||||
|
||||
//PY-21166
|
||||
public void testUnsupportedFormatSpecifierNewStyleFormatting() {
|
||||
doTest();
|
||||
|
||||
Reference in New Issue
Block a user