1 package com.puppycrawl.tools.checkstyle.checks.coding; 20 21 import com.puppycrawl.tools.checkstyle.api.Check; 22 import com.puppycrawl.tools.checkstyle.api.TokenTypes; 23 import com.puppycrawl.tools.checkstyle.api.DetailAST; 24 25 42 public class SimplifyBooleanExpressionCheck 43 extends Check 44 { 45 46 public int[] getDefaultTokens() 47 { 48 return new int[] {TokenTypes.LITERAL_TRUE, TokenTypes.LITERAL_FALSE}; 49 } 50 51 56 public int[] getAcceptableTokens() 57 { 58 return new int[] {}; 59 } 60 61 62 public int[] getRequiredTokens() 63 { 64 return new int[] {TokenTypes.LITERAL_TRUE, TokenTypes.LITERAL_FALSE}; 65 } 66 67 68 public void visitToken(DetailAST aAST) 69 { 70 final DetailAST parent = aAST.getParent(); 71 switch (parent.getType()) { 72 case TokenTypes.NOT_EQUAL: 73 case TokenTypes.EQUAL: 74 case TokenTypes.LNOT: 75 case TokenTypes.LOR: 76 case TokenTypes.LAND: 77 log(parent.getLineNo(), parent.getColumnNo(), 78 "simplify.expression"); 79 break; 80 default: 81 break; 82 } 83 } 84 } 85 | Popular Tags |