diff options
author | rnveach <rveach02@gmail.com> | 2016-04-28 08:37:12 -0400 |
---|---|---|
committer | Roman Ivanov <romani@users.noreply.github.com> | 2016-04-28 05:37:12 -0700 |
commit | e2ad52ad596f594968bb08098777551c2bccf8bb (patch) | |
tree | adc184d2944d5c74ea5362b2d8c6fea2d3365d4d /src/main | |
parent | 4c26dcafb2534901dacaccbcdfbf81dae100d2d4 (diff) | |
download | checkstyle-e2ad52ad596f594968bb08098777551c2bccf8bb.tar.gz |
Issue #3136: added indentation check of while in do..while (#3139)
Diffstat (limited to 'src/main')
-rw-r--r-- | src/main/java/com/puppycrawl/tools/checkstyle/checks/indentation/DoWhileHandler.java | 21 |
1 files changed, 16 insertions, 5 deletions
diff --git a/src/main/java/com/puppycrawl/tools/checkstyle/checks/indentation/DoWhileHandler.java b/src/main/java/com/puppycrawl/tools/checkstyle/checks/indentation/DoWhileHandler.java index b26088d36..b2523cf41 100644 --- a/src/main/java/com/puppycrawl/tools/checkstyle/checks/indentation/DoWhileHandler.java +++ b/src/main/java/com/puppycrawl/tools/checkstyle/checks/indentation/DoWhileHandler.java @@ -42,17 +42,28 @@ public class DoWhileHandler extends BlockParentHandler { } /** - * Check the indentation level of the conditional expression. + * Check the indentation level of the while and conditional expression. */ - private void checkCondExpr() { - final DetailAST condAst = getMainAst() - .findFirstToken(TokenTypes.LPAREN).getNextSibling(); + private void checkWhileExpr() { + // check while statement alone + + final DetailAST whileAst = getMainAst().findFirstToken(TokenTypes.DO_WHILE); + + if (isOnStartOfLine(whileAst) + && !getIndent().isAcceptable(expandedTabsColumnNo(whileAst))) { + logError(whileAst, "while", expandedTabsColumnNo(whileAst)); + } + + // check condition alone + + final DetailAST condAst = getMainAst().findFirstToken(TokenTypes.LPAREN).getNextSibling(); + checkExpressionSubtree(condAst, getIndent(), false, false); } @Override public void checkIndentation() { super.checkIndentation(); - checkCondExpr(); + checkWhileExpr(); } } |