当前位置: 首页>>代码示例>>Java>>正文


Java XPathTokenTypes类代码示例

本文整理汇总了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");
      }
    }
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:20,代码来源:XsltAnnotator.java

示例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;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:22,代码来源:XPathNodeTestImpl.java

示例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);
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:35,代码来源:ExpectedTypeUtil.java

示例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 '&lt;' in XSLT documents");
      ann.registerFix(new ConvertToEntityFix(token));
      ann.registerFix(new FlipOperandsFix(token));
    }
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:11,代码来源:XsltAnnotator.java

示例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;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:16,代码来源:XsltPatternValidator.java

示例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;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:15,代码来源:FunctionDeclarationParsing.java

示例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);
      }
    }
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:16,代码来源:XPathElementImpl.java

示例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;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:16,代码来源:XPath2TypeElementImpl.java

示例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;
    }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:12,代码来源:XPathAxisSpecifierImpl.java

示例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;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:9,代码来源:XPathNodeTestImpl.java

示例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;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:42,代码来源:ExpectedTypeUtil.java

示例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;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:57,代码来源:XPathLanguageInjector.java

示例13: isAbsolute

import org.intellij.lang.xpath.XPathTokenTypes; //导入依赖的package包/类
public boolean isAbsolute() {
  return getPreviousStep() == null && getNode().getChildren(XPathTokenTypes.PATH_OPS).length > 0;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:4,代码来源:XPathStepImpl.java

示例14: getNameNode

import org.intellij.lang.xpath.XPathTokenTypes; //导入依赖的package包/类
@Nullable
protected ASTNode getNameNode() {
    return getNode().findChildByType(XPathTokenTypes.NODE_TYPE);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:5,代码来源:XPathNodeTypeTestImpl.java

示例15: getNameNode

import org.intellij.lang.xpath.XPathTokenTypes; //导入依赖的package包/类
@Nullable
protected ASTNode getNameNode() {
  return getNode().findChildByType(XPathTokenTypes.FUNCTION_NAME);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:5,代码来源:XPathFunctionCallImpl.java


注:本文中的org.intellij.lang.xpath.XPathTokenTypes类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。