本文整理汇总了Java中com.github.javaparser.ast.Node.getChildNodes方法的典型用法代码示例。如果您正苦于以下问题:Java Node.getChildNodes方法的具体用法?Java Node.getChildNodes怎么用?Java Node.getChildNodes使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.github.javaparser.ast.Node
的用法示例。
在下文中一共展示了Node.getChildNodes方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: findNameExpression
import com.github.javaparser.ast.Node; //导入方法依赖的package包/类
public static NameExpr findNameExpression(Node node, String name) {
if (node instanceof NameExpr) {
NameExpr nameExpr = (NameExpr) node;
if (nameExpr.getName() != null && nameExpr.getName().getId().equals(name)) {
return nameExpr;
}
}
for (Node child : node.getChildNodes()) {
NameExpr res = findNameExpression(child, name);
if (res != null) {
return res;
}
}
return null;
}
示例2: findSimpleName
import com.github.javaparser.ast.Node; //导入方法依赖的package包/类
public static SimpleName findSimpleName(Node node, String name) {
if (node instanceof SimpleName) {
SimpleName nameExpr = (SimpleName) node;
if (nameExpr.getId() != null && nameExpr.getId().equals(name)) {
return nameExpr;
}
}
for (Node child : node.getChildNodes()) {
SimpleName res = findSimpleName(child, name);
if (res != null) {
return res;
}
}
return null;
}
示例3: findMethodCall
import com.github.javaparser.ast.Node; //导入方法依赖的package包/类
public static MethodCallExpr findMethodCall(Node node, String methodName) {
if (node instanceof MethodCallExpr) {
MethodCallExpr methodCallExpr = (MethodCallExpr) node;
if (methodCallExpr.getName().getId().equals(methodName)) {
return methodCallExpr;
}
}
for (Node child : node.getChildNodes()) {
MethodCallExpr res = findMethodCall(child, methodName);
if (res != null) {
return res;
}
}
return null;
}
示例4: demandVariableDeclaration
import com.github.javaparser.ast.Node; //导入方法依赖的package包/类
public static VariableDeclarator demandVariableDeclaration(Node node, String name) {
if (node instanceof VariableDeclarator) {
VariableDeclarator variableDeclarator = (VariableDeclarator) node;
if (variableDeclarator.getName().getId().equals(name)) {
return variableDeclarator;
}
}
for (Node child : node.getChildNodes()) {
VariableDeclarator res = demandVariableDeclaration(child, name);
if (res != null) {
return res;
}
}
return null;
}
示例5: findSwitchHelper
import com.github.javaparser.ast.Node; //导入方法依赖的package包/类
private static SwitchStmt findSwitchHelper(Node node) {
if (node instanceof SwitchStmt) {
return (SwitchStmt) node;
}
for (Node child : node.getChildNodes()) {
SwitchStmt resChild = findSwitchHelper(child);
if (resChild != null) {
return resChild;
}
}
return null;
}
示例6: findNodeOfGivenClassHelper
import com.github.javaparser.ast.Node; //导入方法依赖的package包/类
private static <N> N findNodeOfGivenClassHelper(Node node, Class<N> clazz) {
if (clazz.isInstance(node)) {
return clazz.cast(node);
}
for (Node child : node.getChildNodes()) {
N resChild = findNodeOfGivenClassHelper(child, clazz);
if (resChild != null) {
return resChild;
}
}
return null;
}
示例7: findAllNodesOfGivenClassHelper
import com.github.javaparser.ast.Node; //导入方法依赖的package包/类
private static <N> void findAllNodesOfGivenClassHelper(Node node, Class<N> clazz, List<N> collector) {
if (clazz.isInstance(node)) {
collector.add(clazz.cast(node));
}
for (Node child : node.getChildNodes()) {
findAllNodesOfGivenClassHelper(child, clazz, collector);
}
}
示例8: solveMethodCalls
import com.github.javaparser.ast.Node; //导入方法依赖的package包/类
private void solveMethodCalls(Node node) {
if (node instanceof MethodCallExpr) {
out.println(" Line " + node.getBegin().get().line + ") " + node + " ==> " + toString((MethodCallExpr) node));
}
for (Node child : node.getChildNodes()) {
solveMethodCalls(child);
}
}