Class MethodDefHandler
java.lang.Object
com.puppycrawl.tools.checkstyle.checks.indentation.AbstractExpressionHandler
com.puppycrawl.tools.checkstyle.checks.indentation.BlockParentHandler
com.puppycrawl.tools.checkstyle.checks.indentation.MethodDefHandler
Handler for method definitions.
-
Constructor Summary
ConstructorsConstructorDescriptionMethodDefHandler
(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
Modifier and TypeMethodDescriptionvoid
Check the indentation of the expression we are handling.protected void
Check the indentation level of modifiers.private void
Check the indentation level of the throws clause.private static String
getHandlerName
(DetailAST ast) Creates a handler name for this class according to ast type.private static int
getMethodDefLineStart
(DetailAST mainAst) Gets the start line of the method, excluding any annotations.private static DetailAST
getMethodDefParamRightParen
(DetailAST methodDefAst) Returns right parenthesis of method definition parameter list.protected DetailAST
Get the top level expression being managed by this handler.Methods inherited from class com.puppycrawl.tools.checkstyle.checks.indentation.BlockParentHandler
canChildrenBeNested, checkTopLevelToken, curlyIndent, getCheckedChildren, getChildrenExpectedIndent, getLeftCurly, getListChild, getNonListChild, getRightCurly, getSuggestedChildIndent
Methods inherited from class com.puppycrawl.tools.checkstyle.checks.indentation.AbstractExpressionHandler
checkChildren, checkExpressionSubtree, checkLeftParen, checkRightParen, checkWrappingIndentation, checkWrappingIndentation, expandedTabsColumnNo, findSubtreeAst, getBasicOffset, getBraceAdjustment, getFirstAstNode, getFirstLine, getFirstToken, getIndent, getIndentCheck, getIndentImpl, getLineStart, getLineStart, getMainAst, getParent, isOnStartOfLine, logError, logError, shouldIncreaseIndent
-
Constructor Details
-
MethodDefHandler
public MethodDefHandler(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 Details
-
getTopLevelAst
Description copied from class:BlockParentHandler
Get the top level expression being managed by this handler.- Overrides:
getTopLevelAst
in classBlockParentHandler
- Returns:
- the top level expression
-
checkModifiers
Description copied from class:AbstractExpressionHandler
Check the indentation level of modifiers.- Overrides:
checkModifiers
in classAbstractExpressionHandler
-
checkThrows
Check the indentation level of the throws clause. -
getMethodDefLineStart
Gets the start line of the method, excluding any annotations. This is required because the currentTokenTypes.METHOD_DEF
may not always be the start as seen in #3145.- Parameters:
mainAst
- The method definition ast.- Returns:
- The start column position of the method.
-
checkIndentation
Description copied from class:AbstractExpressionHandler
Check the indentation of the expression we are handling.- Overrides:
checkIndentation
in classBlockParentHandler
-
getMethodDefParamRightParen
Returns right parenthesis of method definition parameter list.- Parameters:
methodDefAst
- method definition ast node(TokenTypes.LITERAL_IF)- Returns:
- right parenthesis of method definition parameter list.
-
getHandlerName
Creates a handler name for this class according to ast type.- Parameters:
ast
- the abstract syntax tree.- Returns:
- handler name for this class.
-