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
-
public class MethodDefHandler extends BlockParentHandler
Handler for method definitions.
-
-
Constructor Summary
Constructors Constructor Description MethodDefHandler(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 Static Methods Instance Methods Concrete Methods Modifier and Type Method Description void
checkIndentation()
Check the indentation of the expression we are handling.protected void
checkModifiers()
Check the indentation level of modifiers.private void
checkThrows()
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
getTopLevelAst()
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 Detail
-
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 Detail
-
getTopLevelAst
protected DetailAST 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
protected void checkModifiers()
Description copied from class:AbstractExpressionHandler
Check the indentation level of modifiers.- Overrides:
checkModifiers
in classAbstractExpressionHandler
-
checkThrows
private void checkThrows()
Check the indentation level of the throws clause.
-
getMethodDefLineStart
private static int getMethodDefLineStart(DetailAST mainAst)
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
public void checkIndentation()
Description copied from class:AbstractExpressionHandler
Check the indentation of the expression we are handling.- Overrides:
checkIndentation
in classBlockParentHandler
-
getMethodDefParamRightParen
private static DetailAST getMethodDefParamRightParen(DetailAST methodDefAst)
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
private static String getHandlerName(DetailAST ast)
Creates a handler name for this class according to ast type.- Parameters:
ast
- the abstract syntax tree.- Returns:
- handler name for this class.
-
-