本文整理了Java中net.sourceforge.pmd.lang.ast.Node.findChildNodesWithXPath()
方法的一些代码示例,展示了Node.findChildNodesWithXPath()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Node.findChildNodesWithXPath()
方法的具体详情如下:
包路径:net.sourceforge.pmd.lang.ast.Node
类名称:Node
方法名:findChildNodesWithXPath
[英]Returns all the nodes matching the xpath expression.
[中]返回与xpath表达式匹配的所有节点。
代码示例来源:origin: pmd/pmd
private boolean isEmptyArray(String varName, ASTTypeDeclaration typeDeclaration) {
final List<ASTFieldDeclaration> fds = typeDeclaration.findDescendantsOfType(ASTFieldDeclaration.class);
if (fds != null) {
for (ASTFieldDeclaration fd : fds) {
final ASTVariableDeclaratorId vid = fd.getFirstDescendantOfType(ASTVariableDeclaratorId.class);
if (vid != null && vid.hasImageEqualTo(varName)) {
ASTVariableInitializer initializer = fd.getFirstDescendantOfType(ASTVariableInitializer.class);
if (initializer != null && initializer.jjtGetNumChildren() == 1) {
Node child = initializer.jjtGetChild(0);
if (child instanceof ASTArrayInitializer && child.jjtGetNumChildren() == 0) {
return true;
} else if (child instanceof ASTExpression) {
try {
List<? extends Node> arrayAllocation = child.findChildNodesWithXPath(
"./PrimaryExpression/PrimaryPrefix/AllocationExpression/ArrayDimsAndInits/Expression/PrimaryExpression/PrimaryPrefix/Literal[@IntLiteral=\"true\"][@Image=\"0\"]");
if (arrayAllocation != null && arrayAllocation.size() == 1) {
return true;
}
} catch (JaxenException e) {
return false;
}
}
}
}
}
}
return false;
}
}
代码示例来源:origin: net.sourceforge.pmd/pmd-java
private boolean isEmptyArray(String varName, ASTTypeDeclaration typeDeclaration) {
final List<ASTFieldDeclaration> fds = typeDeclaration.findDescendantsOfType(ASTFieldDeclaration.class);
if (fds != null) {
for (ASTFieldDeclaration fd : fds) {
final ASTVariableDeclaratorId vid = fd.getFirstDescendantOfType(ASTVariableDeclaratorId.class);
if (vid != null && vid.hasImageEqualTo(varName)) {
ASTVariableInitializer initializer = fd.getFirstDescendantOfType(ASTVariableInitializer.class);
if (initializer != null && initializer.jjtGetNumChildren() == 1) {
Node child = initializer.jjtGetChild(0);
if (child instanceof ASTArrayInitializer && child.jjtGetNumChildren() == 0) {
return true;
} else if (child instanceof ASTExpression) {
try {
List<? extends Node> arrayAllocation = child.findChildNodesWithXPath(
"./PrimaryExpression/PrimaryPrefix/AllocationExpression/ArrayDimsAndInits/Expression/PrimaryExpression/PrimaryPrefix/Literal[@IntLiteral=\"true\"][@Image=\"0\"]");
if (arrayAllocation != null && arrayAllocation.size() == 1) {
return true;
}
} catch (JaxenException e) {
return false;
}
}
}
}
}
}
return false;
}
}
代码示例来源:origin: com.alibaba.p3c/p3c-pmd
List<? extends Node> additiveNodes = node.findChildNodesWithXPath(XPATH);
for (Node additiveNode : additiveNodes) {
ASTAdditiveExpression additiveExpression = (ASTAdditiveExpression)additiveNode;
代码示例来源:origin: com.alibaba.p3c/p3c-pmd
List<? extends Node> simpleExpressions = invocation.findChildNodesWithXPath(INVOCATION_PREFIX_XPATH);
if (simpleExpressions == null || simpleExpressions.isEmpty()) {
return super.visit(node, data);
内容来源于网络,如有侵权,请联系作者删除!