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 ObjectBlockHandler extends BlockParentHandler 30 { 31 39 public ObjectBlockHandler(IndentationCheck aIndentCheck, 40 DetailAST aAst, ExpressionHandler aParent) 41 { 42 super(aIndentCheck, "object def", aAst, aParent); 43 } 44 45 50 protected DetailAST getToplevelAST() 51 { 52 return null; 53 } 54 55 60 protected DetailAST getLCurly() 61 { 62 return getMainAst().findFirstToken(TokenTypes.LCURLY); 63 } 64 65 70 protected DetailAST getRCurly() 71 { 72 return getMainAst().findFirstToken(TokenTypes.RCURLY); 73 } 74 75 80 protected DetailAST getListChild() 81 { 82 return getMainAst(); 83 } 84 85 90 protected IndentLevel getLevelImpl() 91 { 92 final DetailAST parentAST = getMainAst().getParent(); 93 IndentLevel indent = getParent().getLevel(); 94 if (parentAST.getType() == TokenTypes.LITERAL_NEW) { 95 indent.addAcceptedIndent(super.getLevelImpl()); 96 } 97 else if (parentAST.getType() == TokenTypes.ENUM_CONSTANT_DEF) { 98 indent = super.getLevelImpl(); 99 } 100 return indent; 101 } 102 103 106 public void checkIndentation() 107 { 108 final DetailAST parentAST = getMainAst().getParent(); 113 if (parentAST.getType() != TokenTypes.LITERAL_NEW) { 114 return; 115 } 116 117 super.checkIndentation(); 118 } 119 } 120 | Popular Tags |