Search in sources :

Example 6 with ArrayType

use of com.github.javaparser.ast.type.ArrayType in project javaparser by javaparser.

the class MethodDeclarationTransformationsTest method replacingOnlyParameter.

@Test
public void replacingOnlyParameter() throws IOException {
    MethodDeclaration it = consider("public void foo(float f){}");
    it.getParameters().set(0, new Parameter(new ArrayType(PrimitiveType.intType()), new SimpleName("foo")));
    assertTransformedToString("public void foo(int[] foo){}", it);
}
Also used : ArrayType(com.github.javaparser.ast.type.ArrayType) MethodDeclaration(com.github.javaparser.ast.body.MethodDeclaration) SimpleName(com.github.javaparser.ast.expr.SimpleName) Parameter(com.github.javaparser.ast.body.Parameter) Test(org.junit.Test) AbstractLexicalPreservingTest(com.github.javaparser.printer.lexicalpreservation.AbstractLexicalPreservingTest)

Aggregations

ArrayType (com.github.javaparser.ast.type.ArrayType)6 Test (org.junit.Test)6 MethodDeclaration (com.github.javaparser.ast.body.MethodDeclaration)2 Parameter (com.github.javaparser.ast.body.Parameter)2 SimpleName (com.github.javaparser.ast.expr.SimpleName)2 AbstractLexicalPreservingTest (com.github.javaparser.printer.lexicalpreservation.AbstractLexicalPreservingTest)2 ConstructorDeclaration (com.github.javaparser.ast.body.ConstructorDeclaration)1 FieldDeclaration (com.github.javaparser.ast.body.FieldDeclaration)1 VariableDeclarator (com.github.javaparser.ast.body.VariableDeclarator)1 CsmToken (com.github.javaparser.printer.concretesyntaxmodel.CsmToken)1 CsmChild (com.github.javaparser.printer.lexicalpreservation.LexicalDifferenceCalculator.CsmChild)1