View Javadoc
1   /*
2   AnnotationLocation
3   allowSamelineMultipleAnnotations = (default)false
4   allowSamelineSingleParameterlessAnnotation = (default)true
5   allowSamelineParameterizedAnnotation = (default)false
6   tokens = (default)CLASS_DEF, INTERFACE_DEF, PACKAGE_DEF, ENUM_CONSTANT_DEF, \
7            ENUM_DEF, METHOD_DEF, CTOR_DEF, VARIABLE_DEF, RECORD_DEF, COMPACT_CTOR_DEF
8   
9   
10  */
11  
12  package com.puppycrawl.tools.checkstyle.checks.annotation.annotationlocation;
13  
14  // violation below 'Annotation 'MyAnn' should be alone on line.'
15  @MyAnn_21 @com.puppycrawl.tools.checkstyle.checks.annotation.annotationlocation.MyAnn
16  (value = "")
17  class InputAnnotationLocationIncorrectOne
18  {
19  
20      @MyAnn_21 @MyAnnotation1(value = "") // violation '.* should be alone on line.'
21      public int a;
22  
23      @MyAnnotation1(value = "") public int b; // violation '.* should be alone on line.'
24  
25      @MyAnn_21
26          @MyAnnotation1 // violation '.* incorrect .* level 8, .* should be 4.'
27  (value = "")
28      public int c;
29  
30      @MyAnnotation1(value = "")
31      public int d;
32  
33      @MyAnn_21
34          @MyAnnotation1 // violation '.* incorrect .* level 8, .* should be 4.'
35  (value = "")
36      public InputAnnotationLocationIncorrectOne() {}
37  
38      @MyAnnotation1("foo") @MyAnn_21 void foo1() {} // 2 violations
39  
40      @MyAnnotation1(value = "")
41         @MyAnn_21 // violation '.* incorrect .* level 7, .* should be 4.'
42      void foo2() {}
43  
44      @MyAnnotation1(value = "")
45          @MyAnn_21 // violation '.* incorrect .* level 8, .* should be 4.'
46        @MyAnnotation3 // violation '.* incorrect .* level 6, .* should be 4.'
47            @MyAnnotation4 // violation '.* incorrect .* level 10, .* should be 4.'
48      class InnerClass
49      {
50          @MyAnn_21 @MyAnnotation1 // violation 'Annotation 'MyAnnotation1' should be alone on line.'
51  (value = "")
52          public int a;
53  
54          @MyAnnotation1(value = "") public int b; // violation '.* should be alone on line.'
55  
56          @MyAnn_21
57              @MyAnnotation1 // violation '.* incorrect .* level 12, .* should be 8.'
58  (value = "")
59          public int c;
60  
61          @MyAnnotation1(value = "")
62          public int d;
63  
64          @MyAnn_21
65          @MyAnnotation1(value = "") public InnerClass() // violation '.* should be alone on line.'
66          {
67              // comment
68          }
69          @MyAnnotation1(value = "")
70              @MyAnn_21 // violation '.* incorrect .* level 12, .* should be 8.'
71          void foo1() {}
72  
73          @MyAnnotation1(value = "")
74              @MyAnn_21 // violation '.* incorrect .* level 12, .* should be 8.'
75          void foo2() {}
76      }
77  
78      @MyAnnotation1(value = "")
79         @MyAnn_21 // violation '.* incorrect .* level 7, .* should be 4.'
80      InnerClass anon = new InnerClass()
81      {
82          @MyAnn_21 @MyAnnotation1(value = "") public int a; // violation '.*should be alone on line.'
83  
84          @MyAnnotation1(value = "") public int b; // violation '.* should be alone on line.'
85  
86          @MyAnn_21
87          @MyAnnotation1(value = "")
88          public int c;
89  
90          @MyAnnotation1(value = "")
91          public int d;
92  
93          @MyAnnotation1(value = "")
94             @MyAnn_21 void foo1() {} // violation '.* incorrect .* level 11, .* should be 8.'
95  
96          @MyAnnotation1(value = "")
97            @MyAnn_21 // violation '.* incorrect .* level 10, .* should be 8.'
98          void foo2() {}
99          @MyAnnotation1(value = "") void foo42() {} // violation '.* should be alone on line.'
100     };
101 
102 }
103 
104 
105 @interface MyAnnotation1 {
106 
107         String value();}
108 
109 @interface MyAnn_21 {}
110 
111 @interface MyAnnotation3 {}
112 
113 @interface MyAnnotation4 {}
114 
115 @interface MyAnn {
116 
117     String value();}