fix parsing of character classes so that it's actually correct (PY-1929)

This commit is contained in:
Dmitry Jemerov
2011-02-21 19:09:58 +01:00
parent 1e821e1216
commit aefabe0d79
4 changed files with 17 additions and 2 deletions
+1 -1
View File
@@ -23,7 +23,7 @@
<orderEntry type="library" name="xpp3-1.1.4-min" level="project" />
<orderEntry type="module" module-name="xml" />
<orderEntry type="module" module-name="xdebugger-api" />
<orderEntry type="module" module-name="RegExpSupport" />
<orderEntry type="module" module-name="RegExpSupport" exported="" />
<orderEntry type="module" module-name="yaml" />
<orderEntry type="library" name="microba" level="project" />
<orderEntry type="library" name="XmlRPC" level="project" />
@@ -0,0 +1,3 @@
import re
EXTRANEOUS_WHITESPACE_REGEX = re.compile(r'[[({] | []}),;:]')
@@ -1,5 +1,8 @@
package com.jetbrains.python;
import com.intellij.lexer.Lexer;
import com.jetbrains.python.codeInsight.regexp.PythonRegexpParserDefinition;
import com.jetbrains.python.fixtures.PyLexerTestCase;
import com.jetbrains.python.fixtures.PyLightFixtureTestCase;
/**
@@ -10,6 +13,11 @@ public class PyRegexpTest extends PyLightFixtureTestCase {
doTest();
}
public void testNestedCharacterClassesLexer() {
Lexer lexer = new PythonRegexpParserDefinition().createLexer(myFixture.getProject());
PyLexerTestCase.doLexerTest("[][]", lexer, "CLASS_BEGIN", "CHARACTER", "CHARACTER", "CLASS_END");
}
public void testNestedCharacterClasses2() { // PY-2908
doTest();
}
@@ -18,6 +26,10 @@ public class PyRegexpTest extends PyLightFixtureTestCase {
doTest();
}
public void testBraceInPythonCharacterClass() { // PY-1929
doTest();
}
private void doTest() {
myFixture.testHighlighting(true, false, false, "regexp/" + getTestName(true) + ".py");
}
@@ -7,7 +7,7 @@ import junit.framework.TestCase;
* @author yole
*/
public abstract class PyLexerTestCase extends TestCase {
protected static void doLexerTest(String text, Lexer lexer, String... expectedTokens) {
public static void doLexerTest(String text, Lexer lexer, String... expectedTokens) {
lexer.start(text);
int idx = 0;
int tokenPos = 0;