View Javadoc
1   /*
2   CommentsIndentation
3   tokens = (default)SINGLE_LINE_COMMENT, BLOCK_COMMENT_BEGIN
4   
5   
6   */
7   
8   package com.puppycrawl.tools.checkstyle.checks.indentation.commentsindentation;
9   
10  public class InputCommentsIndentationCheckWithEmoji {
11  
12      public void myMethod() {
13          String breaks = "J"
14          // violation '.* incorrect .* level 8, expected is 16, .* same .* as line 15.'
15                  + "🥳"
16                  // it is OK 👍
17                  + "🥳VASd🥳"
18                  + "A" + "🥳"
19                  // it is OK 👍
20                  ;
21      }
22  
23      public void test() {
24          String a = "🥳";
25              // violation '.* incorrect .* level 12, expected is 8, .* same .* as line 24.'
26      }
27          // violation '.* incorrect .* level 8, expected is 4, .* same .* as line 29.'
28  
29      String s = String.format(java.util.Locale.ENGLISH, " 🥳 🥳 🥳asdda   🥳"
30                      + "🎄" + "🎄  🎄🎄       ",
31              " ");
32      // OK 🥳
33  
34      public void test2() {
35          String a = "🥳";
36          switch (a) {
37              // 🥳 comment
38              case "1":
39                  break;
40                  // 🎄 comment 🎄
41              case "2":
42                      // comment  👈🏻
43                  // 👈🏻 comment
44              default: a = "🎄".
45                          toString();
46                  // violation '.* incorrect .* level 16, expected is 24, .* same .* as line 45.'
47          }
48      }
49  
50      private void test3() { // trailing 👉🏻
51          if ("🎄".equals("🎄")) // trailing 👉🏻 comment
52          {
53              // some comment  😁
54          }
55          if ("🎄".equals("🎄sad")) { // trailing comment 🤔
56  
57          }
58          /** 🤔
59           *           🤔
60           */
61      }
62  
63      private void test4() {
64          String a = "🎄";
65          a.toString()
66                  // comment 👇🏻
67                  .toLowerCase()
68                  // comment 👆🏻
69                  .charAt(0);
70              // violation '.* incorrect .* level 12, expected is 8, .* same .* as line 72.'
71  
72          try {
73              assert a.equals("🎄") == true;
74          // violation '.* incorrect .* level 8, expected is 12, .* same .* as line 73.'
75          }
76          catch (Exception ex) {
77  
78          } // ok 👍🏻
79          finally {
80  
81          }
82      }
83  
84      public void test5() {
85              // comment
86              // ... 🧐
87              // block
88              // violation '.* incorrect .* level 12, expected is 8, .* same .* as line 90.'
89          // comment
90          String someStr = "🎄🎄😅";
91      }
92  
93      private void test6() {
94          if (true) {
95              /* some 👌🏻 */
96              String k = "🎄🎄😅";
97              // violation below '.* incorrect .* level 16, expected is 12,.* same .* as line 99.'
98                  /* hello there some comment with emoji 👌 */
99              int b = Integer.parseInt("🎄🎄😅");
100                 /* // violation '.* incorrect .* level 16, expected is 12, .* same .* as line 102.'
101                 * */
102             double d; /* trailing comment */
103                 /* // violation '.* incorrect .* level 16, expected is 12, .* same .* as line 116.'
104              *🎄
105                 */
106 
107             /* my comment*/
108             /*
109              * 🤛🏻
110              *
111              *  some            😧
112              *  😧 /
113             /*
114              * comment 🤩
115              */
116             String x = "😁mkuhyg";
117         }
118     }
119 }
120