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 ElseHandler extends BlockParentHandler 30 { 31 39 public ElseHandler(IndentationCheck aIndentCheck, 40 DetailAST aAst, ExpressionHandler aParent) 41 { 42 super(aIndentCheck, "else", aAst, aParent); 43 } 44 45 48 protected void checkToplevelToken() 49 { 50 54 final DetailAST ifAST = getMainAst().getParent(); 55 if (ifAST != null) { 56 final DetailAST slist = ifAST.findFirstToken(TokenTypes.SLIST); 57 if (slist != null) { 58 final DetailAST lcurly = slist.getLastChild(); 59 if ((lcurly != null) 60 && (lcurly.getLineNo() == getMainAst().getLineNo())) 61 { 62 return; 64 } 65 } 66 } 67 super.checkToplevelToken(); 68 } 69 70 75 protected DetailAST getNonlistChild() 76 { 77 return (DetailAST) getMainAst().getFirstChild(); 78 } 79 } 80 | Popular Tags |