|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| BlockParentHandler | Line # 41 | 97.1% |
0.9705882
|
44.05 | 57 | 44 | 44 | 0.77 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ( 10 of 31) | |||
| Result | |||
|
0.84313726
|
com.puppycrawl.tools.checkstyle.checks.indentation.IndentationCheckTest.testInvalidIfWithChecker
com.puppycrawl.tools.checkstyle.checks.indentation.IndentationCheckTest.testInvalidIfWithChecker
|
1 PASS | |
|
0.8137255
|
com.puppycrawl.tools.checkstyle.checks.indentation.IndentationCheckTest.testInvalidSwitchWithChecker
com.puppycrawl.tools.checkstyle.checks.indentation.IndentationCheckTest.testInvalidSwitchWithChecker
|
1 PASS | |
|
0.75490195
|
com.puppycrawl.tools.checkstyle.checks.indentation.IndentationCheckTest.testValidDoWhileWithChecker
com.puppycrawl.tools.checkstyle.checks.indentation.IndentationCheckTest.testValidDoWhileWithChecker
|
1 PASS | |
|
0.75490195
|
com.puppycrawl.tools.checkstyle.checks.indentation.IndentationCheckTest.testInvalidTryWithChecker
com.puppycrawl.tools.checkstyle.checks.indentation.IndentationCheckTest.testInvalidTryWithChecker
|
1 PASS | |
|
0.74509805
|
com.puppycrawl.tools.checkstyle.checks.indentation.IndentationCheckTest.testInvalidClassDefWithChecker
com.puppycrawl.tools.checkstyle.checks.indentation.IndentationCheckTest.testInvalidClassDefWithChecker
|
1 PASS | |
|
0.74509805
|
com.puppycrawl.tools.checkstyle.checks.indentation.IndentationCheckTest.testInvalidMethodWithChecker
com.puppycrawl.tools.checkstyle.checks.indentation.IndentationCheckTest.testInvalidMethodWithChecker
|
1 PASS | |
|
0.7352941
|
com.puppycrawl.tools.checkstyle.checks.indentation.IndentationCheckTest.testInvalidBlockWithChecker
com.puppycrawl.tools.checkstyle.checks.indentation.IndentationCheckTest.testInvalidBlockWithChecker
|
1 PASS | |
|
0.7352941
|
com.puppycrawl.tools.checkstyle.checks.indentation.IndentationCheckTest.testInvalidWhileWithChecker
com.puppycrawl.tools.checkstyle.checks.indentation.IndentationCheckTest.testInvalidWhileWithChecker
|
1 PASS | |
|
0.7352941
|
com.puppycrawl.tools.checkstyle.checks.indentation.IndentationCheckTest.testInvalidForWithChecker
com.puppycrawl.tools.checkstyle.checks.indentation.IndentationCheckTest.testInvalidForWithChecker
|
1 PASS | |
|
0.7254902
|
com.puppycrawl.tools.checkstyle.checks.indentation.IndentationCheckTest.testValidIfWithChecker
com.puppycrawl.tools.checkstyle.checks.indentation.IndentationCheckTest.testValidIfWithChecker
|
1 PASS | |
| 21 tests are not displayed. This report was configured to show the top 10 tests that covered this file. | |||
| 1 | //////////////////////////////////////////////////////////////////////////////// | |
| 2 | // checkstyle: Checks Java source code for adherence to a set of rules. | |
| 3 | // Copyright (C) 2001-2005 Oliver Burn | |
| 4 | // | |
| 5 | // This library is free software; you can redistribute it and/or | |
| 6 | // modify it under the terms of the GNU Lesser General Public | |
| 7 | // License as published by the Free Software Foundation; either | |
| 8 | // version 2.1 of the License, or (at your option) any later version. | |
| 9 | // | |
| 10 | // This library is distributed in the hope that it will be useful, | |
| 11 | // but WITHOUT ANY WARRANTY; without even the implied warranty of | |
| 12 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
| 13 | // Lesser General Public License for more details. | |
| 14 | // | |
| 15 | // You should have received a copy of the GNU Lesser General Public | |
| 16 | // License along with this library; if not, write to the Free Software | |
| 17 | // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | |
| 18 | //////////////////////////////////////////////////////////////////////////////// | |
| 19 | 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 | /** | |
| 25 | * Handler for parents of blocks ('if', 'else', 'while', etc). | |
| 26 | * <P> | |
| 27 | * The "block" handler classes use a common superclass BlockParentHandler, | |
| 28 | * employing the Template Method pattern. | |
| 29 | * <P> | |
| 30 | * <UL> | |
| 31 | * <LI>template method to get the lcurly</LI> | |
| 32 | * <LI>template method to get the rcurly</LI> | |
| 33 | * <LI>if curlys aren't present, then template method to get expressions | |
| 34 | * is called</LI> | |
| 35 | * <LI>now all the repetitous code which checks for BOL, if curlys are on | |
| 36 | * same line, etc. can be collapsed into the superclass</LI> | |
| 37 | * </UL> | |
| 38 | * | |
| 39 | * @author jrichard | |
| 40 | */ | |
| 41 | public class BlockParentHandler extends ExpressionHandler | |
| 42 | { | |
| 43 | /** | |
| 44 | * Children checked by parent handlers. | |
| 45 | */ | |
| 46 | private static final int[] CHECKED_CHILDREN = new int[] { | |
| 47 | TokenTypes.VARIABLE_DEF, | |
| 48 | TokenTypes.EXPR, | |
| 49 | TokenTypes.OBJBLOCK, | |
| 50 | TokenTypes.LITERAL_BREAK, | |
| 51 | TokenTypes.LITERAL_RETURN, | |
| 52 | TokenTypes.LITERAL_THROW, | |
| 53 | TokenTypes.LITERAL_CONTINUE, | |
| 54 | }; | |
| 55 | ||
| 56 | /** | |
| 57 | * Returns array of token types which should be checked among childrens. | |
| 58 | * @return array of token types to check. | |
| 59 | */ | |
| 60 | 445 |
protected int[] getCheckedChildren() |
| 61 | { | |
| 62 | 445 | return CHECKED_CHILDREN; |
| 63 | } | |
| 64 | ||
| 65 | /** | |
| 66 | * Construct an instance of this handler with the given indentation check, | |
| 67 | * name, abstract syntax tree, and parent handler. | |
| 68 | * | |
| 69 | * @param aIndentCheck the indentation check | |
| 70 | * @param aName the name of the handler | |
| 71 | * @param aAst the abstract syntax tree | |
| 72 | * @param aParent the parent handler | |
| 73 | */ | |
| 74 | 1259 |
public BlockParentHandler(IndentationCheck aIndentCheck, |
| 75 | String aName, DetailAST aAst, ExpressionHandler aParent) | |
| 76 | { | |
| 77 | 1259 | super(aIndentCheck, aName, aAst, aParent); |
| 78 | } | |
| 79 | ||
| 80 | /** | |
| 81 | * Get the top level expression being managed by this handler. | |
| 82 | * | |
| 83 | * @return the top level expression | |
| 84 | */ | |
| 85 | 243 |
protected DetailAST getToplevelAST() |
| 86 | { | |
| 87 | 243 | return getMainAst(); |
| 88 | } | |
| 89 | ||
| 90 | /** | |
| 91 | * Check the indent of the top level token. | |
| 92 | */ | |
| 93 | 595 |
protected void checkToplevelToken() |
| 94 | { | |
| 95 | 595 | final DetailAST toplevel = getToplevelAST(); |
| 96 | ||
| 97 | 595 | if ((toplevel == null) |
| 98 | || getLevel().accept(expandedTabsColumnNo(toplevel))) | |
| 99 | { | |
| 100 | 545 | return; |
| 101 | } | |
| 102 | 50 | if (!toplevelMustStartLine() && !startsLine(toplevel)) { |
| 103 | 15 | return; |
| 104 | } | |
| 105 | 35 | logError(toplevel, "", expandedTabsColumnNo(toplevel)); |
| 106 | } | |
| 107 | ||