本文整理汇总了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;
}
}
示例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);
}
}
}
示例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);
}
}
}
示例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);
}
}
}
示例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();
}
}
示例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();
}
}
示例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();
}
}
示例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));
}
示例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;
}