public class ClassDefHandler extends BlockParentHandler
Handler for class definitions.
  • Field Details

  • Constructor Details

    • ClassDefHandler

      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

    • getLeftCurly

      protected DetailAST getLeftCurly()
      Description copied from class: BlockParentHandler
      Get the left curly brace portion of the expression we are handling.
      Overrides:
      getLeftCurly in class BlockParentHandler
      Returns:
      the left curly brace expression
    • getRightCurly

      protected DetailAST getRightCurly()
      Description copied from class: BlockParentHandler
      Get the right curly brace portion of the expression we are handling.
      Overrides:
      getRightCurly in class BlockParentHandler
      Returns:
      the right curly brace expression
    • 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
    • getListChild

      protected DetailAST getListChild()
      Description copied from class: BlockParentHandler
      Get the child element representing the list of statements.
      Overrides:
      getListChild in class BlockParentHandler
      Returns:
      the statement list child
    • checkIndentation

      public void checkIndentation()
      Description copied from class: AbstractExpressionHandler
      Check the indentation of the expression we are handling.
      Overrides:
      checkIndentation in class BlockParentHandler
    • getCheckedChildren

      protected int[] getCheckedChildren()
      Description copied from class: BlockParentHandler
      Returns array of token types which should be checked among children.
      Overrides:
      getCheckedChildren in class BlockParentHandler
      Returns:
      array of token types to check.
    • checkModifiers

      private void checkModifiers()
      Checks modifiers for class/annotation definitions.
    • checkAnnotationDefModifiers

      Checks modifiers for annotation definitions, skipping modifiers that are not at the start of the line.
    • checkClassDefModifiers

      private void checkClassDefModifiers()
      Checks modifiers for class definitions, skipping wrapped modifiers that appear on lines after the first modifier line. Annotations that wrap before the class keyword are skipped only when they are correctly indented, since a correctly indented annotation before a wrongly indented class keyword is not itself a violation.
    • checkLineModifiers

      private void checkLineModifiers(DetailAST firstModifier, int firstModifierLine)
      Checks modifiers on the first modifier line.
      Parameters:
      firstModifier - the first modifier
      firstModifierLine - line number of the first modifier
    • checkNonFirstLineModifiers

      private void checkNonFirstLineModifiers(DetailAST firstNonAnnotationMod)
      Checks modifiers on the line of the first non-annotation modifier, skipping correctly-indented annotations to avoid false positives when annotations wrap before the class keyword.
      Parameters:
      firstNonAnnotationMod - the first non-annotation modifier
    • getFirstNonAnnotationModifier

      private static DetailAST getFirstNonAnnotationModifier(DetailAST firstModifier)
      Finds the first non-annotation modifier node.
      Parameters:
      firstModifier - the first modifier in the modifiers list
      Returns:
      the first non-annotation modifier node
    • 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.