Class BlockParentHandler
- java.lang.Object
- 
- com.puppycrawl.tools.checkstyle.checks.indentation.AbstractExpressionHandler
- 
- com.puppycrawl.tools.checkstyle.checks.indentation.BlockParentHandler
 
 
- 
- Direct Known Subclasses:
- ArrayInitHandler,- CatchHandler,- ClassDefHandler,- DoWhileHandler,- ElseHandler,- FinallyHandler,- ForHandler,- IfHandler,- MethodDefHandler,- ObjectBlockHandler,- SlistHandler,- StaticInitHandler,- SwitchHandler,- SynchronizedHandler,- TryHandler,- WhileHandler
 
 public class BlockParentHandler extends AbstractExpressionHandler Handler for parents of blocks ('if', 'else', 'while', etc).The "block" handler classes use a common superclass BlockParentHandler, employing the Template Method pattern. - template method to get the lcurly
- template method to get the rcurly
- if curlies aren't present, then template method to get expressions is called
- now all the repetitious code which checks for BOL, if curlies are on same line, etc. can be collapsed into the superclass
 
- 
- 
Constructor SummaryConstructors Constructor Description BlockParentHandler(IndentationCheck indentCheck, java.lang.String name, DetailAST ast, AbstractExpressionHandler parent)Construct an instance of this handler with the given indentation check, name, abstract syntax tree, and parent handler.
 - 
Method SummaryAll Methods Instance Methods Concrete Methods Modifier and Type Method Description protected booleancanChildrenBeNested()Determines if child elements within the expression may be nested.voidcheckIndentation()Check the indentation of the expression we are handling.protected voidcheckTopLevelToken()Check the indent of the top level token.protected IndentLevelcurlyIndent()Get the expected indentation level for the curly braces.protected int[]getCheckedChildren()Returns array of token types which should be checked among children.protected IndentLevelgetChildrenExpectedIndent()Gets indentation level expected for children.protected DetailASTgetLeftCurly()Get the left curly brace portion of the expression we are handling.protected DetailASTgetListChild()Get the child element representing the list of statements.protected DetailASTgetNonListChild()Get the child element that is not a list of statements.protected DetailASTgetRightCurly()Get the right curly brace portion of the expression we are handling.IndentLevelgetSuggestedChildIndent(AbstractExpressionHandler child)Indentation level suggested for a child element.protected DetailASTgetTopLevelAst()Get the top level expression being managed by this handler.- 
Methods inherited from class com.puppycrawl.tools.checkstyle.checks.indentation.AbstractExpressionHandlercheckChildren, checkExpressionSubtree, checkLeftParen, checkModifiers, checkRightParen, checkWrappingIndentation, checkWrappingIndentation, expandedTabsColumnNo, findSubtreeAst, getBasicOffset, getBraceAdjustment, getFirstAst, getFirstLine, getFirstToken, getIndent, getIndentCheck, getIndentImpl, getLineStart, getLineStart, getMainAst, getParent, isOnStartOfLine, logError, logError, shouldIncreaseIndent
 
- 
 
- 
- 
- 
Constructor Detail- 
BlockParentHandlerpublic BlockParentHandler(IndentationCheck indentCheck, java.lang.String name, DetailAST ast, AbstractExpressionHandler parent) Construct an instance of this handler with the given indentation check, name, abstract syntax tree, and parent handler.- Parameters:
- indentCheck- the indentation check
- name- the name of the handler
- ast- the abstract syntax tree
- parent- the parent handler
 
 
- 
 - 
Method Detail- 
getCheckedChildrenprotected int[] getCheckedChildren() Returns array of token types which should be checked among children.- Returns:
- array of token types to check.
 
 - 
getTopLevelAstprotected DetailAST getTopLevelAst() Get the top level expression being managed by this handler.- Returns:
- the top level expression
 
 - 
checkTopLevelTokenprotected void checkTopLevelToken() Check the indent of the top level token.
 - 
getLeftCurlyprotected DetailAST getLeftCurly() Get the left curly brace portion of the expression we are handling.- Returns:
- the left curly brace expression
 
 - 
getRightCurlyprotected DetailAST getRightCurly() Get the right curly brace portion of the expression we are handling.- Returns:
- the right curly brace expression
 
 - 
curlyIndentprotected IndentLevel curlyIndent() Get the expected indentation level for the curly braces.- Returns:
- the curly brace indentation level
 
 - 
canChildrenBeNestedprotected boolean canChildrenBeNested() Determines if child elements within the expression may be nested.- Returns:
- false
 
 - 
getNonListChildprotected DetailAST getNonListChild() Get the child element that is not a list of statements.- Returns:
- the non-list child element
 
 - 
getListChildprotected DetailAST getListChild() Get the child element representing the list of statements.- Returns:
- the statement list child
 
 - 
checkIndentationpublic void checkIndentation() Description copied from class:AbstractExpressionHandlerCheck the indentation of the expression we are handling.- Specified by:
- checkIndentationin class- AbstractExpressionHandler
 
 - 
getChildrenExpectedIndentprotected IndentLevel getChildrenExpectedIndent() Gets indentation level expected for children.- Returns:
- indentation level expected for children
 
 - 
getSuggestedChildIndentpublic IndentLevel getSuggestedChildIndent(AbstractExpressionHandler child) Description copied from class:AbstractExpressionHandlerIndentation level suggested for a child element. Children don't have to respect this, but most do.- Overrides:
- getSuggestedChildIndentin class- AbstractExpressionHandler
- Parameters:
- child- child AST (so suggestion level can differ based on child type)
- Returns:
- suggested indentation for child
 
 
- 
 
-