本文整理汇总了Java中org.intellij.lang.xpath.XPathTokenTypes类的典型用法代码示例。如果您正苦于以下问题:Java XPathTokenTypes类的具体用法?Java XPathTokenTypes怎么用?Java XPathTokenTypes使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
XPathTokenTypes类属于org.intellij.lang.xpath包,在下文中一共展示了XPathTokenTypes类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: visitXPathFile
import org.intellij.lang.xpath.XPathTokenTypes; //导入依赖的package包/类
@Override
public void visitXPathFile(XPathFile file) {
final XmlAttribute context = PsiTreeUtil.getContextOfType(file, XmlAttribute.class, true);
if (context != null) {
if (XsltSupport.isPatternAttribute(context)) {
XsltPatternValidator.validate(myHolder, file);
} else {
if (file.getText().trim().length() == 0 && file.getExpression() == null) {
myHolder.createErrorAnnotation(file, "Empty XPath expression");
}
}
if (XsltSupport.isXsltAttribute(context) && !XsltSupport.mayBeAVT(context)) {
final ASTNode node = file.getNode();
if (node != null && node.findChildByType(XPathTokenTypes.LBRACE) != null) {
myHolder.createErrorAnnotation(file, "Attribute Value Template is not allowed here");
}
}
}
}
示例2: getQName
import org.intellij.lang.xpath.XPathTokenTypes; //导入依赖的package包/类
@Nullable
public PrefixedName getQName() {
final ASTNode[] nodes = getNode().getChildren(TokenSet.create(XPathTokenTypes.NCNAME));
if (nodes.length == 0) {
final ASTNode node = getNode().findChildByType(XPathTokenTypes.STAR);
if (node != null) {
return new PrefixedNameImpl(null, node);
}
} else if (nodes.length == 1) {
final ASTNode star = getNode().findChildByType(XPathTokenTypes.STAR);
if (star != null) {
return star.getTextRange().getStartOffset() > nodes[0].getTextRange().getStartOffset() ?
new PrefixedNameImpl(nodes[0], star) : new PrefixedNameImpl(star, nodes[0]);
} else {
return new PrefixedNameImpl(nodes[0]);
}
} else if (nodes.length == 2) {
return new PrefixedNameImpl(nodes[0], nodes[1]);
}
return null;
}
示例3: visitXPathBinaryExpression
import org.intellij.lang.xpath.XPathTokenTypes; //导入依赖的package包/类
@Override
public void visitXPathBinaryExpression(XPathBinaryExpression parent) {
if (myExpression == parent.getROperand()) {
final XPathElementType op = parent.getOperator();
final XPathExpression lop = parent.getLOperand();
if (op == XPathTokenTypes.AND || op == XPathTokenTypes.OR) {
myExpectedType = XPathType.BOOLEAN;
} else if (XPath2TokenTypes.NUMBER_OPERATIONS.contains(op)) {
if (isXPath1(myExpression)) {
myExpectedType = XPathType.NUMBER;
} else {
myExpectedType = matchingType(lop, op);
}
} else if (XPath2TokenTypes.COMP_OPS.contains(op)) {
if (lop != null && lop.getType() != XPathType.NODESET) {
if ((myExpectedType = lop.getType()) == XPathType.BOOLEAN) {
if (!isXPath1(myExpression)) myExpectedType = XPath2Type.BOOLEAN_STRICT;
} else if (myExpectedType == XPath2Type.BOOLEAN) {
myExpectedType = XPath2Type.BOOLEAN_STRICT;
}
} else {
myExpectedType = XPathType.UNKNOWN;
}
} else if (XPath2TokenTypes.INTERSECT_EXCEPT.contains(op)) {
myExpectedType = XPath2SequenceType.create(XPath2Type.NODE, XPath2SequenceType.Cardinality.ZERO_OR_MORE);
} else if (op == XPath2TokenTypes.TO) {
myExpectedType = XPath2Type.INTEGER;
} else {
myExpectedType = XPathType.UNKNOWN;
}
} else {
super.visitXPathBinaryExpression(parent);
}
}
示例4: visitXPathToken
import org.intellij.lang.xpath.XPathTokenTypes; //导入依赖的package包/类
@Override
public void visitXPathToken(XPathToken token) {
if (XPathTokenTypes.REL_OPS.contains(token.getTokenType())) {
if (token.textContains('<')) {
final Annotation ann = myHolder.createErrorAnnotation(token, "'<' must be escaped as '<' in XSLT documents");
ann.registerFix(new ConvertToEntityFix(token));
ann.registerFix(new FlipOperandsFix(token));
}
}
}
示例5: checkPattern
import org.intellij.lang.xpath.XPathTokenTypes; //导入依赖的package包/类
private static boolean checkPattern(XPathExpression element) {
if (element instanceof XPathBinaryExpression) {
final XPathBinaryExpression expression = (XPathBinaryExpression)element;
if (expression.getOperator() == XPathTokenTypes.UNION) {
if (checkPattern(expression.getLOperand()) && checkPattern(expression.getROperand())) {
return true;
}
}
} else if (element instanceof XPathLocationPath) {
return checkLocationPathPattern((XPathLocationPath)element);
} else if (element instanceof XPathFunctionCall) {
return checkIdKeyPattern(element);
}
return false;
}
示例6: parseCardinality
import org.intellij.lang.xpath.XPathTokenTypes; //导入依赖的package包/类
@Nullable
public static XPath2SequenceType.Cardinality parseCardinality(Lexer lexer) {
if (lexer.getTokenType() == XPath2TokenTypes.QUEST) {
lexer.advance();
return XPath2SequenceType.Cardinality.OPTIONAL;
} else if (lexer.getTokenType() == XPathTokenTypes.MULT || lexer.getTokenType() == XPathTokenTypes.STAR) {
lexer.advance();
return XPath2SequenceType.Cardinality.ZERO_OR_MORE;
} else if (lexer.getTokenType() == XPathTokenTypes.PLUS) {
lexer.advance();
return XPath2SequenceType.Cardinality.ONE_OR_MORE;
}
return null;
}
示例7: delete
import org.intellij.lang.xpath.XPathTokenTypes; //导入依赖的package包/类
public void delete() throws IncorrectOperationException {
final ASTNode node = getNode();
final ASTNode parent = node.getTreeParent();
final ASTNode next = node.getTreeNext();
parent.removeChild(node);
if (XPath2ElementTypes.EXPRESSIONS.contains(node.getElementType())) {
if (parent.getElementType() == XPathElementTypes.FUNCTION_CALL) {
if (next != null && next.getElementType() == XPathTokenTypes.COMMA) {
parent.removeChild(next);
}
}
}
}
示例8: getQName
import org.intellij.lang.xpath.XPathTokenTypes; //导入依赖的package包/类
@Override
public PrefixedName getQName() {
final ASTNode[] nodes = getNode().getChildren(TokenSet.create(XPathTokenTypes.NCNAME));
if (nodes.length == 0) {
final ASTNode node = getNode().findChildByType(XPathTokenTypes.STAR);
if (node != null) {
return new PrefixedNameImpl(null, node);
}
} else if (nodes.length == 1) {
return new PrefixedNameImpl(nodes[0]);
} else if (nodes.length == 2) {
return new PrefixedNameImpl(nodes[0], nodes[1]);
}
return null;
}
示例9: getAxis
import org.intellij.lang.xpath.XPathTokenTypes; //导入依赖的package包/类
@NotNull
public Axis getAxis() {
final ASTNode[] nodes = getNode().getChildren(XPathTokenTypes.AXIS);
if (nodes.length > 0) {
return Axis.fromName(nodes[0].getText());
} else if (getNode().findChildByType(XPathTokenTypes.AT) != null) {
return Axis.ATTRIBUTE;
} else {
return Axis.CHILD;
}
}
示例10: getReference
import org.intellij.lang.xpath.XPathTokenTypes; //导入依赖的package包/类
@Nullable
public PsiReference getReference() {
final ASTNode name = getNode().findChildByType(XPathTokenTypes.NCNAME);
if (name != null) {
return new Reference(this, name);
}
return null;
}
示例11: matchingType
import org.intellij.lang.xpath.XPathTokenTypes; //导入依赖的package包/类
private static XPathType matchingType(XPathExpression lOperand, XPathElementType op) {
final XPathType type = mapType(lOperand, lOperand.getType());
if (op == XPathTokenTypes.PLUS) {
if (XPathType.isAssignable(XPath2Type.NUMERIC, type)) {
return XPath2Type.NUMERIC;
} else if (XPathType.isAssignable(XPath2Type.DATE, type) ||
XPathType.isAssignable(XPath2Type.TIME, type) ||
XPathType.isAssignable(XPath2Type.DATETIME, type)) {
return XPath2Type.DURATION;
} else if (XPathType.isAssignable(XPath2Type.DURATION, type)) {
return XPathType.ChoiceType.create(XPath2Type.DURATION, XPath2Type.DATE, XPath2Type.TIME, XPath2Type.DATETIME);
}
} else if (op == XPathTokenTypes.MINUS) {
if (XPathType.isAssignable(XPath2Type.NUMERIC, type)) {
return XPath2Type.NUMERIC;
} else if (XPathType.isAssignable(XPath2Type.DATE, type) ||
XPathType.isAssignable(XPath2Type.TIME, type) ||
XPathType.isAssignable(XPath2Type.DATETIME, type)) {
return XPathType.ChoiceType.create(type, XPath2Type.DURATION);
} else if (XPathType.isAssignable(XPath2Type.DURATION, type)) {
return XPath2Type.DURATION;
}
} else if (op == XPathTokenTypes.MULT) {
if (XPathType.isAssignable(XPath2Type.NUMERIC, type)) {
return XPathType.ChoiceType.create(XPath2Type.NUMERIC, XPath2Type.DURATION);
} else if (XPath2Type.DURATION.isAssignableFrom(type)) {
return XPath2Type.NUMERIC;
}
} else if (op == XPath2TokenTypes.IDIV || op == XPathTokenTypes.MOD) {
return XPath2Type.NUMERIC;
} else if (op == XPathTokenTypes.DIV) {
if (XPathType.isAssignable(XPath2Type.NUMERIC, type)) {
return XPath2Type.NUMERIC;
} else if (XPath2Type.DURATION.isAssignableFrom(type)) {
return XPath2Type.ChoiceType.create(XPath2Type.NUMERIC, XPath2Type.DURATION);
}
}
// TODO
return XPathType.UNKNOWN;
}
示例12: getInjectionRanges
import org.intellij.lang.xpath.XPathTokenTypes; //导入依赖的package包/类
@NotNull
private synchronized TextRange[] getInjectionRanges(final XmlAttribute attribute, XsltChecker.LanguageLevel languageLevel) {
final TextRange[] cachedFiles = getCachedRanges(attribute);
if (cachedFiles != null) {
return cachedFiles;
}
final String value = attribute.getDisplayValue();
if (value == null) return EMPTY_ARRAY;
final TextRange[] ranges;
if (XsltSupport.mayBeAVT(attribute)) {
final List<TextRange> avtRanges = new SmartList<TextRange>();
int i;
int j = 0;
Lexer lexer = null;
while ((i = XsltSupport.getAVTOffset(value, j)) != -1) {
if (lexer == null) {
lexer = LanguageParserDefinitions.INSTANCE.forLanguage(languageLevel.getXPathVersion().getLanguage())
.createLexer(attribute.getProject());
}
// "A right curly brace inside a Literal in an expression is not recognized as terminating the expression."
lexer.start(value, i, value.length());
j = -1;
while (lexer.getTokenType() != null) {
if (lexer.getTokenType() == XPathTokenTypes.RBRACE) {
j = lexer.getTokenStart();
break;
}
lexer.advance();
}
if (j != -1) {
avtRanges.add(AVTRange.create(attribute, i, j + 1, j > i + 1));
} else {
// missing '}' error will be flagged by xpath parser
avtRanges.add(AVTRange.create(attribute, i, value.length(), false));
break;
}
}
if (avtRanges.size() > 0) {
ranges = avtRanges.toArray(new TextRange[avtRanges.size()]);
} else {
ranges = EMPTY_ARRAY;
}
} else {
ranges = new TextRange[]{ attribute.getValueTextRange() };
}
attribute.putUserData(CACHED_FILES, Pair.create(attribute.getValue(), ranges));
return ranges;
}
示例13: isAbsolute
import org.intellij.lang.xpath.XPathTokenTypes; //导入依赖的package包/类
public boolean isAbsolute() {
return getPreviousStep() == null && getNode().getChildren(XPathTokenTypes.PATH_OPS).length > 0;
}
示例14: getNameNode
import org.intellij.lang.xpath.XPathTokenTypes; //导入依赖的package包/类
@Nullable
protected ASTNode getNameNode() {
return getNode().findChildByType(XPathTokenTypes.NODE_TYPE);
}
示例15: getNameNode
import org.intellij.lang.xpath.XPathTokenTypes; //导入依赖的package包/类
@Nullable
protected ASTNode getNameNode() {
return getNode().findChildByType(XPathTokenTypes.FUNCTION_NAME);
}