use of org.intellij.lang.xpath.XPathElementType in project intellij-community by JetBrains.
the class XPathAnnotator method visitXPathBinaryExpression.
@Override
public void visitXPathBinaryExpression(final XPathBinaryExpression o) {
final XPathExpression operand = o.getLOperand();
if (operand != null && o.getXPathVersion() == XPathVersion.V2) {
final XPathElementType operator = o.getOperator();
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");
final XPathExpression rOperand = o.getROperand();
if (rOperand != null) {
final String replacement = "(" + operand.getText() + ") " + o.getOperationSign() + " " + rOperand.getText();
annotation.registerFix(new ExpressionReplacementFix(replacement, o));
}
}
if (XPath2TokenTypes.NODE_COMP_OPS.contains(operator)) {
checkApplicability(o, XPath2Type.NODE);
} else if (operator == XPath2TokenTypes.WEQ || operator == XPath2TokenTypes.WNE || operator == XPathTokenTypes.EQ || operator == XPathTokenTypes.NE) {
checkApplicability(o, XPath2Type.NUMERIC, XPath2Type.BOOLEAN, XPath2Type.STRING, XPath2Type.DATE, XPath2Type.TIME, XPath2Type.DATETIME, XPath2Type.DURATION, XPath2Type.HEXBINARY, XPath2Type.BASE64BINARY, XPath2Type.ANYURI, XPath2Type.QNAME);
} else if (operator == XPath2TokenTypes.WGT || operator == XPath2TokenTypes.WGE || operator == XPath2TokenTypes.WLE || operator == XPath2TokenTypes.WLT || operator == XPathTokenTypes.GT || operator == XPathTokenTypes.GE || operator == XPathTokenTypes.LE || operator == XPathTokenTypes.LT) {
checkApplicability(o, XPath2Type.NUMERIC, XPath2Type.BOOLEAN, XPath2Type.STRING, XPath2Type.DATE, XPath2Type.TIME, XPath2Type.DATETIME, XPath2Type.DURATION, XPath2Type.ANYURI);
}
} else if (XPath2TokenTypes.UNION_OPS.contains(operator) || XPath2TokenTypes.INTERSECT_EXCEPT.contains(operator)) {
checkApplicability(o, XPath2SequenceType.create(XPath2Type.NODE, XPath2SequenceType.Cardinality.ZERO_OR_MORE));
} else if (operator == XPath2TokenTypes.TO) {
checkApplicability(o, XPath2Type.INTEGER);
} else if (operator == XPathTokenTypes.AND || operator == XPathTokenTypes.OR) {
checkApplicability(o, XPath2Type.BOOLEAN);
} else if (XPathTokenTypes.ADD_OPS.contains(operator)) {
checkApplicability(o, XPath2Type.NUMERIC, XPath2Type.DURATION, XPath2Type.DATE, XPath2Type.TIME, XPath2Type.DATETIME);
} else if (XPath2TokenTypes.MULT_OPS.contains(operator)) {
if (operator == XPath2TokenTypes.IDIV || operator == XPathTokenTypes.MOD) {
checkApplicability(o, XPath2Type.NUMERIC);
} else if (operator == XPathTokenTypes.DIV) {
checkApplicability(o, XPath2Type.NUMERIC, XPath2Type.DURATION);
} else {
assert operator == XPathTokenTypes.MULT;
checkApplicability(o, XPath2Type.NUMERIC, XPath2Type.DURATION);
}
}
}
checkExpression(myHolder, o);
super.visitXPathBinaryExpression(o);
}
use of org.intellij.lang.xpath.XPathElementType in project intellij-community by JetBrains.
the class XPathPrefixExpressionImpl method getOperator.
@NotNull
@Override
public XPathElementType getOperator() {
final ASTNode node = getNode().findChildByType(XPathTokenTypes.ADD_OPS);
final XPathElementType elementType = (XPathElementType) (node != null ? node.getElementType() : null);
assert elementType != null : unexpectedPsiAssertion();
return elementType;
}
Aggregations