本文整理汇总了Java中com.github.javaparser.ASTHelper.addArgument方法的典型用法代码示例。如果您正苦于以下问题:Java ASTHelper.addArgument方法的具体用法?Java ASTHelper.addArgument怎么用?Java ASTHelper.addArgument使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.github.javaparser.ASTHelper
的用法示例。
在下文中一共展示了ASTHelper.addArgument方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: createStatementExecuteBlock
import com.github.javaparser.ASTHelper; //导入方法依赖的package包/类
private BlockStmt createStatementExecuteBlock() {
BlockStmt block = new BlockStmt();
MethodCallExpr stmtExecute = new MethodCallExpr(ASTHelper.createNameExpr("stmt"), "execute");
ASTHelper.addArgument(stmtExecute, new StringLiteralExpr(createTableStatement));
ASTHelper.addStmt(block, stmtExecute);
return block;
}
示例2: visit
import com.github.javaparser.ASTHelper; //导入方法依赖的package包/类
public void visit(final BlockStmt n, final RoutingDefineContext arg) {
if (arg.isInRoutingDefine()) {
MethodCallExpr call = new MethodCallExpr(
ASTHelper.createNameExpr(arg.getRoutingParameter().getId().getName()),
"resource");
ReferenceType rt = ASTHelper.createReferenceType(controllerClassName, 0);
ASTHelper.addArgument(call, new ClassExpr(rt.getType()));
ASTHelper.addStmt(n, call);
} else {
super.visit(n, arg);
}
}
示例3: createCU
import com.github.javaparser.ASTHelper; //导入方法依赖的package包/类
/**
* creates the compilation unit
*/
private static CompilationUnit createCU() {
CompilationUnit cu = new CompilationUnit();
// set the package
cu.setPackage(new PackageDeclaration(ASTHelper.createNameExpr("java.parser.test")));
// create the type declaration
ClassOrInterfaceDeclaration type = new ClassOrInterfaceDeclaration(ModifierSet.PUBLIC, false, "GeneratedClass");
ASTHelper.addTypeDeclaration(cu, type);
// create a method
MethodDeclaration method = new MethodDeclaration(ModifierSet.PUBLIC, ASTHelper.VOID_TYPE, "main");
method.setModifiers(ModifierSet.addModifier(method.getModifiers(), ModifierSet.STATIC));
ASTHelper.addMember(type, method);
// add a parameter to the method
Parameter param = ASTHelper.createParameter(ASTHelper.createReferenceType("String", 0), "args");
param.setVarArgs(true);
ASTHelper.addParameter(method, param);
// add a body to the method
BlockStmt block = new BlockStmt();
method.setBody(block);
// add a statement do the method body
NameExpr clazz = new NameExpr("System");
FieldAccessExpr field = new FieldAccessExpr(clazz, "out");
MethodCallExpr call = new MethodCallExpr(field, "println");
ASTHelper.addArgument(call, new StringLiteralExpr("Hello World!"));
ASTHelper.addStmt(block, call);
return cu;
}
示例4: setup
import com.github.javaparser.ASTHelper; //导入方法依赖的package包/类
@Before
public void setup(){
CompilationUnit cu = new CompilationUnit();
// set the package
cu.setPackage(new PackageDeclaration(ASTHelper.createNameExpr("java.parser.test")));
// create the type declaration
ClassOrInterfaceDeclaration type = new ClassOrInterfaceDeclaration(ModifierSet.PUBLIC, false, "GeneratedClass");
ASTHelper.addTypeDeclaration(cu, type);
// create a method
MethodDeclaration method = new MethodDeclaration(ModifierSet.PUBLIC, ASTHelper.VOID_TYPE, "main");
method.setModifiers(ModifierSet.addModifier(method.getModifiers(), ModifierSet.STATIC));
ASTHelper.addMember(type, method);
// add a parameter to the method
Parameter param = ASTHelper.createParameter(ASTHelper.createReferenceType("String", 0), "args");
param.setVarArgs(true);
ASTHelper.addParameter(method, param);
// add a body to the method
BlockStmt block = new BlockStmt();
method.setBody(block);
// add a statement do the method body
NameExpr clazz = new NameExpr("System");
FieldAccessExpr field = new FieldAccessExpr(clazz, "out");
MethodCallExpr call = new MethodCallExpr(field, "println");
ASTHelper.addArgument(call, new StringLiteralExpr("Hello World!"));
ASTHelper.addStmt(block, call);
unit = cu;
}
示例5: whenHelloWorldIsAddedToTheBodyOfMethodInClass
import com.github.javaparser.ASTHelper; //导入方法依赖的package包/类
@When("$className.$fieldName.$methodName(\"$stringValue\"); is added to the body of method $methodPosition in class $classPosition")
public void whenHelloWorldIsAddedToTheBodyOfMethodInClass(String className, String fieldName, String methodName, String stringValue,
int methodPosition, int classPosition) {
CompilationUnit compilationUnit = (CompilationUnit) state.get("cu1");
MethodDeclaration method = getMethodByPositionAndClassPosition(compilationUnit, methodPosition, classPosition);
NameExpr clazz = new NameExpr(className);
FieldAccessExpr field = new FieldAccessExpr(clazz, fieldName);
MethodCallExpr call = new MethodCallExpr(field, methodName);
ASTHelper.addArgument(call, new StringLiteralExpr(stringValue));
ASTHelper.addStmt(method.getBody(), call);
}