public class LineWrappingHandler extends java.lang.Object
| Modifier and Type | Class and Description |
|---|---|
static class |
LineWrappingHandler.LineWrappingOptions
Enum to be used for test if first line's indentation should be checked or not.
|
| Modifier and Type | Field and Description |
|---|---|
private static int[] |
IGNORED_LIST
The list of ignored token types for being checked by lineWrapping indentation
inside
checkIndentation() as these tokens are checked for lineWrapping
inside their dedicated handlers. |
private IndentationCheck |
indentCheck
The current instance of
IndentationCheck class using this
handler. |
| Constructor and Description |
|---|
LineWrappingHandler(IndentationCheck instance)
Sets values of class field, finds last node and calculates indentation level.
|
| Modifier and Type | Method and Description |
|---|---|
private void |
checkAnnotationIndentation(DetailAST atNode,
java.util.NavigableMap<java.lang.Integer,DetailAST> firstNodesOnLines,
int indentLevel)
Checks line wrapping into annotations.
|
void |
checkForAnnotationIndentation(java.util.NavigableMap<java.lang.Integer,DetailAST> firstNodesOnLines,
int indentLevel)
Checks for annotation indentation.
|
static boolean |
checkForMethodLparenNewLine(DetailAST node)
Checks whether the method lparen starts from a new line or not.
|
static boolean |
checkForNullParameterChild(DetailAST node)
Checks whether parameter node has any child or not.
|
void |
checkIndentation(DetailAST firstNode,
DetailAST lastNode)
Checks line wrapping into expressions and definitions using property
'lineWrappingIndentation'.
|
private void |
checkIndentation(DetailAST firstNode,
DetailAST lastNode,
int indentLevel)
Checks line wrapping into expressions and definitions.
|
void |
checkIndentation(DetailAST firstNode,
DetailAST lastNode,
int indentLevel,
int startIndent,
LineWrappingHandler.LineWrappingOptions ignoreFirstLine)
Checks line wrapping into expressions and definitions.
|
private java.util.NavigableMap<java.lang.Integer,DetailAST> |
collectFirstNodes(DetailAST firstNode,
DetailAST lastNode)
Finds first nodes on line and puts them into Map.
|
private int |
expandedTabsColumnNo(DetailAST ast)
Get the column number for the start of a given expression, expanding
tabs out into spaces in the process.
|
private int |
getLineStart(DetailAST ast)
Get the start of the line for the given expression.
|
private int |
getLineStart(java.lang.String line)
Get the start of the specified line.
|
private static DetailAST |
getNextCurNode(DetailAST curNode)
Returns next curNode node.
|
private static java.lang.Integer |
getNextNodeLine(java.util.NavigableMap<java.lang.Integer,DetailAST> firstNodesOnLines,
DetailAST node)
Gets the next node line from the firstNodesOnLines map unless there is no next line, in
which case, it returns the last line.
|
private static boolean |
isEndOfScope(DetailAST lastAnnotationNode,
DetailAST node)
Checks line for end of scope.
|
private static boolean |
isParentContainsTokenType(DetailAST node,
int type)
Checks that some parent of given node contains given token type.
|
private void |
logWarningMessage(DetailAST currentNode,
int currentIndent)
Logs warning message if indentation is incorrect.
|
private static final int[] IGNORED_LIST
checkIndentation() as these tokens are checked for lineWrapping
inside their dedicated handlers.private final IndentationCheck indentCheck
IndentationCheck class using this
handler. This field used to get access to private fields of
IndentationCheck instance.public LineWrappingHandler(IndentationCheck instance)
instance - instance of IndentationCheck.public void checkIndentation(DetailAST firstNode, DetailAST lastNode)
firstNode - First node to start examining.lastNode - Last node to examine inclusively.private void checkIndentation(DetailAST firstNode, DetailAST lastNode, int indentLevel)
firstNode - First node to start examining.lastNode - Last node to examine inclusively.indentLevel - Indentation all wrapped lines should use.public void checkIndentation(DetailAST firstNode, DetailAST lastNode, int indentLevel, int startIndent, LineWrappingHandler.LineWrappingOptions ignoreFirstLine)
firstNode - First node to start examining.lastNode - Last node to examine inclusively.indentLevel - 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.public void checkForAnnotationIndentation(java.util.NavigableMap<java.lang.Integer,DetailAST> firstNodesOnLines, int indentLevel)
firstNodesOnLines - the nodes which are present in the beginning of each line.indentLevel - line wrapping indentation.public static boolean checkForNullParameterChild(DetailAST node)
node - the node for which to check.public static boolean checkForMethodLparenNewLine(DetailAST node)
node - the node for which to check.private static java.lang.Integer getNextNodeLine(java.util.NavigableMap<java.lang.Integer,DetailAST> firstNodesOnLines, DetailAST node)
firstNodesOnLines - NavigableMap of lines and their first nodes.node - the node for which to find the next node lineprivate java.util.NavigableMap<java.lang.Integer,DetailAST> collectFirstNodes(DetailAST firstNode, DetailAST lastNode)
firstNode - First node to start examining.lastNode - Last node to examine inclusively.private static DetailAST getNextCurNode(DetailAST curNode)
curNode - current node.private void checkAnnotationIndentation(DetailAST atNode, java.util.NavigableMap<java.lang.Integer,DetailAST> firstNodesOnLines, int indentLevel)
atNode - block tag node.firstNodesOnLines - map which contains
first nodes as values and line numbers as keys.indentLevel - line wrapping indentation.private static boolean isEndOfScope(DetailAST lastAnnotationNode, DetailAST node)
lastAnnotationNode - the last node of the annotationnode - the node indicating where to begin checkingprivate static boolean isParentContainsTokenType(DetailAST node, int type)
node - node to checktype - type to look forprivate int expandedTabsColumnNo(DetailAST ast)
ast - the expression to find the start ofprivate int getLineStart(DetailAST ast)
ast - the expression to find the start of the line forprivate int getLineStart(java.lang.String line)
line - the specified line numberprivate void logWarningMessage(DetailAST currentNode, int currentIndent)
currentNode - current node which probably invoked a violation.currentIndent - correct indentation.Copyright © 2001-2022. All Rights Reserved.