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 voidcheckIndentation()Check the indentation of the expression we are handling.protected voidcheckModifiers()Check the indentation level of modifiers.private voidcheckThrows()Check the indentation level of the throws clause.private static java.lang.StringgetHandlerName(DetailAST ast)Creates a handler name for this class according to ast type.private static intgetMethodDefLineStart(DetailAST mainAst)Gets the start line of the method, excluding any annotations.private static DetailASTgetMethodDefParamRightParen(DetailAST methodDefAst)Returns right parenthesis of method definition parameter list.protected DetailASTgetTopLevelAst()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:BlockParentHandlerGet the top level expression being managed by this handler.- Overrides:
getTopLevelAstin classBlockParentHandler- Returns:
- the top level expression
-
checkModifiers
protected void checkModifiers()
Description copied from class:AbstractExpressionHandlerCheck the indentation level of modifiers.- Overrides:
checkModifiersin 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_DEFmay not always be the start as seen in https://github.com/checkstyle/checkstyle/issues/3145.- Parameters:
mainAst- The method definition ast.- Returns:
- The start column position of the method.
-
checkIndentation
public void checkIndentation()
Description copied from class:AbstractExpressionHandlerCheck the indentation of the expression we are handling.- Overrides:
checkIndentationin 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 java.lang.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.
-
-