View Javadoc
1   /*
2   WhitespaceAfter
3   tokens = LITERAL_DO
4   
5   
6   */
7   
8   package com.puppycrawl.tools.checkstyle.checks.whitespace.whitespaceafter;
9   
10  public class InputWhitespaceAfterLiteralDo {
11  
12      boolean condition() {
13          return false;
14      }
15  
16      void testIfElse() {
17          //Valid
18          if (condition()) {
19              testIfElse();
20          } else {
21              testIfElse();
22          }
23  
24          //Invalid
25          if(condition()) {
26              testIfElse();
27          } else {
28              testIfElse();
29          }
30  
31          //Invalid
32          if (condition()) {
33              testIfElse();
34          } else{
35              testIfElse();
36          }
37      }
38  
39      void testWhile() {
40          //Valid
41          while (condition()) {
42              testWhile();
43          }
44  
45          //Invalid
46          while(condition()) {
47              testWhile();
48          }
49      }
50  
51      void testFor() {
52          //Valid
53          for (int i = 0; i < 5; i++) {
54              testFor();
55          }
56  
57          //Invalid
58          for(int i = 0; i < 5; i++) {
59              testFor();
60          }
61      }
62  
63      void testDo() {
64          //Valid
65          do {
66              testDo();
67          } while (condition());
68  
69          //Invalid
70          do{ // violation ''do' is not followed by whitespace'
71              testDo();
72          } while (condition());
73      }
74  }