public abstract class AbstractExpressionHandler extends Object
Modifier | Constructor and Description |
---|---|
protected |
AbstractExpressionHandler(IndentationCheck indentCheck,
String typeName,
DetailAST expr,
AbstractExpressionHandler 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 parentNode,
int[] tokenTypes,
IndentLevel startIndent,
boolean firstLineMatches,
boolean allowNesting)
Check the indent level of the children of the specified parent
expression.
|
protected void |
checkExpressionSubtree(DetailAST tree,
IndentLevel indentLevel,
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 |
getBraceAdjustment()
A shortcut for
IndentationCheck property. |
protected int |
getFirstLine(int startLine,
DetailAST tree)
Get the first line for a given expression.
|
IndentLevel |
getIndent()
Get the indentation amount for this handler.
|
protected IndentationCheck |
getIndentCheck()
Accessor for the IndentCheck attribute.
|
protected IndentLevel |
getIndentImpl()
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 AbstractExpressionHandler |
getParent()
Accessor for the Parent attribute.
|
IndentLevel |
getSuggestedChildIndent(AbstractExpressionHandler child)
Indentation level suggested for a child element.
|
protected boolean |
isOnStartOfLine(DetailAST ast)
Determines if the given expression is at the start of a line.
|
protected void |
logError(DetailAST ast,
String subtypeName,
int actualIndent)
Log an indentation error.
|
protected void |
logError(DetailAST ast,
String subtypeName,
int actualIndent,
IndentLevel expectedIndent)
Log an indentation error.
|
protected boolean |
shouldIncreaseIndent()
Checks that indentation should be increased after first line in checkLinesIndent().
|
protected AbstractExpressionHandler(IndentationCheck indentCheck, String typeName, DetailAST expr, AbstractExpressionHandler parent)
indentCheck
- the indentation checktypeName
- the name of the handlerexpr
- the abstract syntax treeparent
- the parent handlerpublic abstract void checkIndentation()
public final IndentLevel getIndent()
protected IndentLevel getIndentImpl()
public IndentLevel getSuggestedChildIndent(AbstractExpressionHandler child)
child
- child AST (so suggestion level can differ based on child
type)protected final void logError(DetailAST ast, String subtypeName, int actualIndent)
ast
- the expression that caused the errorsubtypeName
- the type of the expressionactualIndent
- the actual indent level of the expressionprotected final void logError(DetailAST ast, String subtypeName, int actualIndent, IndentLevel expectedIndent)
ast
- the expression that caused the errorsubtypeName
- the type of the expressionactualIndent
- the actual indent level of the expressionexpectedIndent
- the expected indent level of the expressionprotected final boolean isOnStartOfLine(DetailAST ast)
ast
- the expression to checkprotected final int getLineStart(DetailAST ast)
ast
- the expression to find the start of the line forprotected final int getLineStart(String line)
line
- the specified line numberprotected boolean shouldIncreaseIndent()
protected final void checkLinesIndent(int startLine, int endLine, IndentLevel indentLevel)
startLine
- the first line to checkendLine
- the last line to checkindentLevel
- the required indent levelprotected final void checkChildren(DetailAST parentNode, int[] tokenTypes, IndentLevel startIndent, boolean firstLineMatches, boolean allowNesting)
parentNode
- the parent whose children we are checkingtokenTypes
- the token types to checkstartIndent
- 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 indentLevel, boolean firstLineMatches, boolean allowNesting)
tree
- the expression subtree to checkindentLevel
- 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()
protected final IndentationCheck getIndentCheck()
protected final DetailAST getMainAst()
protected final AbstractExpressionHandler getParent()
protected final int getBasicOffset()
IndentationCheck
property.IndentationCheck
protected final int getBraceAdjustment()
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–2016. All rights reserved.