1 package com.puppycrawl.tools.checkstyle.checks.coding; 20 21 import com.puppycrawl.tools.checkstyle.api.DetailAST; 22 import com.puppycrawl.tools.checkstyle.api.TokenTypes; 23 24 import com.puppycrawl.tools.checkstyle.checks.DescendantTokenCheck; 25 26 40 public class MissingCtorCheck extends DescendantTokenCheck 41 { 42 43 public MissingCtorCheck() 44 { 45 setLimitedTokens(new String [] { 46 TokenTypes.getTokenName(TokenTypes.CTOR_DEF), 47 }); 48 setMinimumNumber(1); 49 setMaximumDepth(2); 50 setMinimumMessage("missing.ctor"); 51 } 52 53 54 public int[] getDefaultTokens() 55 { 56 return new int[]{TokenTypes.CLASS_DEF}; 57 } 58 59 60 public int[] getAcceptableTokens() 61 { 62 return getDefaultTokens(); 63 } 64 65 66 public void visitToken(DetailAST aAST) 67 { 68 final DetailAST modifiers = aAST.findFirstToken(TokenTypes.MODIFIERS); 69 if ((modifiers != null) 70 && modifiers.branchContains(TokenTypes.ABSTRACT)) 71 { 72 return; 74 } 75 76 super.visitToken(aAST); 77 } 78 } 79 | Popular Tags |