File tree 5 files changed +143
-0
lines changed
plugin-maven/src/test/java/com/diffplug/spotless/maven/java
testlib/src/main/resources/java/formatannotations
5 files changed +143
-0
lines changed Original file line number Diff line number Diff line change @@ -30,4 +30,14 @@ void testFormatAnnotations() throws Exception {
30
30
mavenRunner ().withArguments ("spotless:apply" ).runNoError ();
31
31
assertFile (path ).sameAsResource ("java/formatannotations/FormatAnnotationsTestOutput.test" );
32
32
}
33
+
34
+ @ Test
35
+ void testFormatAnnotationsAccessModifiers () throws Exception {
36
+ writePomWithJavaSteps ("<formatAnnotations/>" );
37
+
38
+ String path = "src/main/java/test.java" ;
39
+ setFile (path ).toResource ("java/formatannotations/FormatAnnotationsAccessModifiersInput.test" );
40
+ mavenRunner ().withArguments ("spotless:apply" ).runNoError ();
41
+ assertFile (path ).sameAsResource ("java/formatannotations/FormatAnnotationsAccessModifiersOutput.test" );
42
+ }
33
43
}
Original file line number Diff line number Diff line change
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
+ @Deprecated
31
+ @Nullable
32
+ public Object myMethod4a() {
33
+ return null;
34
+ }
35
+
36
+ @Override
37
+ @Nullable
38
+ @Deprecated
39
+ public Object myMethod5() {
40
+ return null;
41
+ }
42
+
43
+ @Nullable @Deprecated public Object myMethod6() {
44
+ return null;
45
+ }
46
+ }
47
+
48
+ @Deprecated
49
+ @Interned
50
+ @MustCall("close")
51
+ @SuppressWarnings
52
+ public class MyClass3 {
53
+ // No body
54
+ }
55
+
56
+ public
57
+ @Deprecated
58
+ @SuppressWarnings
59
+ @Interned
60
+ @MustCall("close")
61
+ class MyClass4 {
62
+ // No body
63
+ }
Original file line number Diff line number Diff line change
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 public Object myMethod2() {
14
+ return null;
15
+ }
16
+
17
+ @Nullable public
18
+ Object myMethod3() {
19
+ return null;
20
+ }
21
+
22
+ @Nullable @Deprecated
23
+ public Object myMethod4() {
24
+ return null;
25
+ }
26
+
27
+ @Deprecated
28
+ @Nullable public Object myMethod4a() {
29
+ return null;
30
+ }
31
+
32
+ @Override
33
+ @Nullable @Deprecated
34
+ public Object myMethod5() {
35
+ return null;
36
+ }
37
+
38
+ @Nullable @Deprecated public Object myMethod6() {
39
+ return null;
40
+ }
41
+ }
42
+
43
+ @Deprecated
44
+ @Interned @MustCall("close") @SuppressWarnings
45
+ public class MyClass3 {
46
+ // No body
47
+ }
48
+
49
+ public
50
+ @Deprecated
51
+ @SuppressWarnings
52
+ @Interned @MustCall("close") class MyClass4 {
53
+ // No body
54
+ }
Original file line number Diff line number Diff line change @@ -75,3 +75,12 @@ class FormatAnnotationsTest {
75
75
@Localized
76
76
String localized;
77
77
}
78
+
79
+ @Deprecated
80
+ @SuppressWarnings
81
+ public
82
+ @Interned
83
+ @MustCall("close")
84
+ class MyClass1 {
85
+ // No body
86
+ }
Original file line number Diff line number Diff line change @@ -49,3 +49,10 @@ class FormatAnnotationsTest {
49
49
50
50
@Localized String localized;
51
51
}
52
+
53
+ @Deprecated
54
+ @SuppressWarnings
55
+ public
56
+ @Interned @MustCall("close") class MyClass1 {
57
+ // No body
58
+ }
You can’t perform that action at this time.
0 commit comments