Skip to content

Commit 04b5839

Browse files
committed
Handle type annotations on anonymous classes
Fixes google#98 MOE_MIGRATED_REVID=139974613
1 parent 946e01c commit 04b5839

File tree

3 files changed

+19
-0
lines changed

3 files changed

+19
-0
lines changed

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

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -645,6 +645,11 @@ public Void visitNewClass(NewClassTree node, Void unused) {
645645
token("new");
646646
builder.space();
647647
addTypeArguments(node.getTypeArguments(), plusFour);
648+
if (node.getClassBody() != null) {
649+
builder.addAll(
650+
visitModifiers(
651+
node.getClassBody().getModifiers(), Direction.HORIZONTAL, Optional.absent()));
652+
}
648653
scan(node.getIdentifier(), null);
649654
addArguments(node.getArguments(), plusFour);
650655
builder.close();
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
public class AnonInnerDefaults {
2+
3+
public void tryStuff(final UIElement e) {
4+
PolyIface p =
5+
new @UI PolyIface() {
6+
};
7+
}
8+
}
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
public class AnonInnerDefaults {
2+
3+
public void tryStuff(final UIElement e) {
4+
PolyIface p = new @UI PolyIface() {};
5+
}
6+
}

0 commit comments

Comments
 (0)