mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
IDEA-67727: XPath 2: numeric literal immediately followed with letter is green
This commit is contained in:
+13
-3
@@ -26,6 +26,7 @@ import com.intellij.psi.PsiElement;
|
||||
import com.intellij.psi.PsiReference;
|
||||
import com.intellij.psi.util.PsiTreeUtil;
|
||||
import org.intellij.lang.xpath.XPath2TokenTypes;
|
||||
import org.intellij.lang.xpath.XPathElementType;
|
||||
import org.intellij.lang.xpath.XPathFileType;
|
||||
import org.intellij.lang.xpath.context.functions.Function;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
@@ -104,9 +105,18 @@ public final class XPathAnnotator extends XPath2ElementVisitor implements Annota
|
||||
|
||||
@Override
|
||||
public void visitXPathBinaryExpression(final XPathBinaryExpression o) {
|
||||
if (XPath2TokenTypes.COMP_OPS.contains(o.getOperator())) {
|
||||
if (o.getContainingFile().getLanguage() == XPathFileType.XPATH2.getLanguage()) {
|
||||
final XPathExpression operand = o.getLOperand();
|
||||
if (o.getContainingFile().getLanguage() == XPathFileType.XPATH2.getLanguage()) {
|
||||
final XPathExpression operand = o.getLOperand();
|
||||
final XPathElementType operator = o.getOperator();
|
||||
if (operand instanceof XPathNumber) {
|
||||
if (operator != XPathTokenTypes.STAR && XPath2TokenTypes.KEYWORDS.contains(operator)) {
|
||||
final String op = o.getOperationSign();
|
||||
if (o.getText().startsWith(operand.getText() + op)) {
|
||||
myHolder.createErrorAnnotation(o, "Number literal must be followed by whitespace in XPath 2");
|
||||
}
|
||||
}
|
||||
}
|
||||
if (XPath2TokenTypes.COMP_OPS.contains(operator)) {
|
||||
if (operand instanceof XPathBinaryExpression && XPath2TokenTypes.COMP_OPS.contains(((XPathBinaryExpression)operand).getOperator())) {
|
||||
final Annotation annotation = myHolder.createErrorAnnotation(o, "Consecutive comparison is not allowed in XPath 2");
|
||||
|
||||
|
||||
@@ -29,6 +29,10 @@ public class XPath2HighlightingTest extends XPath2HighlightingTestBase {
|
||||
doXPathHighlighting();
|
||||
}
|
||||
|
||||
public void testNumberFollowedByToken() throws Throwable {
|
||||
doXPathHighlighting();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getSubPath() {
|
||||
return "xpath/highlighting";
|
||||
|
||||
@@ -56,6 +56,10 @@ public class XPathHighlightingTest extends TestBase {
|
||||
doXPathHighlighting();
|
||||
}
|
||||
|
||||
public void testNumberFollowedByToken() throws Throwable {
|
||||
doXPathHighlighting();
|
||||
}
|
||||
|
||||
private void doXPathHighlighting(String... moreFiles) throws Throwable {
|
||||
final String name = getTestFileName();
|
||||
myFixture.testHighlighting(true, false, false, ArrayUtil.append(moreFiles, name + ".xpath"));
|
||||
|
||||
@@ -0,0 +1 @@
|
||||
10div 2 + 3 mod 2
|
||||
@@ -0,0 +1 @@
|
||||
<error descr="Number literal must be followed by whitespace in XPath 2">10div 2</error> + 3 mod 2
|
||||
Reference in New Issue
Block a user