net.sourceforge.pmd.lang.ast.Node.hasDescendantMatchingXPath()方法的使用及代码示例

x33g5p2x  于2022-01-25 转载在 其他  
字(2.0k)|赞(0)|评价(0)|浏览(81)

本文整理了Java中net.sourceforge.pmd.lang.ast.Node.hasDescendantMatchingXPath()方法的一些代码示例,展示了Node.hasDescendantMatchingXPath()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Node.hasDescendantMatchingXPath()方法的具体详情如下:
包路径:net.sourceforge.pmd.lang.ast.Node
类名称:Node
方法名:hasDescendantMatchingXPath

Node.hasDescendantMatchingXPath介绍

[英]Checks whether at least one descendant matches the xpath expression.
[中]检查是否至少有一个子代与xpath表达式匹配。

代码示例

代码示例来源:origin: pmd/pmd

private boolean searchForAMatch(String matchType, Node node) {
  String xpathQuery = "//ClassOrInterfaceDeclaration[(./ExtendsList/ClassOrInterfaceType[@Image = '" + matchType
      + "']) or (./ImplementsList/ClassOrInterfaceType[@Image = '" + matchType + "'])]";
  return node.hasDescendantMatchingXPath(xpathQuery);
}

代码示例来源:origin: pmd/pmd

private void setSuppression(Rule rule, T node) {
  String regex = rule.getProperty(Rule.VIOLATION_SUPPRESS_REGEX_DESCRIPTOR); // Regex
  if (regex != null && description != null) {
    if (Pattern.matches(regex, description)) {
      suppressed = true;
    }
  }
  if (!suppressed) { // XPath
    String xpath = rule.getProperty(Rule.VIOLATION_SUPPRESS_XPATH_DESCRIPTOR);
    if (xpath != null) {
      suppressed = node.hasDescendantMatchingXPath(xpath);
    }
  }
}

代码示例来源:origin: net.sourceforge.pmd/pmd-java

private boolean searchForAMatch(String matchType, Node node) {
  String xpathQuery = "//ClassOrInterfaceDeclaration[(./ExtendsList/ClassOrInterfaceType[@Image = '" + matchType
      + "']) or (./ImplementsList/ClassOrInterfaceType[@Image = '" + matchType + "'])]";
  return node.hasDescendantMatchingXPath(xpathQuery);
}

代码示例来源:origin: net.sourceforge.pmd/pmd-core

private void setSuppression(Rule rule, T node) {
  String regex = rule.getProperty(Rule.VIOLATION_SUPPRESS_REGEX_DESCRIPTOR); // Regex
  if (regex != null && description != null) {
    if (Pattern.matches(regex, description)) {
      suppressed = true;
    }
  }
  if (!suppressed) { // XPath
    String xpath = rule.getProperty(Rule.VIOLATION_SUPPRESS_XPATH_DESCRIPTOR);
    if (xpath != null) {
      suppressed = node.hasDescendantMatchingXPath(xpath);
    }
  }
}

相关文章