View Javadoc
1   /*
2   CommentsIndentation
3   tokens = (default)SINGLE_LINE_COMMENT, BLOCK_COMMENT_BEGIN
4   
5   
6   */
7   package com.puppycrawl.tools.checkstyle.checks.indentation.commentsindentation;
8   
9   
10  
11  
12  
13  /**
14   * Contains examples of using comments at the end of the block.
15   */
16  public class InputCommentsIndentationCommentIsAtTheEndOfBlockSix {
17  
18      void foo71() {
19          switch("") {
20              case "!":
21                  break;
22              default:
23                  break;
24          }
25  
26            //violation '.* incorrect .* level 10, expected is 8, .* same .* as line 19.'
27      }
28  
29      void foo72() {
30          int u = 1;
31  
32          /* comment */
33  // violation '.* incorrect .* level 0, expected is 8, .* same .* as line 30.'
34      }
35      void foo73() {
36          class Foo { }
37  
38          /* comment */
39  // violation '.* incorrect .* level 0, expected is 8, .* same .* as line 36.'
40      }
41  
42      interface Bar1 {
43          interface NestedBar { }
44  
45  // violation '.* incorrect .* level 0, expected is 8, .* same .* as line 43.'
46      }
47      static class Bar2 {
48          enum Foo {
49              A;
50          }
51  
52      //violation '.* incorrect .* level 4, expected is 8, .* same .* as line 48.'
53      }
54      static class Bar3 {
55          @interface Foo { }
56              // violation '.* incorrect .* level 12, expected is 8, .* same .* as line 55.'
57      }
58  
59      void foo74() {
60          getClass(); // comment
61  // comment
62  // violation '.* incorrect .* level 0, expected is 8, .* same .* as line 60.'
63      }
64  
65      void foo75() {
66          getClass();
67  // violation '.* incorrect .* level 0, expected is 8, .* same .* as line 66.'
68          // comment
69      }
70  
71      void InputCommentsIndentationCommentIsAtTheEndOfBlock(String s) {
72          assert(s == null ||
73                  s != null);
74          // comment
75          //comment
76      }
77  
78      int foo76() {
79          return 0;
80          /* test
81           * test */
82  //         violation '.* incorrect .* level 0, expected is 8, .* same .* as line 79.'
83      }
84  
85      void foo77() {
86          try {
87              /* CHECKSTYLE:OFF */} catch(Exception e) {
88          }
89      }
90      void foo78() {
91          /* violation */
92          new Object()
93                  .toString();
94              //violation '.* incorrect .* level 12, expected is 8, .* same .* as line 92.'
95      }
96      void foo79() {
97          /* violation */
98          /* violation */new Object().toString();
99  
100     }
101 
102     // We almost reached the end of the class here.
103 }