mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-01-04 17:20:55 +07:00
correct highlighting of string literals with mixed quotes (PY-299)
This commit is contained in:
@@ -4,9 +4,8 @@ import com.jetbrains.python.psi.PyStringLiteralExpression;
|
||||
|
||||
/**
|
||||
* Looks for well-formedness of string constants.
|
||||
* User: dcheryasov
|
||||
* Date: Jul 5, 2008
|
||||
* Time: 11:58:57 PM
|
||||
*
|
||||
* @author dcheryasov
|
||||
*/
|
||||
public class StringConstantAnnotator extends PyAnnotator {
|
||||
public static final String MISSING_Q = "Missing closing quote";
|
||||
@@ -34,9 +33,15 @@ public class StringConstantAnnotator extends PyAnnotator {
|
||||
char c = s.charAt(index);
|
||||
if (esc) esc = false;
|
||||
else {
|
||||
if (c != first_quote) {
|
||||
if (c == '\\') esc = true;
|
||||
// a line may consist of multiple fragments with different quote chars (PY-299)
|
||||
else if (c == '\'' || c == '\"') {
|
||||
if (first_quote == '\0')
|
||||
first_quote = c;
|
||||
else
|
||||
first_quote = '\0';
|
||||
}
|
||||
|
||||
/*
|
||||
else { // impossible with current lexer, but who knows :)
|
||||
msg = PREMATURE_Q + " [" + first_quote + "]";
|
||||
|
||||
2
python/testData/highlighting/stringMixedSeparatorsOK.py
Normal file
2
python/testData/highlighting/stringMixedSeparatorsOK.py
Normal file
@@ -0,0 +1,2 @@
|
||||
print "Hello"\
|
||||
'World'
|
||||
@@ -86,6 +86,10 @@ public class PythonHighlightingTest extends PyLightFixtureTestCase {
|
||||
doTest();
|
||||
}
|
||||
|
||||
public void testStringMixedSeparatorsOK() throws Exception { // PY-299
|
||||
doTest();
|
||||
}
|
||||
|
||||
public void testYieldInNestedFunction() throws Exception {
|
||||
// highlight func declaration first, lest we get an "Extra fragment highlighted" error.
|
||||
EditorColorsManager manager = EditorColorsManager.getInstance();
|
||||
|
||||
Reference in New Issue
Block a user