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 import antlr.collections.AST; 25 26 38 public class StringLiteralEqualityCheck extends Check 39 { 40 41 public int[] getDefaultTokens() 42 { 43 return new int[] {TokenTypes.EQUAL, TokenTypes.NOT_EQUAL}; 44 } 45 46 47 public void visitToken(DetailAST aAST) 48 { 49 final AST firstChild = aAST.getFirstChild(); 51 final AST secondChild = firstChild.getNextSibling(); 52 53 if ((firstChild.getType() == TokenTypes.STRING_LITERAL) 54 || (secondChild.getType() == TokenTypes.STRING_LITERAL)) 55 { 56 log(aAST.getLineNo(), aAST.getColumnNo(), 57 "string.literal.equality", aAST.getText()); 58 } 59 } 60 } 61 | Popular Tags |