View Javadoc
1   /*xml
2   <module name="Checker">
3     <module name="TreeWalker">
4       <module name="RequireThis">
5         <property name="validateOnlyOverlapping" value="false"/>
6       </module>
7     </module>
8   </module>
9   */
10  package com.puppycrawl.tools.checkstyle.checks.coding.requirethis;
11  
12  // xdoc section -- start
13  class Example4 {
14    int field1,field2,field3;
15  
16    Example4(int field1) {
17      this.field1 = field1;
18      field2 = 0; // violation, reference to instance variable "field2" requires "this"
19      foo(5); // violation, method call "foo(5)" requires "this"
20    }
21  
22    void method2(int i) {
23      foo(i); // violation, 'Method call to 'foo' needs "this.".'
24    }
25  
26    void foo(int field3) {
27      // violation below, reference to instance variable "field3" requires "this"
28      field3 = field3;
29    }
30  }
31  // xdoc section -- end