com.github.javaparser.ast.Node.getChildrenNodes()方法的使用及代码示例

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

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

Node.getChildrenNodes介绍

暂无

代码示例

代码示例来源:origin: stackoverflow.com

  1. public Set<Node> getActiveChildrenNodes(Node n){
  2. Set<Node> result = new HashSet();
  3. for(Node cn : n.getChildrenNodes()){
  4. if(cn.isActive)
  5. result.add(cn);
  6. }
  7. return result;
  8. }

代码示例来源:origin: stackoverflow.com

  1. void process(Node node){
  2. // Do something with the node
  3. for (Node child : node.getChildrenNodes()){
  4. process(child);
  5. }
  6. }

代码示例来源:origin: org.jooby/jooby-spec

  1. private List<MethodCallExpr> dump(final Node n) {
  2. List<MethodCallExpr> dump = new ArrayList<>();
  3. if (n instanceof MethodCallExpr) {
  4. dump.add((MethodCallExpr) n);
  5. }
  6. List<Node> children = n.getChildrenNodes();
  7. for (Node c : children) {
  8. dump.addAll(dump(c));
  9. }
  10. return dump;
  11. }

代码示例来源:origin: org.wisdom-framework/wisdom-source-model

  1. /**
  2. * <p>
  3. * Extract the String value for each child of the <code>node</code> or the node itself if it does not
  4. * have children.
  5. * </p>
  6. *
  7. * <p>It removes the {@literal "}.</p>
  8. * @param node The java node which children or value to convert into a list of string.
  9. * @return list of the node children string value or singleton list with the value of the node if no children.
  10. */
  11. public static Set<String> asStringSet(Node node){
  12. if(node.getChildrenNodes() == null || node.getChildrenNodes().isEmpty()){
  13. return singleton(asString(node));
  14. }
  15. Set<String> list = new LinkedHashSet<>(node.getChildrenNodes().size());
  16. for(Node child: node.getChildrenNodes()){
  17. list.add(asString(child));
  18. }
  19. return list;
  20. }

代码示例来源:origin: stackoverflow.com

  1. void processNode(Node node) {
  2. if (node instanceof TypeDeclaration) {
  3. // do something with this type declaration
  4. } else if (node instanceof MethodDeclaration) {
  5. // do something with this method declaration
  6. } else if (node instanceof FieldDeclaration) {
  7. // do something with this field declaration
  8. }
  9. for (Node child : node.getChildrenNodes()){
  10. processNode(child);
  11. }
  12. }
  13. ...
  14. CompilationUnit cu = JavaParser.parse(sourceFile);
  15. processNode(node);
  16. ...

相关文章