com.puppycrawl.tools.checkstyle.checks.indentation

Class BlockParentHandler

public class BlockParentHandler extends ExpressionHandler

Handler for parents of blocks ('if', 'else', 'while', etc).

The "block" handler classes use a common superclass BlockParentHandler, employing the Template Method pattern.

Author: jrichard

Constructor Summary
BlockParentHandler(IndentationCheck aIndentCheck, String aName, DetailAST aAst, ExpressionHandler aParent)
Construct an instance of this handler with the given indentation check, name, abstract syntax tree, and parent handler.
Method Summary
voidcheckIndentation()
Check the indentation of the expression we are handling.
protected voidcheckLCurly()
Check the indentation of the left curly brace.
protected voidcheckRCurly()
Check the indentation of the right curly brace.
protected voidcheckToplevelToken()
Check the indent of the top level token.
protected booleanchildrenMayNest()
Determines if child elements within the expression may be nested.
protected int[]getCheckedChildren()
Returns array of token types which should be checked among childrens.
protected IndentLevelgetChildrenExpectedLevel()
protected DetailASTgetLCurly()
Get the left curly brace portion of the expression we are handling.
protected DetailASTgetListChild()
Get the child element representing the list of statements.
protected DetailASTgetLParen()
Get the left parenthesis portion of the expression we are handling.
protected DetailASTgetNonlistChild()
Get the child element that is not a list of statements.
protected DetailASTgetRCurly()
Get the right curly brace portion of the expression we are handling.
protected DetailASTgetRParen()
Get the right parenthesis portion of the expression we are handling.
protected DetailASTgetToplevelAST()
Get the top level expression being managed by this handler.
protected booleanhasCurlys()
Determines if this block expression has curly braces.
protected booleanrcurlyMustStart()
Determines if the right curly brace must be at the start of the line.
IndentLevelsuggestedChildLevel(ExpressionHandler aChild)
{@inheritDoc}
protected booleantoplevelMustStartLine()
Determines if the top level token must start the line.

Constructor Detail

BlockParentHandler

public BlockParentHandler(IndentationCheck aIndentCheck, String aName, DetailAST aAst, ExpressionHandler aParent)
Construct an instance of this handler with the given indentation check, name, abstract syntax tree, and parent handler.

Parameters: aIndentCheck the indentation check aName the name of the handler aAst the abstract syntax tree aParent the parent handler

Method Detail

checkIndentation

public void checkIndentation()
Check the indentation of the expression we are handling.

checkLCurly

protected void checkLCurly()
Check the indentation of the left curly brace.

checkRCurly

protected void checkRCurly()
Check the indentation of the right curly brace.

checkToplevelToken

protected void checkToplevelToken()
Check the indent of the top level token.

childrenMayNest

protected boolean childrenMayNest()
Determines if child elements within the expression may be nested.

Returns: false

getCheckedChildren

protected int[] getCheckedChildren()
Returns array of token types which should be checked among childrens.

Returns: array of token types to check.

getChildrenExpectedLevel

protected IndentLevel getChildrenExpectedLevel()

Returns: indentation level expected for children

getLCurly

protected DetailAST getLCurly()
Get the left curly brace portion of the expression we are handling.

Returns: the left curly brace expression

getListChild

protected DetailAST getListChild()
Get the child element representing the list of statements.

Returns: the statement list child

getLParen

protected DetailAST getLParen()
Get the left parenthesis portion of the expression we are handling.

Returns: the left parenthis expression

getNonlistChild

protected DetailAST getNonlistChild()
Get the child element that is not a list of statements.

Returns: the non-list child element

getRCurly

protected DetailAST getRCurly()
Get the right curly brace portion of the expression we are handling.

Returns: the right curly brace expression

getRParen

protected DetailAST getRParen()
Get the right parenthesis portion of the expression we are handling.

Returns: the right parenthis expression

getToplevelAST

protected DetailAST getToplevelAST()
Get the top level expression being managed by this handler.

Returns: the top level expression

hasCurlys

protected boolean hasCurlys()
Determines if this block expression has curly braces.

Returns: true if curly braces are present, false otherwise

rcurlyMustStart

protected boolean rcurlyMustStart()
Determines if the right curly brace must be at the start of the line.

Returns: true

suggestedChildLevel

public IndentLevel suggestedChildLevel(ExpressionHandler aChild)
{@inheritDoc}

toplevelMustStartLine

protected boolean toplevelMustStartLine()
Determines if the top level token must start the line.

Returns: true