Search in sources :

Example 1 with ArrayCreationLevel

use of com.github.javaparser.ast.ArrayCreationLevel in project javaparser by javaparser.

the class ArrayCreationLevelTransformationsTest method removingDimension.

@Test
public void removingDimension() throws IOException {
    ArrayCreationLevel it = consider("[10]");
    it.removeDimension();
    assertTransformedToString("[]", it);
}
Also used : ArrayCreationLevel(com.github.javaparser.ast.ArrayCreationLevel) Test(org.junit.Test) AbstractLexicalPreservingTest(com.github.javaparser.printer.lexicalpreservation.AbstractLexicalPreservingTest)

Example 2 with ArrayCreationLevel

use of com.github.javaparser.ast.ArrayCreationLevel in project javaparser by javaparser.

the class ArrayCreationLevelTransformationsTest method replacingAnnotation.

@Test
public void replacingAnnotation() throws IOException {
    ArrayCreationLevel it = consider("@myAnno []");
    it.getAnnotations().set(0, new NormalAnnotationExpr(new Name("myOtherAnno"), new NodeList<>()));
    assertTransformedToString("@myOtherAnno() []", it);
}
Also used : NodeList(com.github.javaparser.ast.NodeList) ArrayCreationLevel(com.github.javaparser.ast.ArrayCreationLevel) NormalAnnotationExpr(com.github.javaparser.ast.expr.NormalAnnotationExpr) Name(com.github.javaparser.ast.expr.Name) Test(org.junit.Test) AbstractLexicalPreservingTest(com.github.javaparser.printer.lexicalpreservation.AbstractLexicalPreservingTest)

Example 3 with ArrayCreationLevel

use of com.github.javaparser.ast.ArrayCreationLevel in project javaparser by javaparser.

the class ArrayCreationLevelTransformationsTest method replacingDimension.

@Test
public void replacingDimension() throws IOException {
    ArrayCreationLevel it = consider("[10]");
    it.setDimension(new IntegerLiteralExpr("12"));
    assertTransformedToString("[12]", it);
}
Also used : IntegerLiteralExpr(com.github.javaparser.ast.expr.IntegerLiteralExpr) ArrayCreationLevel(com.github.javaparser.ast.ArrayCreationLevel) Test(org.junit.Test) AbstractLexicalPreservingTest(com.github.javaparser.printer.lexicalpreservation.AbstractLexicalPreservingTest)

Example 4 with ArrayCreationLevel

use of com.github.javaparser.ast.ArrayCreationLevel in project javaparser by javaparser.

the class ArrayCreationLevelTransformationsTest method addingAnnotation.

// Annotations
@Test
public void addingAnnotation() throws IOException {
    ArrayCreationLevel it = consider("[]");
    it.addAnnotation("myAnno");
    assertTransformedToString("@myAnno()" + Utils.EOL + "[]", it);
}
Also used : ArrayCreationLevel(com.github.javaparser.ast.ArrayCreationLevel) Test(org.junit.Test) AbstractLexicalPreservingTest(com.github.javaparser.printer.lexicalpreservation.AbstractLexicalPreservingTest)

Example 5 with ArrayCreationLevel

use of com.github.javaparser.ast.ArrayCreationLevel in project javaparser by javaparser.

the class ArrayCreationLevelTransformationsTest method removingAnnotation.

@Test
public void removingAnnotation() throws IOException {
    ArrayCreationLevel it = consider("@myAnno []");
    it.getAnnotations().remove(0);
    assertTransformedToString("[]", it);
}
Also used : ArrayCreationLevel(com.github.javaparser.ast.ArrayCreationLevel) Test(org.junit.Test) AbstractLexicalPreservingTest(com.github.javaparser.printer.lexicalpreservation.AbstractLexicalPreservingTest)

Aggregations

ArrayCreationLevel (com.github.javaparser.ast.ArrayCreationLevel)7 AbstractLexicalPreservingTest (com.github.javaparser.printer.lexicalpreservation.AbstractLexicalPreservingTest)6 Test (org.junit.Test)6 IntegerLiteralExpr (com.github.javaparser.ast.expr.IntegerLiteralExpr)2 NodeList (com.github.javaparser.ast.NodeList)1 Name (com.github.javaparser.ast.expr.Name)1 NormalAnnotationExpr (com.github.javaparser.ast.expr.NormalAnnotationExpr)1