View Javadoc
1   /*
2   LeftCurly
3   option = eol
4   ignoreEnums = (default)true
5   tokens = (default)ANNOTATION_DEF, CLASS_DEF, CTOR_DEF, ENUM_CONSTANT_DEF, \
6            ENUM_DEF, INTERFACE_DEF, LAMBDA, LITERAL_CASE, LITERAL_CATCH, \
7            LITERAL_DEFAULT, LITERAL_DO, LITERAL_ELSE, LITERAL_FINALLY, LITERAL_FOR, \
8            LITERAL_IF, LITERAL_SWITCH, LITERAL_SYNCHRONIZED, LITERAL_TRY, LITERAL_WHILE, \
9            METHOD_DEF, OBJBLOCK, STATIC_INIT, RECORD_DEF, COMPACT_CTOR_DEF
10  
11  
12  */
13  
14  package com.puppycrawl.tools.checkstyle.checks.blocks.leftcurly;
15  
16  import org.junit.jupiter.api.function.ThrowingConsumer;
17  
18  import java.net.InetSocketAddress;
19  import java.net.Socket;
20  import java.util.*;
21  import java.util.List;
22  
23  public class InputLeftCurlyCommentBeforeLeftCurly2 {
24  
25      private long[] countList;
26  
27      void method1() /* comment
28      comment */ { // ok until #11410
29      }
30  
31      void method2() /********
32      comment */ {
33          if (!Arrays.equals(this.countList, countList)
34              /* || !Arrays.equals(this.whereCreated, other.whereCreated) */ ) {
35          }
36      }
37  
38      void method3() /*****
39      ********/ { } // ok until #11410
40  
41  
42      InputLeftCurlyCommentBeforeLeftCurly2() /**************/ { }
43  
44      InputLeftCurlyCommentBeforeLeftCurly2(int data) /*
45       ****** comment *********/ { } // ok until #11410
46  }
47  
48  class Class {
49      private
50      class Node /************/{
51          int data;
52          Node next;
53          Node(int data) /* comment */
54          { // violation ''{' at column 9 should be on the previous line'
55              this.data = data;
56          }
57      }
58  
59      String s = "🧐  🧐";
60      private void foo3(String s) {
61          /*🧐 🧐 🧐*/  /* comment */ if ("🧐".isEmpty()) {
62          }
63      }
64  
65      List<ThrowingConsumer<InetSocketAddress>> targets = List.of(
66              /* 0 */  (a) -> {Socket s = new Socket();},
67              // violation above ''{' at column 29 should have line break after'
68              /* 0 */  (b) -> {
69                  Socket s = new Socket();
70              }
71      );
72  }
73  
74  class Nothing {
75      void method() {
76          int a = 9;int b = 9;
77          if(a == 0 && b == 0
78           /* || a==3 */) {}
79      }
80  
81      public void test2(String
82                        /* CHECKSTYLE */ ...para) {
83      }
84  
85      public void test3(String line) {
86  
87          int index=0;
88          if (line.regionMatches(index, "/**", 0, "/**".length())) {
89              index += 2;
90          }
91          else if (line.regionMatches(index, "*/", 0, 2)) {
92              index++;
93          }
94      }
95  }