From 7e0104bb59ec0d3c981924dea1fc6e286fbde92a Mon Sep 17 00:00:00 2001 From: sweinreuter Date: Thu, 10 Mar 2011 20:17:13 +0100 Subject: [PATCH] if not treated as an expression in argument lists --- .../lang/xpath/XPath2ElementTypes.java | 2 +- .../lang/xpath/XPath2HighlightingTest.java | 32 +++++++++++++++++++ .../xpath/XPath2HighlightingTestBase.java | 30 +++++++++++++++++ .../intellij/lang/xpath/XPath2TypeTest.java | 9 +----- .../highlighting/ifInsideArgumentList.xpath2 | 1 + 5 files changed, 65 insertions(+), 9 deletions(-) create mode 100644 plugins/xpath/xpath-lang/test/org/intellij/lang/xpath/XPath2HighlightingTest.java create mode 100644 plugins/xpath/xpath-lang/test/org/intellij/lang/xpath/XPath2HighlightingTestBase.java create mode 100644 plugins/xpath/xpath-lang/testData/xpath/highlighting/ifInsideArgumentList.xpath2 diff --git a/plugins/xpath/xpath-lang/src/org/intellij/lang/xpath/XPath2ElementTypes.java b/plugins/xpath/xpath-lang/src/org/intellij/lang/xpath/XPath2ElementTypes.java index c387338cb462..4dc98b95367d 100644 --- a/plugins/xpath/xpath-lang/src/org/intellij/lang/xpath/XPath2ElementTypes.java +++ b/plugins/xpath/xpath-lang/src/org/intellij/lang/xpath/XPath2ElementTypes.java @@ -45,7 +45,7 @@ public final class XPath2ElementTypes { public static final TokenSet EXPRESSIONS = TokenSet.orSet( XPathElementTypes.EXPRESSIONS, - TokenSet.create(XPathElementTypes.NODE_TYPE, CONTEXT_ITEM, FOR, RANGE_EXPRESSION, QUANTIFIED, INSTANCE_OF, TREAT_AS, CASTABLE_AS, CAST_AS) + TokenSet.create(XPathElementTypes.NODE_TYPE, SEQUENCE, CONTEXT_ITEM, IF, FOR, RANGE_EXPRESSION, QUANTIFIED, INSTANCE_OF, TREAT_AS, CASTABLE_AS, CAST_AS) ); private XPath2ElementTypes() { diff --git a/plugins/xpath/xpath-lang/test/org/intellij/lang/xpath/XPath2HighlightingTest.java b/plugins/xpath/xpath-lang/test/org/intellij/lang/xpath/XPath2HighlightingTest.java new file mode 100644 index 000000000000..80352131d57a --- /dev/null +++ b/plugins/xpath/xpath-lang/test/org/intellij/lang/xpath/XPath2HighlightingTest.java @@ -0,0 +1,32 @@ +/* + * Copyright 2000-2011 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.intellij.lang.xpath; + +/* +* Created by IntelliJ IDEA. +* User: sweinreuter +* Date: 10.03.11 +*/ +public class XPath2HighlightingTest extends XPath2HighlightingTestBase { + public void testIfInsideArgumentList() throws Throwable { + doXPathHighlighting(); + } + + @Override + protected String getSubPath() { + return "xpath/highlighting"; + } +} \ No newline at end of file diff --git a/plugins/xpath/xpath-lang/test/org/intellij/lang/xpath/XPath2HighlightingTestBase.java b/plugins/xpath/xpath-lang/test/org/intellij/lang/xpath/XPath2HighlightingTestBase.java new file mode 100644 index 000000000000..7944ebcc43a7 --- /dev/null +++ b/plugins/xpath/xpath-lang/test/org/intellij/lang/xpath/XPath2HighlightingTestBase.java @@ -0,0 +1,30 @@ +/* + * Copyright 2000-2011 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.intellij.lang.xpath; + +import com.intellij.util.ArrayUtil; + +/* +* Created by IntelliJ IDEA. +* User: sweinreuter +* Date: 10.03.11 +*/ +public abstract class XPath2HighlightingTestBase extends TestBase { + protected void doXPathHighlighting(String... moreFiles) throws Throwable { + final String name = getTestFileName(); + myFixture.testHighlighting(true, false, false, ArrayUtil.append(moreFiles, name + ".xpath2")); + } +} \ No newline at end of file diff --git a/plugins/xpath/xpath-lang/test/org/intellij/lang/xpath/XPath2TypeTest.java b/plugins/xpath/xpath-lang/test/org/intellij/lang/xpath/XPath2TypeTest.java index 77a5b78076b5..123e98c33760 100644 --- a/plugins/xpath/xpath-lang/test/org/intellij/lang/xpath/XPath2TypeTest.java +++ b/plugins/xpath/xpath-lang/test/org/intellij/lang/xpath/XPath2TypeTest.java @@ -15,9 +15,7 @@ */ package org.intellij.lang.xpath; -import com.intellij.util.ArrayUtil; - -public class XPath2TypeTest extends TestBase { +public class XPath2TypeTest extends XPath2HighlightingTestBase { public void testQNameToQName() throws Throwable { doXPathHighlighting(); @@ -91,11 +89,6 @@ public class XPath2TypeTest extends TestBase { doXPathHighlighting(); } - private void doXPathHighlighting(String... moreFiles) throws Throwable { - final String name = getTestFileName(); - myFixture.testHighlighting(true, false, false, ArrayUtil.append(moreFiles, name + ".xpath2")); - } - @Override protected String getSubPath() { return "xpath/highlighting/types"; diff --git a/plugins/xpath/xpath-lang/testData/xpath/highlighting/ifInsideArgumentList.xpath2 b/plugins/xpath/xpath-lang/testData/xpath/highlighting/ifInsideArgumentList.xpath2 new file mode 100644 index 000000000000..a7ee662e5f26 --- /dev/null +++ b/plugins/xpath/xpath-lang/testData/xpath/highlighting/ifInsideArgumentList.xpath2 @@ -0,0 +1 @@ +concat('', if (true()) then '1' else '2') \ No newline at end of file