Class LambdaHandler
- java.lang.Object
-
- com.puppycrawl.tools.checkstyle.checks.indentation.AbstractExpressionHandler
-
- com.puppycrawl.tools.checkstyle.checks.indentation.LambdaHandler
-
public class LambdaHandler extends AbstractExpressionHandler
Handler for lambda expressions.
-
-
Field Summary
Fields Modifier and Type Field Description private boolean
isLambdaCorrectlyIndented
Checks whether the lambda is correctly indented, this variable get its value from checking the lambda handler's indentation, and it is being used in aligning the lambda's children.
-
Constructor Summary
Constructors Constructor Description LambdaHandler(IndentationCheck indentCheck, DetailAST ast, AbstractExpressionHandler parent)
Construct an instance of this handler with the given indentation check, abstract syntax tree, and parent handler.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
checkIndentation()
Check the indentation of the expression we are handling.private void
checkLineWrappedLambda(boolean isSwitchRuleLambda, int mainAstColumnNo)
This method checks a line wrapped lambda, whether it is a lambda expression or switch rule lambda.protected IndentLevel
getIndentImpl()
Compute the indentation amount for this handler.IndentLevel
getSuggestedChildIndent(AbstractExpressionHandler child)
Indentation level suggested for a child element.private boolean
isNonAcceptableIndent(int astColumnNo, IndentLevel level)
Checks that given indent is acceptable or not.-
Methods inherited from class com.puppycrawl.tools.checkstyle.checks.indentation.AbstractExpressionHandler
checkChildren, checkExpressionSubtree, checkLeftParen, checkModifiers, checkRightParen, checkWrappingIndentation, checkWrappingIndentation, expandedTabsColumnNo, findSubtreeAst, getBasicOffset, getBraceAdjustment, getFirstAstNode, getFirstLine, getFirstToken, getIndent, getIndentCheck, getLineStart, getLineStart, getMainAst, getParent, isOnStartOfLine, logError, logError, shouldIncreaseIndent
-
-
-
-
Field Detail
-
isLambdaCorrectlyIndented
private boolean isLambdaCorrectlyIndented
Checks whether the lambda is correctly indented, this variable get its value from checking the lambda handler's indentation, and it is being used in aligning the lambda's children. A true value depicts lambda is correctly aligned without giving any errors. This is updated to false where there is any Indentation error log.
-
-
Constructor Detail
-
LambdaHandler
public LambdaHandler(IndentationCheck indentCheck, DetailAST ast, AbstractExpressionHandler parent)
Construct an instance of this handler with the given indentation check, abstract syntax tree, and parent handler.- Parameters:
indentCheck
- the indentation checkast
- the abstract syntax treeparent
- the parent handler
-
-
Method Detail
-
getSuggestedChildIndent
public IndentLevel getSuggestedChildIndent(AbstractExpressionHandler child)
Description copied from class:AbstractExpressionHandler
Indentation level suggested for a child element. Children don't have to respect this, but most do.- Overrides:
getSuggestedChildIndent
in classAbstractExpressionHandler
- Parameters:
child
- child AST (so suggestion level can differ based on child type)- Returns:
- suggested indentation for child
-
getIndentImpl
protected IndentLevel getIndentImpl()
Compute the indentation amount for this handler..- Overrides:
getIndentImpl
in classAbstractExpressionHandler
- Returns:
- the expected indentation amount
-
checkIndentation
public void checkIndentation()
Description copied from class:AbstractExpressionHandler
Check the indentation of the expression we are handling.- Specified by:
checkIndentation
in classAbstractExpressionHandler
-
isNonAcceptableIndent
private boolean isNonAcceptableIndent(int astColumnNo, IndentLevel level)
Checks that given indent is acceptable or not.- Parameters:
astColumnNo
- indent value to checklevel
- indent level- Returns:
- true if indent is not acceptable
-
checkLineWrappedLambda
private void checkLineWrappedLambda(boolean isSwitchRuleLambda, int mainAstColumnNo)
This method checks a line wrapped lambda, whether it is a lambda expression or switch rule lambda.- Parameters:
isSwitchRuleLambda
- if mainAst is a switch rule lambdamainAstColumnNo
- the column number of the lambda we are checking
-
-