public abstract class ExpressionHandler extends Object
Constructor and Description |
---|
ExpressionHandler(IndentationCheck indentCheck,
String typeName,
DetailAST expr,
ExpressionHandler parent)
Construct an instance of this handler with the given indentation check,
name, abstract syntax tree, and parent handler.
|
Modifier and Type | Method and Description |
---|---|
protected void |
checkChildren(DetailAST parent,
int[] tokenTypes,
IndentLevel startLevel,
boolean firstLineMatches,
boolean allowNesting)
Check the indent level of the children of the specified parent
expression.
|
protected void |
checkExpressionSubtree(DetailAST tree,
IndentLevel level,
boolean firstLineMatches,
boolean allowNesting)
Check the indentation level for an expression subtree.
|
abstract void |
checkIndentation()
Check the indentation of the expression we are handling.
|
protected void |
checkLinesIndent(int startLine,
int endLine,
IndentLevel indentLevel)
Check the indentation of consecutive lines for the expression we are
handling.
|
protected void |
checkLParen(DetailAST lparen)
Check the indentation of the left parenthesis.
|
protected void |
checkModifiers()
Check the indentation level of modifiers.
|
protected void |
checkRParen(DetailAST lparen,
DetailAST rparen)
Check the indentation of the right parenthesis.
|
protected int |
expandedTabsColumnNo(DetailAST ast)
Get the column number for the start of a given expression, expanding
tabs out into spaces in the process.
|
protected void |
findSubtreeLines(LineSet lines,
DetailAST tree,
boolean allowNesting)
Find the set of lines for a given subtree.
|
protected int |
getBasicOffset()
A shortcut for
IndentationCheck property. |
protected int |
getBraceAdjustement()
A shortcut for
IndentationCheck property. |
protected int |
getFirstLine(int startLine,
DetailAST tree)
Get the first line for a given expression.
|
protected IndentationCheck |
getIndentCheck()
Accessor for the IndentCheck attribute.
|
IndentLevel |
getLevel()
Get the indentation amount for this handler.
|
protected IndentLevel |
getLevelImpl()
Compute the indentation amount for this handler.
|
protected int |
getLineStart(DetailAST ast)
Get the start of the line for the given expression.
|
protected int |
getLineStart(String line)
Get the start of the specified line.
|
protected DetailAST |
getMainAst()
Accessor for the MainAst attribute.
|
protected ExpressionHandler |
getParent()
Accessor for the Parent attribute.
|
protected void |
logError(DetailAST ast,
String subtypeName,
int actualLevel)
Log an indentation error.
|
protected void |
logError(DetailAST ast,
String subtypeName,
int actualLevel,
IndentLevel expectedLevel)
Log an indentation error.
|
protected boolean |
shouldIncreaseIndent() |
protected boolean |
startsLine(DetailAST ast)
Determines if the given expression is at the start of a line.
|
IndentLevel |
suggestedChildLevel(ExpressionHandler child)
Indentation level suggested for a child element.
|
public ExpressionHandler(IndentationCheck indentCheck, String typeName, DetailAST expr, ExpressionHandler parent)
indentCheck
- the indentation checktypeName
- the name of the handlerexpr
- the abstract syntax treeparent
- the parent handlerpublic final IndentLevel getLevel()
protected IndentLevel getLevelImpl()
public IndentLevel suggestedChildLevel(ExpressionHandler child)
child
- child AST (so suggestion level can differ based on child
type)protected final void logError(DetailAST ast, String subtypeName, int actualLevel)
ast
- the expression that caused the errorsubtypeName
- the type of the expressionactualLevel
- the actual indent level of the expressionprotected final void logError(DetailAST ast, String subtypeName, int actualLevel, IndentLevel expectedLevel)
ast
- the expression that caused the errorsubtypeName
- the type of the expressionactualLevel
- the actual indent level of the expressionexpectedLevel
- the expected indent level of the expressionprotected final boolean startsLine(DetailAST ast)
ast
- the expression to checkprotected final int getLineStart(DetailAST ast)
ast
- the expression to find the start of the line forprotected final void checkLinesIndent(int startLine, int endLine, IndentLevel indentLevel)
startLine
- the first line to checkendLine
- the last line to checkindentLevel
- the required indent levelprotected boolean shouldIncreaseIndent()
protected final int getLineStart(String line)
line
- the specified line numberprotected final void checkChildren(DetailAST parent, int[] tokenTypes, IndentLevel startLevel, boolean firstLineMatches, boolean allowNesting)
parent
- the parent whose children we are checkingtokenTypes
- the token types to checkstartLevel
- the starting indent levelfirstLineMatches
- whether or not the first line needs to matchallowNesting
- whether or not nested children are allowedprotected final void checkExpressionSubtree(DetailAST tree, IndentLevel level, boolean firstLineMatches, boolean allowNesting)
tree
- the expression subtree to checklevel
- the indentation levelfirstLineMatches
- whether or not the first line has to matchallowNesting
- whether or not subtree nesting is allowedprotected final int getFirstLine(int startLine, DetailAST tree)
startLine
- the line we are starting fromtree
- the expression to find the first line forprotected final int expandedTabsColumnNo(DetailAST ast)
ast
- the expression to find the start ofprotected final void findSubtreeLines(LineSet lines, DetailAST tree, boolean allowNesting)
lines
- the set of lines to add totree
- the subtree to examineallowNesting
- whether or not to allow nested subtreesprotected void checkModifiers()
public abstract void checkIndentation()
protected final IndentationCheck getIndentCheck()
protected final DetailAST getMainAst()
protected final ExpressionHandler getParent()
protected final int getBasicOffset()
IndentationCheck
property.IndentationCheck
protected final int getBraceAdjustement()
IndentationCheck
property.IndentationCheck
protected final void checkRParen(DetailAST lparen, DetailAST rparen)
rparen
- parenthesis to checklparen
- left parenthesis associated with aRparenprotected final void checkLParen(DetailAST lparen)
lparen
- parenthesis to checkCopyright © 2001–2015. All rights reserved.