diff --git a/plugins/xpath/xpath-lang/src/org/intellij/lang/xpath/XPath2Parser.java b/plugins/xpath/xpath-lang/src/org/intellij/lang/xpath/XPath2Parser.java index 830d7e450223..0dd6bdf6f408 100644 --- a/plugins/xpath/xpath-lang/src/org/intellij/lang/xpath/XPath2Parser.java +++ b/plugins/xpath/xpath-lang/src/org/intellij/lang/xpath/XPath2Parser.java @@ -515,6 +515,21 @@ public class XPath2Parser extends XPathParser { return true; } + @Override + protected boolean parseWildcard(PsiBuilder builder) { + builder.advanceLexer(); + + if (builder.getTokenType() == XPathTokenTypes.COL) { + builder.advanceLexer(); + if (builder.getTokenType() != XPathTokenTypes.NCNAME) { + builder.error("NCName expected"); + builder.advanceLexer(); + } + } + + return true; + } + @Override protected TokenSet unionOps() { return XPath2TokenTypes.UNION_OPS; diff --git a/plugins/xpath/xpath-lang/src/org/intellij/lang/xpath/XPathParser.java b/plugins/xpath/xpath-lang/src/org/intellij/lang/xpath/XPathParser.java index 5394c80e3d85..33342a1a22a1 100644 --- a/plugins/xpath/xpath-lang/src/org/intellij/lang/xpath/XPathParser.java +++ b/plugins/xpath/xpath-lang/src/org/intellij/lang/xpath/XPathParser.java @@ -453,10 +453,9 @@ public class XPathParser implements PsiParser { /** * [37] NameTest ::= '*' | NCName ':' '*' | QName */ - private static boolean parseNameTest(PsiBuilder builder) { + protected boolean parseNameTest(PsiBuilder builder) { if (builder.getTokenType() == XPathTokenTypes.STAR) { - builder.advanceLexer(); - return true; + return parseWildcard(builder); } else if (builder.getTokenType() == XPathTokenTypes.NCNAME) { builder.advanceLexer(); @@ -477,6 +476,11 @@ public class XPathParser implements PsiParser { return false; } + protected boolean parseWildcard(PsiBuilder builder) { + builder.advanceLexer(); + return true; + } + /** * [5] AxisSpecifier ::= AxisName '::' | AbbreviatedAxisSpecifier *
diff --git a/plugins/xpath/xpath-lang/test/org/intellij/lang/xpath/XPath2ParsingTest.java b/plugins/xpath/xpath-lang/test/org/intellij/lang/xpath/XPath2ParsingTest.java index c06ed53311af..aa5cabc37e0a 100644 --- a/plugins/xpath/xpath-lang/test/org/intellij/lang/xpath/XPath2ParsingTest.java +++ b/plugins/xpath/xpath-lang/test/org/intellij/lang/xpath/XPath2ParsingTest.java @@ -67,6 +67,14 @@ public class XPath2ParsingTest extends TestBase { doXPathHighlighting(); } + public void testWildcardNamespace() throws Throwable { + doXPathHighlighting(); + } + + public void testInvalidWildcard() throws Throwable { + doXPathHighlighting(); + } + private void doXPathHighlighting(String... moreFiles) throws Throwable { final String name = getTestFileName(); myFixture.testHighlighting(false, false, false, ArrayUtil.append(moreFiles, name + ".xpath2")); diff --git a/plugins/xpath/xpath-lang/testData/xpath2/parsing/invalidWildcard.xpath2 b/plugins/xpath/xpath-lang/testData/xpath2/parsing/invalidWildcard.xpath2 new file mode 100644 index 000000000000..c2ebba97569d --- /dev/null +++ b/plugins/xpath/xpath-lang/testData/xpath2/parsing/invalidWildcard.xpath2 @@ -0,0 +1 @@ +*: