com.puppycrawl.tools.checkstyle.checks.indentation
Class BlockParentHandler
public class BlockParentHandler
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 curlys aren't present, then template method to get expressions
is called
- now all the repetitous code which checks for BOL, if curlys are on
same line, etc. can be collapsed into the superclass
checkChildren , checkExpressionSubtree , checkIndentation , checkLParen , checkLinesIndent , checkModifiers , checkRParen , expandedTabsColumnNo , findSubtreeLines , getBasicOffset , getBraceAdjustement , getFirstLine , getIndentCheck , getLevel , getLevelImpl , getLineStart , getLineStart , getMainAst , getParent , logError , logError , shouldIncreaseIndent , startsLine , suggestedChildLevel |
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.
aIndentCheck
- the indentation checkaName
- the name of the handleraAst
- the abstract syntax treeaParent
- the parent handler
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.
getCheckedChildren
protected int[] getCheckedChildren()
Returns array of token types which should be checked among childrens.
- array of token types to check.
getChildrenExpectedLevel
protected IndentLevel getChildrenExpectedLevel()
- indentation level expected for children
getLCurly
protected DetailAST getLCurly()
Get the left curly brace portion of the expression we are handling.
- the left curly brace expression
getLParen
protected DetailAST getLParen()
Get the left parenthesis portion of the expression we are handling.
- the left parenthis expression
getListChild
protected DetailAST getListChild()
Get the child element representing the list of statements.
getNonlistChild
protected DetailAST getNonlistChild()
Get the child element that is not a list of statements.
- the non-list child element
getRCurly
protected DetailAST getRCurly()
Get the right curly brace portion of the expression we are handling.
- the right curly brace expression
getRParen
protected DetailAST getRParen()
Get the right parenthesis portion of the expression we are handling.
- the right parenthis expression
getToplevelAST
protected DetailAST getToplevelAST()
Get the top level expression being managed by this handler.
hasCurlys
protected boolean hasCurlys()
Determines if this block expression has curly braces.
- 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.
toplevelMustStartLine
protected boolean toplevelMustStartLine()
Determines if the top level token must start the line.