本文整理汇总了Java中japa.parser.ast.body.MethodDeclaration.getArrayCount方法的典型用法代码示例。如果您正苦于以下问题:Java MethodDeclaration.getArrayCount方法的具体用法?Java MethodDeclaration.getArrayCount怎么用?Java MethodDeclaration.getArrayCount使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类japa.parser.ast.body.MethodDeclaration
的用法示例。
在下文中一共展示了MethodDeclaration.getArrayCount方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: visit
import japa.parser.ast.body.MethodDeclaration; //导入方法依赖的package包/类
@Override
public MethodDeclaration visit(MethodDeclaration n, Void arg) {
if (!n.isGenerator()) {
throw new UnsupportedOperationException("cannot transform non-generator");
}
// Desugar ALL the loops!
n.accept(new LoopDesugarTransform(), null);
if (CompilerSettings.dumpDesugar) {
System.err.println(n);
}
Generator g = new Generator();
Map<String, TypedVariableDeclarator> vars = new HashMap<String, TypedVariableDeclarator>();
// Mangle all our scope variables.
n.accept(new ScopeMangleTransform(), vars);
if (CompilerSettings.dumpMangle) {
System.err.println(n);
}
// Generate the body.
n.accept(new LinearizeTransform(), g);
List<BodyDeclaration> generatorBody = new ArrayList<BodyDeclaration>();
// Add the fields to the generator body.
for (Map.Entry<String, TypedVariableDeclarator> kv : vars.entrySet()) {
VariableDeclarator decl = new VariableDeclarator(new VariableDeclaratorId(kv.getKey()), null);
generatorBody.add(new FieldDeclaration(ModifierSet.PRIVATE, kv.getValue().type, decl));
}
// Add the moveNext method to the generator body.
generatorBody.add(new MethodDeclaration(0, 0, 0, 0, null, ModifierSet.PROTECTED,
null, null, new PrimitiveType(Primitive.Boolean),
"moveNext", null, 0, null, false,
new BlockStmt(g.generate())));
ObjectCreationExpr o = new ObjectCreationExpr(0, 0, 0, 0, null, makeRtGeneratorType(n.getType()), null, null, generatorBody);
List<Statement> methodBody = new ArrayList<Statement>();
methodBody.add(new ReturnStmt(o));
MethodDeclaration n2 = new MethodDeclaration(n.getBeginLine(),
n.getBeginColumn(),
n.getEndLine(),
n.getEndColumn(),
n.getJavaDoc(),
n.getModifiers(),
n.getAnnotations(),
n.getTypeParameters(),
makeRtGeneratorType(n.getType()),
n.getName(),
n.getParameters(),
n.getArrayCount(),
n.getThrows(),
false,
new BlockStmt(methodBody));
return n2;
}
示例2: visit
import japa.parser.ast.body.MethodDeclaration; //导入方法依赖的package包/类
public Boolean visit(MethodDeclaration n1, Node arg) {
MethodDeclaration n2 = (MethodDeclaration) arg;
// javadoc are checked at CompilationUnit
if (n1.getModifiers() != n2.getModifiers()) {
return Boolean.FALSE;
}
if (n1.getArrayCount() != n2.getArrayCount()) {
return Boolean.FALSE;
}
if (!objEquals(n1.getName(), n2.getName())) {
return Boolean.FALSE;
}
if (!nodeEquals(n1.getType(), n2.getType())) {
return Boolean.FALSE;
}
if (!nodesEquals(n1.getAnnotations(), n2.getAnnotations())) {
return Boolean.FALSE;
}
if (!nodeEquals(n1.getBody(), n2.getBody())) {
return Boolean.FALSE;
}
if (!nodesEquals(n1.getParameters(), n2.getParameters())) {
return Boolean.FALSE;
}
if (!nodesEquals(n1.getThrows(), n2.getThrows())) {
return Boolean.FALSE;
}
if (!nodesEquals(n1.getTypeParameters(), n2.getTypeParameters())) {
return Boolean.FALSE;
}
return Boolean.TRUE;
}
示例3: visit
import japa.parser.ast.body.MethodDeclaration; //导入方法依赖的package包/类
public void visit(MethodDeclaration n, Object arg) {
printJavadoc(n.getJavaDoc(), arg);
printMemberAnnotations(n.getAnnotations(), arg);
printModifiers(n.getModifiers());
printTypeParameters(n.getTypeParameters(), arg);
if (n.getTypeParameters() != null) {
printer.print(" ");
}
n.getType().accept(this, arg);
if (n.isGenerator()) {
printer.print("*");
}
printer.print(" ");
printer.print(n.getName());
printer.print("(");
if (n.getParameters() != null) {
for (Iterator<Parameter> i = n.getParameters().iterator(); i.hasNext();) {
Parameter p = i.next();
p.accept(this, arg);
if (i.hasNext()) {
printer.print(", ");
}
}
}
printer.print(")");
for (int i = 0; i < n.getArrayCount(); i++) {
printer.print("[]");
}
if (n.getThrows() != null) {
printer.print(" throws ");
for (Iterator<NameExpr> i = n.getThrows().iterator(); i.hasNext();) {
NameExpr name = i.next();
name.accept(this, arg);
if (i.hasNext()) {
printer.print(", ");
}
}
}
if (n.getBody() == null) {
printer.print(";");
} else {
printer.print(" ");
n.getBody().accept(this, arg);
}
}