1 package com.puppycrawl.tools.checkstyle.checks.coding; 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 final class PackageDeclarationCheck extends Check 33 { 34 35 private boolean mDefined; 36 37 38 public int[] getDefaultTokens() 39 { 40 return new int[] {TokenTypes.PACKAGE_DEF}; 41 } 42 43 44 public int[] getRequiredTokens() 45 { 46 return getDefaultTokens(); 47 } 48 49 50 public void beginTree(DetailAST aAST) 51 { 52 mDefined = false; 53 } 54 55 56 public void finishTree(DetailAST aAST) 57 { 58 if (!mDefined) { 59 log(aAST.getLineNo(), "missing.package.declaration"); 60 } 61 } 62 63 64 public void visitToken(DetailAST aAST) 65 { 66 mDefined = true; 67 } 68 } 69 | Popular Tags |