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 |
---|---|
static boolean |
areOnSameLine(DetailAST ast1,
DetailAST ast2)
Determines if two expressions are on the same line.
|
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 |
checkLeftParen(DetailAST lparen)
Check the indentation of the left parenthesis.
|
protected void |
checkModifiers()
Check the indentation level of modifiers.
|
protected void |
checkRightParen(DetailAST lparen,
DetailAST rparen)
Check the indentation of the right parenthesis.
|
protected void |
checkWrappingIndentation(DetailAST firstNode,
DetailAST lastNode)
Checks indentation on wrapped lines between and including
firstNode and lastNode . |
protected void |
checkWrappingIndentation(DetailAST firstNode,
DetailAST lastNode,
int wrappedIndentLevel,
int startIndent,
boolean ignoreFirstLine)
Checks indentation on wrapped lines between and including
firstNode and lastNode . |
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 static int |
getFirstLine(int startLine,
DetailAST tree)
Get the first line for a given expression.
|
static DetailAST |
getFirstToken(DetailAST ast)
Searches in given sub-tree (including given node) for the token
which represents first symbol for this sub-tree in file.
|
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(int lineNo)
Get the start of the line for the given line number.
|
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 checkpublic static boolean areOnSameLine(DetailAST ast1, DetailAST ast2)
ast1
- the first expressionast2
- the second expressionpublic static DetailAST getFirstToken(DetailAST ast)
ast
- a root of sub-tree in which the search should be performed.protected final int getLineStart(DetailAST ast)
ast
- the expression to find the start of the line forprotected final int getLineStart(int lineNo)
lineNo
- the line number to find the start forprotected boolean shouldIncreaseIndent()
protected void checkWrappingIndentation(DetailAST firstNode, DetailAST lastNode)
firstNode
and lastNode
.firstNode
- First node to start examining.lastNode
- Last node to examine inclusively.protected void checkWrappingIndentation(DetailAST firstNode, DetailAST lastNode, int wrappedIndentLevel, int startIndent, boolean ignoreFirstLine)
firstNode
and lastNode
.firstNode
- First node to start examining.lastNode
- Last node to examine inclusively.wrappedIndentLevel
- Indentation all wrapped lines should use.startIndent
- Indentation first line before wrapped lines used.ignoreFirstLine
- Test if first line's indentation should be checked or not.protected 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 static 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 checkRightParen(DetailAST lparen, DetailAST rparen)
rparen
- parenthesis to checklparen
- left parenthesis associated with aRparenprotected final void checkLeftParen(DetailAST lparen)
lparen
- parenthesis to checkCopyright © 2001–2018. All rights reserved.