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 AssignHandler extends BlockParentHandler 30 { 31 39 public AssignHandler(IndentationCheck aIndentCheck, 40 DetailAST aAst, ExpressionHandler aParent) 41 { 42 super(aIndentCheck, "assign", aAst, aParent); 43 } 44 45 48 public void checkIndentation() 49 { 50 final IndentLevel expectedLevel = getChildrenExpectedLevel(); 51 52 final DetailAST assign = getMainAst(); 54 if (startsLine(assign) 55 && !expectedLevel.accept(expandedTabsColumnNo(assign))) 56 { 57 logError(assign, "" , expandedTabsColumnNo(assign), expectedLevel); 58 } 59 60 DetailAST child = (DetailAST) assign.getFirstChild(); 62 63 final DetailAST parent = assign.getParent(); 66 if ((parent != null) && (parent.getType() == TokenTypes.EXPR)) { 67 child = (DetailAST) child.getNextSibling(); 68 } 69 if ((parent != null) 70 && (parent.getType() == TokenTypes.ANNOTATION_MEMBER_VALUE_PAIR)) 71 { 72 child = (DetailAST) assign.getNextSibling(); 73 } 74 75 checkExpressionSubtree(child, expectedLevel, false, true); 76 } 77 78 83 protected boolean shouldIncreaseIndent() 84 { 85 return false; 86 } 87 88 89 public IndentLevel suggestedChildLevel(ExpressionHandler aChild) 90 { 91 final DetailAST assign = getMainAst(); 92 final DetailAST child = aChild.getMainAst(); 93 94 if (child == assign.getFirstChild()) { 95 return getLevel(); 98 } 99 if (startsLine(assign)) { 100 return new IndentLevel(expandedTabsColumnNo(assign)); 101 } 102 return super.suggestedChildLevel(aChild); 103 } 104 } 105 | Popular Tags |