use of com.github.javaparser.ast.body.MethodDeclaration in project javaparser by javaparser.
the class MethodDeclarationTransformationsTest method removingLastParameterOfMany.
@Test
public void removingLastParameterOfMany() throws IOException {
MethodDeclaration it = consider("public void foo(double d, float f){}");
it.getParameters().remove(1);
assertTransformedToString("public void foo(double d){}", it);
}
use of com.github.javaparser.ast.body.MethodDeclaration in project javaparser by javaparser.
the class MethodDeclarationTransformationsTest method addingParameters.
// Parameters
@Test
public void addingParameters() throws IOException {
MethodDeclaration it = consider("void foo(){}");
it.addParameter(PrimitiveType.doubleType(), "d");
assertTransformedToString("void foo(double d){}", it);
}
use of com.github.javaparser.ast.body.MethodDeclaration in project javaparser by javaparser.
the class TransformationsTest method exampleParam2.
@Test
public void exampleParam2() throws IOException {
considerExample("Example_param1_original");
MethodDeclaration md = (MethodDeclaration) cu.getClassByName("A").get().getMember(0).asMethodDeclaration();
md.addParameter(new ArrayType(PrimitiveType.intType()), "p1");
md.addParameter("char", "p2");
assertTransformed("Example_param2", cu);
}
use of com.github.javaparser.ast.body.MethodDeclaration in project javaparser by javaparser.
the class TransformationsTest method exampleParam1.
@Test
public void exampleParam1() throws IOException {
considerExample("Example_param1_original");
MethodDeclaration md = (MethodDeclaration) cu.getClassByName("A").get().getMember(0).asMethodDeclaration();
md.addParameter("int", "p1");
assertTransformed("Example_param1", cu);
}
use of com.github.javaparser.ast.body.MethodDeclaration in project javaparser by javaparser.
the class TransformationsTest method exampleParam5.
@Test
public void exampleParam5() throws IOException {
considerExample("Example_param3_original");
MethodDeclaration md = (MethodDeclaration) cu.getClassByName("A").get().getMember(0).asMethodDeclaration();
md.setType(PrimitiveType.intType());
assertTransformed("Example_param5b", cu);
md.getBody().get().getStatements().add(new ReturnStmt(new NameExpr("p1")));
assertTransformed("Example_param5", cu);
}
Aggregations