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
- jrichard
checkChildren , checkExpressionSubtree , checkIndentation , checkLinesIndent , checkModifiers , 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
checkIndentation
public void checkIndentation()
Check the indentation of the expression we are handling.
- checkIndentation in interface ExpressionHandler
checkLCurly
protected void checkLCurly()
Check the indentation of the left curly brace.
checkLParen
protected void checkLParen()
Check the indentation of the left parenthesis.
checkRCurly
protected void checkRCurly()
Check the indentation of the right curly brace.
checkRParen
protected void checkRParen()
Check the indentation of the right parenthesis.
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.
- false
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.
- the statement list child
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.
- the top level expression
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.
- true
toplevelMustStartLine
protected boolean toplevelMustStartLine()
Determines if the top level token must start the line.
- true