1 package com.puppycrawl.tools.checkstyle.checks.naming; 20 21 import com.puppycrawl.tools.checkstyle.api.DetailAST; 22 import com.puppycrawl.tools.checkstyle.api.FullIdent; 23 import com.puppycrawl.tools.checkstyle.api.TokenTypes; 24 import com.puppycrawl.tools.checkstyle.checks.AbstractFormatCheck; 25 26 63 public class PackageNameCheck 64 extends AbstractFormatCheck 65 { 66 69 public PackageNameCheck() 70 { 71 super("^[a-z]+(\\.[a-zA-Z_][a-zA-Z0-9_]*)*$"); 75 } 76 77 78 public int[] getDefaultTokens() 79 { 80 return new int[] {TokenTypes.PACKAGE_DEF}; 81 } 82 83 84 public void visitToken(DetailAST aAST) 85 { 86 final DetailAST nameAST = aAST.getLastChild().getPreviousSibling(); 87 final FullIdent full = FullIdent.createFullIdent(nameAST); 88 if (!getRegexp().matcher(full.getText()).find()) { 89 log(full.getLineNo(), 90 full.getColumnNo(), 91 "name.invalidPattern", 92 full.getText(), 93 getFormat()); 94 } 95 } 96 } 97 | Popular Tags |