allow dangling metacharacters in Python regexps (PY-2430)

This commit is contained in:
Dmitry Jemerov
2011-02-21 20:04:53 +01:00
parent 29e9f1f1c4
commit 74b7c06a68
3 changed files with 16 additions and 0 deletions
@@ -1,5 +1,6 @@
package com.jetbrains.python.codeInsight.regexp;
import com.intellij.lang.PsiParser;
import com.intellij.lexer.Lexer;
import com.intellij.openapi.project.Project;
import com.intellij.psi.FileViewProvider;
@@ -7,6 +8,7 @@ import com.intellij.psi.PsiFile;
import com.intellij.psi.tree.IFileElementType;
import org.intellij.lang.regexp.RegExpFile;
import org.intellij.lang.regexp.RegExpLexer;
import org.intellij.lang.regexp.RegExpParser;
import org.intellij.lang.regexp.RegExpParserDefinition;
import org.jetbrains.annotations.NotNull;
@@ -21,6 +23,13 @@ public class PythonRegexpParserDefinition extends RegExpParserDefinition {
return new RegExpLexer(false, true, false, true);
}
@Override
public PsiParser createParser(Project project) {
RegExpParser regExpParser = new RegExpParser();
regExpParser.setAllowDanglingMetacharacters(true);
return regExpParser;
}
@Override
public IFileElementType getFileNodeType() {
return PYTHON_REGEXP_FILE;
@@ -0,0 +1,3 @@
import re
re.compile('{\w+}')
@@ -33,6 +33,10 @@ public class PyRegexpTest extends PyLightFixtureTestCase {
doTestLexer("[^][]", "CLASS_BEGIN", "CARET", "CHARACTER", "CHARACTER", "CLASS_END");
}
public void testDanglingMetacharacters() { // PY-2430
doTestHighlighting();
}
private void doTestHighlighting() {
myFixture.testHighlighting(true, false, false, "regexp/" + getTestName(true) + ".py");
}