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 NewHandler extends ExpressionHandler 30 { 31 39 public NewHandler(IndentationCheck aIndentCheck, 40 DetailAST aAST, 41 ExpressionHandler aParent) 42 { 43 super(aIndentCheck, "operator new", aAST, aParent); 44 } 45 46 47 public void checkIndentation() 48 { 49 final DetailAST type = (DetailAST) getMainAst().getFirstChild(); 50 checkExpressionSubtree(type, getLevel(), false, false); 51 52 final DetailAST lparen = getMainAst().findFirstToken(TokenTypes.LPAREN); 53 final DetailAST rparen = getMainAst().findFirstToken(TokenTypes.RPAREN); 54 checkLParen(lparen); 55 56 if ((rparen == null) || (lparen == null) 57 || (rparen.getLineNo() == lparen.getLineNo())) 58 { 59 return; 60 } 61 62 72 checkExpressionSubtree( 73 getMainAst().findFirstToken(TokenTypes.ELIST), 74 new IndentLevel(getLevel(), getBasicOffset()), 75 false, true); 76 77 checkRParen(lparen, rparen); 78 } 79 80 81 protected IndentLevel getLevelImpl() 82 { 83 if (getLineStart(getMainAst()) != getMainAst().getColumnNo()) { 86 return new IndentLevel(getLineStart(getMainAst())); 87 } 88 return super.getLevelImpl(); 89 } 90 91 92 protected boolean shouldIncreaseIndent() 93 { 94 return false; 95 } 96 } 97 | Popular Tags |