当前位置: 首页>>代码示例>>Java>>正文


Java BodyDeclaration.accept方法代码示例

本文整理汇总了Java中com.github.javaparser.ast.body.BodyDeclaration.accept方法的典型用法代码示例。如果您正苦于以下问题:Java BodyDeclaration.accept方法的具体用法?Java BodyDeclaration.accept怎么用?Java BodyDeclaration.accept使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.github.javaparser.ast.body.BodyDeclaration的用法示例。


在下文中一共展示了BodyDeclaration.accept方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: printMembers

import com.github.javaparser.ast.body.BodyDeclaration; //导入方法依赖的package包/类
private void printMembers(final NodeList<BodyDeclaration<?>> members, final Void arg) {
	BodyDeclaration<?> prev = null;

	members.sort((a, b) -> {
		if (a instanceof FieldDeclaration && b instanceof CallableDeclaration) {
			return 1;
		} else if (b instanceof FieldDeclaration && a instanceof CallableDeclaration) {
			return -1;
		} else if (a instanceof MethodDeclaration && !((MethodDeclaration) a).getModifiers().contains(Modifier.STATIC) && b instanceof ConstructorDeclaration) {
			return 1;
		} else if (b instanceof MethodDeclaration && !((MethodDeclaration) b).getModifiers().contains(Modifier.STATIC) && a instanceof ConstructorDeclaration) {
			return -1;
		} else {
			return 0;
		}
	});

	for (final BodyDeclaration<?> member : members) {
		if (prev != null && (!prev.isFieldDeclaration() || !member.isFieldDeclaration())) printer.println();
		member.accept(this, arg);
		printer.println();

		prev = member;
	}
}
 
开发者ID:sfPlayer1,项目名称:Matcher,代码行数:26,代码来源:SrcRemapper.java

示例2: visit

import com.github.javaparser.ast.body.BodyDeclaration; //导入方法依赖的package包/类
@Override public void visit(final AnnotationDeclaration n, final A arg) {
	visitComment(n.getComment(), arg);
	if (n.getJavaDoc() != null) {
		n.getJavaDoc().accept(this, arg);
	}
	if (n.getAnnotations() != null) {
		for (final AnnotationExpr a : n.getAnnotations()) {
			a.accept(this, arg);
		}
	}
	if (n.getMembers() != null) {
		for (final BodyDeclaration member : n.getMembers()) {
			member.accept(this, arg);
		}
	}
}
 
开发者ID:plum-umd,项目名称:java-sketch,代码行数:17,代码来源:VoidVisitorAdapter.java

示例3: visit

import com.github.javaparser.ast.body.BodyDeclaration; //导入方法依赖的package包/类
@Override public void visit(final AnnotationDeclaration n, final A arg) {
    jw.write(n); 
    visitComment(n.getComment(), arg);
    if (n.getJavaDoc() != null) {
        n.getJavaDoc().accept(this, arg);
    }
    if (n.getAnnotations() != null) {
        for (final AnnotationExpr a : n.getAnnotations()) {
            a.accept(this, arg);
        }
    }
    if (n.getMembers() != null) {
        for (final BodyDeclaration member : n.getMembers()) {
            member.accept(this, arg);
        }
    }
}
 
开发者ID:plum-umd,项目名称:java-sketch,代码行数:18,代码来源:JsonVisitorAdapter.java

示例4: visit

import com.github.javaparser.ast.body.BodyDeclaration; //导入方法依赖的package包/类
@Override public void visit(final EnumDeclaration n, final A arg) {
	visitComment(n.getComment(), arg);
	visitAnnotations(n, arg);
	n.getNameExpr().accept(this, arg);
	if (n.getImplements() != null) {
		for (final ClassOrInterfaceType c : n.getImplements()) {
			c.accept(this, arg);
		}
	}
	if (n.getEntries() != null) {
		for (final EnumConstantDeclaration e : n.getEntries()) {
			e.accept(this, arg);
		}
	}
	if (n.getMembers() != null) {
           for (final BodyDeclaration<?> member : n.getMembers()) {
			member.accept(this, arg);
		}
	}
}
 
