Skip to content

Commit 26f8f59

Browse files
committed
Add test cases for type annotations on classes
1 parent 0b186ab commit 26f8f59

File tree

4 files changed

+130
-0
lines changed

4 files changed

+130
-0
lines changed
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
// Annotations in the wrong order. The preferred order is:
2+
// * declaration annotations
3+
// * access modifiers such as `public`
4+
// * type annotations
5+
// * type
6+
7+
class FormatAnnotationsAccessModifiers {
8+
9+
@Nullable public Object myMethod1() {
10+
return null;
11+
}
12+
13+
@Nullable
14+
public Object myMethod2() {
15+
return null;
16+
}
17+
18+
@Nullable
19+
public
20+
Object myMethod3() {
21+
return null;
22+
}
23+
24+
@Nullable
25+
@Deprecated
26+
public Object myMethod4() {
27+
return null;
28+
}
29+
30+
@Override
31+
@Nullable
32+
@Deprecated
33+
public Object myMethod5() {
34+
return null;
35+
}
36+
37+
@Nullable @Deprecated public Object myMethod6() {
38+
return null;
39+
}
40+
}
41+
42+
@Deprecated
43+
@Interned
44+
@MustCall("close")
45+
@SuppressWarnings
46+
public class MyClass3 {
47+
// No body
48+
}
49+
50+
public
51+
@Deprecated
52+
@SuppressWarnings
53+
@Interned
54+
@MustCall("close")
55+
class MyClass4 {
56+
// No body
57+
}
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
// Annotations in the wrong order. The preferred order is:
2+
// * declaration annotations
3+
// * access modifiers such as `public`
4+
// * type annotations
5+
// * type
6+
7+
class FormatAnnotationsAccessModifiers {
8+
9+
@Nullable public Object myMethod1() {
10+
return null;
11+
}
12+
13+
@Nullable
14+
public Object myMethod2() {
15+
return null;
16+
}
17+
18+
@Nullable
19+
public
20+
Object myMethod3() {
21+
return null;
22+
}
23+
24+
@Nullable
25+
@Deprecated
26+
public Object myMethod4() {
27+
return null;
28+
}
29+
30+
@Override
31+
@Nullable
32+
@Deprecated
33+
public Object myMethod5() {
34+
return null;
35+
}
36+
37+
@Nullable @Deprecated public Object myMethod6() {
38+
return null;
39+
}
40+
}
41+
42+
@Deprecated
43+
@Interned
44+
@MustCall("close")
45+
@SuppressWarnings
46+
public class MyClass3 {
47+
// No body
48+
}
49+
50+
public
51+
@Deprecated
52+
@SuppressWarnings
53+
@Interned
54+
@MustCall("close")
55+
class MyClass4 {
56+
// No body
57+
}

testlib/src/main/resources/java/formatannotations/FormatAnnotationsTestInput.test

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,3 +75,12 @@ class FormatAnnotationsTest {
7575
@Localized
7676
String localized;
7777
}
78+
79+
@Deprecated
80+
@SuppressWarnings
81+
public
82+
@Interned
83+
@MustCall("close")
84+
class MyClass1 {
85+
// No body
86+
}

testlib/src/main/resources/java/formatannotations/FormatAnnotationsTestOutput.test

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,3 +49,10 @@ class FormatAnnotationsTest {
4949

5050
@Localized String localized;
5151
}
52+
53+
@Deprecated
54+
@SuppressWarnings
55+
public
56+
@Interned @MustCall("close") class MyClass1 {
57+
// No body
58+
}

0 commit comments

Comments
 (0)