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

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

本文整理了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

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

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

  1. private void setSuppression(Rule rule, T node) {
  2. String regex = rule.getProperty(Rule.VIOLATION_SUPPRESS_REGEX_DESCRIPTOR); // Regex
  3. if (regex != null && description != null) {
  4. if (Pattern.matches(regex, description)) {
  5. suppressed = true;
  6. }
  7. }
  8. if (!suppressed) { // XPath
  9. String xpath = rule.getProperty(Rule.VIOLATION_SUPPRESS_XPATH_DESCRIPTOR);
  10. if (xpath != null) {
  11. suppressed = node.hasDescendantMatchingXPath(xpath);
  12. }
  13. }
  14. }

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

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

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

  1. private void setSuppression(Rule rule, T node) {
  2. String regex = rule.getProperty(Rule.VIOLATION_SUPPRESS_REGEX_DESCRIPTOR); // Regex
  3. if (regex != null && description != null) {
  4. if (Pattern.matches(regex, description)) {
  5. suppressed = true;
  6. }
  7. }
  8. if (!suppressed) { // XPath
  9. String xpath = rule.getProperty(Rule.VIOLATION_SUPPRESS_XPATH_DESCRIPTOR);
  10. if (xpath != null) {
  11. suppressed = node.hasDescendantMatchingXPath(xpath);
  12. }
  13. }
  14. }

相关文章