void (AnnotationHolder holder, XPathNodeTypeTest test) { final NodeType nodeType = test.getNodeType(); if (nodeType == null) { return; } final XPathExpression[] arguments = test.getArgumentList(); if (test.getXPathVersion() == XPathVersion.V2) { switch (nodeType) { case NODE, TEXT, COMMENT -> markExceedingArguments(holder, arguments, 0); // TODO: parser doesn't understand TypeName? yet: // ElementTest ::= "element" "(" (ElementNameOrWildcard ("," TypeName "?"?)?)? ")" case ELEMENT, ATTRIBUTE -> checkKindTestArguments(holder, test, true, 0, 2); case SCHEMA_ELEMENT, SCHEMA_ATTRIBUTE -> checkKindTestArguments(holder, test, false, 1, 1); case DOCUMENT_NODE -> { if (arguments.length >= 1) { markExceedingArguments(holder, arguments, 1); final XPathNodeTypeTest argument = findNodeType(arguments[0]); if (argument != null) { final NodeType type = argument.getNodeType(); if (type == NodeType.ELEMENT || type == NodeType.SCHEMA_ELEMENT) { return; } } holder.newAnnotation(HighlightSeverity.ERROR, XPathBundle.message("annotator.error.element.or.schema.element.expected")).range(arguments[0]).create(); } } case PROCESSING_INSTRUCTION -> { if (arguments.length >= 1) { markExceedingArguments(holder, arguments, 1); if (arguments[0] instanceof XPathString) { break; } else { final PrefixedName argument = findQName(arguments[0]); if (argument != null) { if (argument.getPrefix() == null && !"*".equals(argument.getLocalName())) { break; } } } holder.newAnnotation(HighlightSeverity.ERROR, XPathBundle.message("annotator.error.string.literal.or.ncname.expected")).range(arguments[0]).create(); } } } } else { if (arguments.length == 0) { return; } if (test.getNodeType() == NodeType.PROCESSING_INSTRUCTION && arguments.length == 1) { if (!(arguments[0] instanceof XPathString)) { holder.newAnnotation(HighlightSeverity.ERROR, XPathBundle.message("annotator.error.string.literal.expected")).range(arguments[0]).create(); } return; } holder.newAnnotation(HighlightSeverity.ERROR, XPathBundle.message("annotator.error.invalid.number.arguments.for.node.type.test", nodeType.getType())).create(); } }