1 package com.puppycrawl.tools.checkstyle.checks.indentation; 20 21 import com.puppycrawl.tools.checkstyle.api.DetailAST; 22 import com.puppycrawl.tools.checkstyle.api.TokenTypes; 23 24 29 public class SwitchHandler extends BlockParentHandler 30 { 31 39 public SwitchHandler(IndentationCheck aIndentCheck, 40 DetailAST aAst, ExpressionHandler aParent) 41 { 42 super(aIndentCheck, "switch", aAst, aParent); 43 } 44 45 50 protected DetailAST getLCurly() 51 { 52 return getMainAst().findFirstToken(TokenTypes.LCURLY); 53 } 54 55 60 protected DetailAST getRCurly() 61 { 62 return getMainAst().findFirstToken(TokenTypes.RCURLY); 63 } 64 65 70 protected DetailAST getListChild() 71 { 72 return null; 77 } 78 79 84 protected DetailAST getNonlistChild() 85 { 86 return null; 87 } 88 89 92 private void checkSwitchExpr() 93 { 94 checkExpressionSubtree( 95 (DetailAST) getMainAst().findFirstToken(TokenTypes.LPAREN). 96 getNextSibling(), 97 getLevel(), 98 false, 99 false); 100 } 101 102 105 public void checkIndentation() 106 { 107 checkSwitchExpr(); 108 super.checkIndentation(); 109 } 110 } 111 | Popular Tags |