开发者ID:javaparser,项目名称:javasymbolsolver,代码行数:21,代码来源:VoidVisitorAdapter.java

示例5: printMembers

import com.github.javaparser.ast.body.BodyDeclaration; //导入方法依赖的package包/类
public void printMembers(final List<BodyDeclaration> members, final Object arg) {
    for (final BodyDeclaration member : members) {
        printer.printLn();
        member.accept(this, arg);
        printer.printLn();
    }
}
 
开发者ID:pcgomes,项目名称:javaparser2jctree,代码行数:8,代码来源:ASTDumpVisitor.java

示例6: printMembers

import com.github.javaparser.ast.body.BodyDeclaration; //导入方法依赖的package包/类
private void printMembers(final List<BodyDeclaration> members, final Object arg) {
for (final BodyDeclaration member : members) {
    printer.printLn();
    member.accept(this, arg);
    printer.printLn();
}
   }
 
开发者ID:plum-umd,项目名称:java-sketch,代码行数:8,代码来源:DumpVisitor.java

示例7: printMembers

import com.github.javaparser.ast.body.BodyDeclaration; //导入方法依赖的package包/类
private void printMembers(final List<BodyDeclaration> members, final Object arg) {
	for (final BodyDeclaration member : members) {
		printer.printLn();
		member.accept(this, arg);
		printer.printLn();
	}
}
 
开发者ID:javaparser,项目名称:javasymbolsolver,代码行数:8,代码来源:DumpVisitor.java

示例8: IRRepresentation

import com.github.javaparser.ast.body.BodyDeclaration; //导入方法依赖的package包/类
private IRRepresentation(String methodBody) {
    final BodyDeclaration<?> cu = JavaParser.parseBodyDeclaration(methodBody);
    cu.accept(new IRVisitor(this), new VisitorContext(this, null, null));
}
 
开发者ID:linzeqipku,项目名称:SnowGraph,代码行数:5,代码来源:IRRepresentation.java

示例9: visit

import com.github.javaparser.ast.body.BodyDeclaration; //导入方法依赖的package包/类
@Override
  public Node visit(final ClassOrInterfaceDeclaration n, final Object arg) {

      if (!(n.isInterface())) {

          // Preserve the value of flag indicating that enclosing class
          // has found the default constructor.
          boolean storedprev = founddefault;
          founddefault = false;

          // Generates a new list, which might even be empty.
          Vector<BodyDeclaration> lnewlist = new Vector<BodyDeclaration>();

/* Code for unfolding field declaration */
          if (n.getMembers() != null) {
              for (final BodyDeclaration b : n.getMembers()) {
                  BodyDeclaration mydecl = (BodyDeclaration) b.accept(this, arg);

                  // Append the expanded list to list of bodydeclaration
                  if (mydecl instanceof ListFieldDeclaration) {
                      lnewlist.addAll(((ListFieldDeclaration) mydecl).getVarDecls());
                  } else {
                      lnewlist.add(mydecl);
                  }
              }
          }

/*
        Code for detecting declaration of default contructor.
 Clone metadata from class declaration.
 */
          if (!(founddefault)) {
              lnewlist.add(new ConstructorDeclaration(n.getModifiers(),
                      new Vector<AnnotationExpr>(),
                      new Vector<TypeParameter>(),
                      n.getName(),
                      new Vector<Parameter>(),
                      new Vector<NameExpr>(),
                      new BlockStmt(new Vector<Statement>())));
          }

          // Restore the value for the flag relative to enclosing class
          founddefault = storedprev;

          // Set the generated list
          n.setMembers(lnewlist);
      }

      return n;
  }
 
开发者ID:pcgomes,项目名称:javaparser2jctree,代码行数:51,代码来源:ComplyToJCVisitor.java


注:本文中的com.github.javaparser.ast.body.BodyDeclaration.accept方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。