Class MethodDefHandler


public class MethodDefHandler extends BlockParentHandler
Handler for method definitions.
  • 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 check
      ast - the abstract syntax tree
      parent - the parent handler
  • Method Details

    • getTopLevelAst

      protected DetailAST getTopLevelAst()
      Description copied from class: BlockParentHandler
      Get the top level expression being managed by this handler.
      Overrides:
      getTopLevelAst in class BlockParentHandler
      Returns:
      the top level expression
    • checkModifiers

      protected void checkModifiers()
      Description copied from class: AbstractExpressionHandler
      Check the indentation level of modifiers.
      Overrides:
      checkModifiers in class AbstractExpressionHandler
    • 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 current TokenTypes.METHOD_DEF may 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: AbstractExpressionHandler
      Check the indentation of the expression we are handling.
      Overrides:
      checkIndentation in class BlockParentHandler
    • 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.