public abstract class AbstractExpressionHandler extends java.lang.Object
| Modifier and Type | Field and Description |
|---|---|
private IndentLevel |
indent
Indentation amount for this handler.
|
private IndentationCheck |
indentCheck
The instance of
IndentationCheck using this handler. |
private DetailAST |
mainAst
The AST which is handled by this handler.
|
private AbstractExpressionHandler |
parent
Containing AST handler.
|
private java.lang.String |
typeName
Name used during output to user.
|
| Modifier | Constructor and Description |
|---|---|
protected |
AbstractExpressionHandler(IndentationCheck indentCheck,
java.lang.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 |
checkLeftParen(DetailAST lparen)
Check the indentation of the left parenthesis.
|
private void |
checkLineIndent(DetailAST ast,
IndentLevel indentLevel,
boolean mustMatch)
Check the indentation for a single line.
|
private void |
checkLinesIndent(DetailAstSet astSet,
IndentLevel indentLevel,
boolean firstLineMatches,
int firstLine,
boolean allowNesting)
Check the indentation for a set of lines.
|
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 |
findSubtreeAst(DetailAstSet astSet,
DetailAST tree,
boolean allowNesting)
Find the set of abstract syntax tree for a given subtree.
|
protected int |
getBasicOffset()
A shortcut for
IndentationCheck property. |
protected int |
getBraceAdjustment()
A shortcut for
IndentationCheck property. |
protected static DetailAST |
getFirstAstNode(DetailAST ast)
Get the first ast for given expression.
|
protected static int |
getFirstLine(DetailAST tree)
Get the first line number for 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.
|
private int |
getLineStart(java.lang.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.
|
private void |
logChildError(DetailAST ast,
int actualIndent,
IndentLevel expectedIndent)
Log child indentation error.
|
protected void |
logError(DetailAST ast,
java.lang.String subtypeName,
int actualIndent)
Log an indentation error.
|
protected void |
logError(DetailAST ast,
java.lang.String subtypeName,
int actualIndent,
IndentLevel expectedIndent)
Log an indentation error.
|
protected boolean |
shouldIncreaseIndent()
Checks that indentation should be increased after first line in checkLinesIndent().
|
private final IndentationCheck indentCheck
IndentationCheck using this handler.private final java.lang.String typeName
private final AbstractExpressionHandler parent
private IndentLevel indent
protected AbstractExpressionHandler(IndentationCheck indentCheck, java.lang.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, java.lang.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, java.lang.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 expressionprivate void logChildError(DetailAST ast, int actualIndent, IndentLevel expectedIndent)
ast - the abstract syntax tree that causes the erroractualIndent - 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 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 forprivate int getLineStart(java.lang.String line)
line - the specified line numberprotected boolean shouldIncreaseIndent()
private void checkLinesIndent(DetailAstSet astSet, IndentLevel indentLevel, boolean firstLineMatches, int firstLine, boolean allowNesting)
astSet - the set of abstract syntax tree to checkindentLevel - the indentation levelfirstLineMatches - whether or not the first line has to matchfirstLine - first line of whole expressionallowNesting - whether or not subtree nesting is allowedprivate void checkLineIndent(DetailAST ast, IndentLevel indentLevel, boolean mustMatch)
ast - the abstract syntax tree to checkindentLevel - the indentation levelmustMatch - whether or not the indentation level must matchprotected 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(DetailAST tree)
tree - the expression to find the first line forprotected static DetailAST getFirstAstNode(DetailAST ast)
ast - the abstract syntax tree for which the starting ast is to be foundprotected final int expandedTabsColumnNo(DetailAST ast)
ast - the expression to find the start ofprotected final void findSubtreeAst(DetailAstSet astSet, DetailAST tree, boolean allowNesting)
astSet - the set of ast to addtree - 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.IndentationCheckprotected final int getBraceAdjustment()
IndentationCheck property.IndentationCheckprotected final void checkRightParen(DetailAST lparen, DetailAST rparen)
lparen - left parenthesis associated with aRparenrparen - parenthesis to checkprotected final void checkLeftParen(DetailAST lparen)
lparen - parenthesis to checkCopyright © 2001-2022. All Rights Reserved.