1 20 package com.puppycrawl.tools.checkstyle.checks.naming; 21 22 import com.puppycrawl.tools.checkstyle.api.DetailAST; 23 import com.puppycrawl.tools.checkstyle.api.TokenTypes; 24 import com.puppycrawl.tools.checkstyle.checks.AbstractFormatCheck; 25 26 32 public abstract class AbstractNameCheck 33 extends AbstractFormatCheck 34 { 35 39 public AbstractNameCheck(String aFormat) 40 { 41 super(aFormat); 42 } 43 44 51 protected boolean mustCheckName(DetailAST aAST) 52 { 53 return true; 54 } 55 56 57 public void visitToken(DetailAST aAST) 58 { 59 if (mustCheckName(aAST)) { 60 final DetailAST nameAST = aAST.findFirstToken(TokenTypes.IDENT); 61 if (!getRegexp().matcher(nameAST.getText()).find()) { 62 log(nameAST.getLineNo(), 63 nameAST.getColumnNo(), 64 "name.invalidPattern", 65 nameAST.getText(), 66 getFormat()); 67 } 68 } 69 } 70 } 71 | Popular Tags |