Class CaseHandler

java.lang.Object
com.puppycrawl.tools.checkstyle.checks.indentation.AbstractExpressionHandler
com.puppycrawl.tools.checkstyle.checks.indentation.CaseHandler

public class CaseHandler extends AbstractExpressionHandler
Handler for case statements.
  • Field Details

    • CASE_CHILDREN

      private static final int[] CASE_CHILDREN
      The child elements of a case expression.
  • Constructor Details

    • CaseHandler

      public CaseHandler(IndentationCheck indentCheck, DetailAST expr, AbstractExpressionHandler parent)
      Construct an instance of this handler with the given indentation check, abstract syntax tree, and parent handler.
      Parameters:
      indentCheck - the indentation check
      expr - the abstract syntax tree
      parent - the parent handler
  • Method Details

    • getIndentImpl

      protected IndentLevel getIndentImpl()
      Description copied from class: AbstractExpressionHandler
      Compute the indentation amount for this handler.
      Overrides:
      getIndentImpl in class AbstractExpressionHandler
      Returns:
      the expected indentation amount
    • checkCase

      private void checkCase()
      Check the indentation of the case statement.
    • getSuggestedChildIndent

      public IndentLevel getSuggestedChildIndent(AbstractExpressionHandler child)
      Description copied from class: AbstractExpressionHandler
      Indentation level suggested for a child element. Children don't have to respect this, but most do.
      Overrides:
      getSuggestedChildIndent in class AbstractExpressionHandler
      Parameters:
      child - child AST (so suggestion level can differ based on child type)
      Returns:
      suggested indentation for child
    • checkIndentation

      public void checkIndentation()
      Description copied from class: AbstractExpressionHandler
      Check the indentation of the expression we are handling.
      Specified by:
      checkIndentation in class AbstractExpressionHandler
    • isSameLineAsSwitch

      private boolean isSameLineAsSwitch()
      Checks if CASE_GROUP node is placed at the same line as SWITCH_LITERAL node.
      Returns:
      true, if CASE_GROUP node is places at the same line as SWITCH_LITERAL node.