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 24 29 public abstract class AbstractNestedDepthCheck extends Check 30 { 31 32 private int mMax; 33 34 private int mDepth; 35 36 40 public AbstractNestedDepthCheck(int aMax) 41 { 42 setMax(aMax); 43 } 44 45 46 public final int[] getRequiredTokens() 47 { 48 return getDefaultTokens(); 49 } 50 51 52 public void beginTree(DetailAST aRootAST) 53 { 54 mDepth = 0; 55 } 56 57 61 public final int getMax() 62 { 63 return mMax; 64 } 65 66 70 public final void setMax(int aMax) 71 { 72 mMax = aMax; 73 } 74 75 80 protected final void nestIn(DetailAST aAST, String aMessageId) 81 { 82 if (mDepth > mMax) { 83 log(aAST, aMessageId, new Integer (mDepth), new Integer (mMax)); 84 } 85 ++mDepth; 86 } 87 88 89 protected final void nestOut() 90 { 91 --mDepth; 92 } 93 } 94 | Popular Tags |