Skip to content

Commit ca17cb5

Browse files
committed
Handle type annotations on array creation expressions with initializers
Fixes google#100 MOE_MIGRATED_REVID=140082878
1 parent 9fbc6e2 commit ca17cb5

File tree

3 files changed

+15
-0
lines changed

3 files changed

+15
-0
lines changed

core/src/main/java/com/google/googlejavaformat/java/JavaInputAstVisitor.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -426,6 +426,7 @@ public Void visitNewArray(NewArrayTree node, Void unused) {
426426
Deque<ExpressionTree> dimExpressions = new ArrayDeque<>(node.getDimensions());
427427

428428
Deque<List<AnnotationTree>> annotations = new ArrayDeque<>();
429+
annotations.add(ImmutableList.copyOf(node.getAnnotations()));
429430
annotations.addAll((List<List<AnnotationTree>>) node.getDimAnnotations());
430431
annotations.addAll(extractedDims.dims);
431432

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
public class I100 {
2+
void f() {
3+
Object o;
4+
o = new String @A [] {"foo", "bar"};
5+
o = new String @A @B [] @C [] {"foo", "bar"};
6+
}
7+
}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
public class I100 {
2+
void f() {
3+
Object o;
4+
o = new String @A [] {"foo", "bar"};
5+
o = new String @A @B [] @C [] {"foo", "bar"};
6+
}
7+
}

0 commit comments

Comments
 (0)