mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-01-04 17:20:55 +07:00
false positive on escaped backslash in string literal (PY-2994)
This commit is contained in:
@@ -40,7 +40,8 @@ public class StringConstantAnnotator extends PyAnnotator {
|
|||||||
private boolean checkQuotedString(ASTNode stringNode, String nodeText) {
|
private boolean checkQuotedString(ASTNode stringNode, String nodeText) {
|
||||||
char firstQuote = nodeText.charAt(0);
|
char firstQuote = nodeText.charAt(0);
|
||||||
int lastChar = nodeText.length()-1;
|
int lastChar = nodeText.length()-1;
|
||||||
if (lastChar == 0 || nodeText.charAt(lastChar) != firstQuote || nodeText.charAt(lastChar-1) == '\\') {
|
if (lastChar == 0 || nodeText.charAt(lastChar) != firstQuote ||
|
||||||
|
(nodeText.charAt(lastChar-1) == '\\' && (lastChar == 1 || nodeText.charAt(lastChar-2) != '\\'))) {
|
||||||
getHolder().createErrorAnnotation(stringNode, MISSING_Q + " [" + firstQuote + "]");
|
getHolder().createErrorAnnotation(stringNode, MISSING_Q + " [" + firstQuote + "]");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|||||||
1
python/testData/highlighting/escapedBackslash.py
Normal file
1
python/testData/highlighting/escapedBackslash.py
Normal file
@@ -0,0 +1 @@
|
|||||||
|
str = 'a a \\'
|
||||||
@@ -142,6 +142,10 @@ public class PythonHighlightingTest extends PyLightFixtureTestCase {
|
|||||||
doTest(true, false);
|
doTest(true, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void testEscapedBackslash() { // PY-2994
|
||||||
|
doTest(true, false);
|
||||||
|
}
|
||||||
|
|
||||||
public void testUnsupportedFeaturesInPython3() {
|
public void testUnsupportedFeaturesInPython3() {
|
||||||
doTest(LanguageLevel.PYTHON30, true, false);
|
doTest(LanguageLevel.PYTHON30, true, false);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user