View Javadoc
1   package com.puppycrawl.tools.checkstyle.checks.indentation.indentation; //indent:0 exp:0
2   
3   import java.util.Arrays; //indent:0 exp:0
4   
5   /**                                                                           //indent:0 exp:0
6    * This test-input is intended to be checked using following configuration:   //indent:1 exp:1
7    *                                                                            //indent:1 exp:1
8    * arrayInitIndent = 4                                                        //indent:1 exp:1
9    * basicOffset = 4                                                            //indent:1 exp:1
10   * braceAdjustment = 0                                                        //indent:1 exp:1
11   * caseIndent = 4                                                             //indent:1 exp:1
12   * forceStrictCondition = false                                               //indent:1 exp:1
13   * lineWrappingIndentation = 4                                                //indent:1 exp:1
14   * tabWidth = 4                                                               //indent:1 exp:1
15   * throwsIndent = 4                                                           //indent:1 exp:1
16   *                                                                            //indent:1 exp:1
17   * @author  jrichard                                                          //indent:1 exp:1
18   */                                                                           //indent:1 exp:1
19  public class InputIndentationValidMethodIndent extends java.awt.event.MouseAdapter implements java.awt.event.MouseListener { //indent:0 exp:0
20  
21      // ctor with rcurly on same line //indent:4 exp:4
22      public InputIndentationValidMethodIndent() { //indent:4 exp:4
23      } //indent:4 exp:4
24  
25      private InputIndentationValidMethodIndent(boolean test) { //indent:4 exp:4
26          boolean test2 = true; //indent:8 exp:>=8
27  
28          int i = 4 +  //indent:8 exp:8
29              4; //indent:12 exp:>=12
30      } //indent:4 exp:4
31  
32  
33      private InputIndentationValidMethodIndent(boolean test, //indent:4 exp:4
34          boolean test2) { //indent:8 exp:>=8
35          boolean test3 = true; //indent:8 exp:>=8
36  
37          int i = 4 +  //indent:8 exp:8
38              4; //indent:12 exp:>=12
39      } //indent:4 exp:4
40  
41  
42      private InputIndentationValidMethodIndent(boolean test, //indent:4 exp:4
43          boolean test2, boolean test3)  //indent:8 exp:>=8
44      { //indent:4 exp:4
45          boolean test4 = true; //indent:8 exp:8
46  
47          int i = 4 +  //indent:8 exp:8
48              4; //indent:12 exp:>=12
49      } //indent:4 exp:4
50  
51      // ctor with rcurly on next line //indent:4 exp:4
52      public InputIndentationValidMethodIndent(int dummy) //indent:4 exp:4
53      { //indent:4 exp:4
54      } //indent:4 exp:4
55  
56      // method with rcurly on same line //indent:4 exp:4
57      public String method1() { //indent:4 exp:4
58          return "hi"; //indent:8 exp:>=8
59      } //indent:4 exp:4
60  
61      // method with rcurly on next line //indent:4 exp:4
62      public void method2() //indent:4 exp:4
63      { //indent:4 exp:4
64      } //indent:4 exp:4
65  
66      // method with a bunch of params //indent:4 exp:4
67      public int method2(int x, int y, int w, int h) //indent:4 exp:4
68      { //indent:4 exp:4
69          return 1; //indent:8 exp:8
70      } //indent:4 exp:4
71  
72      // params on multiple lines //indent:4 exp:4
73      public void method2(int x, int y, int w, int h, //indent:4 exp:4
74          int x1, int y1, int w1, int h1) //indent:8 exp:>=8
75      { //indent:4 exp:4
76      } //indent:4 exp:4
77  
78      // params on multiple lines //indent:4 exp:4
79      public void method3(int x, int y, int w, int h, //indent:4 exp:4
80          int x1, int y1, int w1, int h1) //indent:8 exp:>=8
81      { //indent:4 exp:4
82          System.getProperty("foo"); //indent:8 exp:8
83      } //indent:4 exp:4
84  
85      // params on multiple lines //indent:4 exp:4
86      public void method4(int x, int y, int w, int h, //indent:4 exp:4
87          int x1, int y1, int w1, int h1) //indent:8 exp:8
88      { //indent:4 exp:4
89          boolean test = true; //indent:8 exp:8
90  
91          int i = 4 +  //indent:8 exp:8
92              4; //indent:12 exp:>=12
93  
94          i += 5; //indent:8 exp:8
95          i += 5  //indent:8 exp:8
96              + 4; //indent:12 exp:>=12
97          if (test)  //indent:8 exp:8
98          { //indent:8 exp:8
99              System.getProperty("foo"); //indent:12 exp:12
100         } else { //indent:8 exp:8
101             System.getProperty("foo"); //indent:12 exp:12
102         } //indent:8 exp:8
103 
104         for (int j=0;j<10; j++) { //indent:8 exp:8
105             System.getProperty("foo"); //indent:12 exp:12
106         } //indent:8 exp:8
107 
108 
109         myfunc2(10, 10, 10, //indent:8 exp:8
110             myfunc3(11, 11, //indent:12 exp:>=12
111                 11, 11), //indent:16 exp:>=16
112             10, 10, //indent:12 exp:>=12
113             10); //indent:12 exp:>=12
114 
115 
116         myfunc3(11, 11, Integer. //indent:8 exp:8
117                 getInteger("mytest").intValue(), //indent:16 exp:>=12
118             11); //indent:12 exp:>=12
119 
120         myfunc3( //indent:8 exp:8
121             1, //indent:12 exp:>=12
122             2,  //indent:12 exp:>=12
123                 3,  //indent:16 exp:>=12
124                 4); //indent:16 exp:>=12
125     } //indent:4 exp:4
126 
127     // strange IMHO, but I suppose this should be allowed //indent:4 exp:4
128     public //indent:4 exp:4
129     void //indent:4 exp:8 warn
130     method5() { //indent:4 exp:8 warn
131     } //indent:4 exp:4
132 
133 
134     private void myfunc2(int a, int b, int c, int d, int e, int f, int g) { //indent:4 exp:4
135     } //indent:4 exp:4
136 
137     private int myfunc3(int a, int b, int c, int d) { //indent:4 exp:4
138         return 1; //indent:8 exp:8
139     } //indent:4 exp:4
140 
141 
142     void method6() { //indent:4 exp:4
143         System.identityHashCode("methods are: " + Arrays.asList( //indent:8 exp:8
144             new String[] {"method"}).toString()); //indent:12 exp:>=12
145 
146         System.identityHashCode("methods are: " + Arrays.asList( //indent:8 exp:8
147             new String[] {"method"} //indent:12 exp:>=12
148         ).toString()); //indent:8 exp:8
149 
150         System.identityHashCode("methods are: " + Arrays.asList( //indent:8 exp:8
151             new String[] {"method"}).toString() //indent:12 exp:>=12
152         ); //indent:8 exp:8
153 
154 
155         myfunc2(3, 4, 5,  //indent:8 exp:8
156             6, 7, 8, 9); //indent:12 exp:>=12
157 
158         myfunc2(3, 4, method2(3, 4, 5, 6) + 5,  //indent:8 exp:8
159             6, 7, 8, 9); //indent:12 exp:>=12
160 
161         System.identityHashCode("methods are: " +  //indent:8 exp:8
162             Arrays.asList( //indent:12 exp:>=12
163                 new String[] {"method"}).toString()); //indent:16 exp:>=16
164 
165         System.identityHashCode("methods are: "  //indent:8 exp:8
166             + Arrays.asList( //indent:12 exp:>=12
167                 new String[] {"method"}).toString()); //indent:16 exp:>=16
168 
169 
170         String blah = (String) System.getProperty( //indent:8 exp:8
171             new String("type")); //indent:12 exp:>=12
172 
173         System.identityHashCode(method1() + "mytext"  //indent:8 exp:8
174             + " at indentation level not at correct indentation, "  //indent:12 exp:>=12
175             + method1()); //indent:12 exp:>=12
176 
177         System.identityHashCode( //indent:8 exp:8
178             method1() + "mytext"  //indent:12 exp:>=12
179                 + " at indentation level not at correct indentation, "  //indent:16 exp:>=12
180                 + method1()); //indent:16 exp:>=12
181 
182         String.CASE_INSENSITIVE_ORDER.toString() //indent:8 exp:8
183             .equals("blah"); //indent:12 exp:>=12
184 
185 
186 
187     } //indent:4 exp:4
188 
189     private int[] getArray() { //indent:4 exp:4
190         return new int[] {1}; //indent:8 exp:8
191     } //indent:4 exp:4
192 
193     private void indexTest() { //indent:4 exp:4
194         getArray()[0] = 2; //indent:8 exp:8
195     } //indent:4 exp:4
196 
197     // the following lines have tabs //indent:4 exp:4
198 	@SuppressWarnings( //indent:4 exp:4
199 		value="" //indent:8 exp:8
200 	) //indent:4 exp:4
201 	public void testStartOfSequence() { //indent:4 exp:4
202 	} //indent:4 exp:4
203 } //indent:0 exp:0