1 package com.puppycrawl.tools.checkstyle.checks.j2ee; 20 21 import com.puppycrawl.tools.checkstyle.api.Check; 22 import com.puppycrawl.tools.checkstyle.api.DetailAST; 23 import com.puppycrawl.tools.checkstyle.api.TokenTypes; 24 25 32 public class ThisReturnCheck 33 extends Check 34 { 35 38 public int[] getDefaultTokens() 39 { 40 return new int[] {TokenTypes.LITERAL_THIS}; 41 } 42 43 46 public int[] getRequiredTokens() 47 { 48 return getDefaultTokens(); 49 } 50 51 54 public void visitToken(DetailAST aAST) 55 { 56 if (Utils.isInEJB(aAST)) { 57 DetailAST parent = aAST.getParent(); 58 59 while ((parent != null) 61 && (parent.getType() == TokenTypes.LPAREN)) 62 { 63 parent = parent.getParent(); 64 } 65 66 if ((parent != null) 67 && (parent.getType() == TokenTypes.EXPR)) 68 { 69 parent = parent.getParent(); 70 if ((parent != null) 71 && (parent.getType() == TokenTypes.LITERAL_RETURN)) 72 { 73 log( 74 aAST.getLineNo(), 75 aAST.getColumnNo(), 76 "thisreturn.bean"); 77 } 78 } 79 } 80 } 81 } 82 | Popular Tags |