Class IndentationContext

java.lang.Object
com.puppycrawl.tools.checkstyle.checks.indentation.IndentationContext

public final class IndentationContext extends Object
Immutable view of everything an indentation handler needs from the surrounding IndentationCheck, so handlers do not hold a direct reference back to the check.
  • Field Details

  • Constructor Details

    • IndentationContext

      IndentationContext(int basicOffset, int braceAdjustment, int caseIndent, int throwsIndent, int arrayInitIndent, int lineWrappingIndentation, boolean forceStrictCondition, int indentationTabWidth, IntFunction<String> lineProvider, HandlerFactory handlerFactory, LineWrappingHandler lineWrappingHandler, IndentationLogger logger)
      Construct a context with all values handlers need for one file.
      Parameters:
      basicOffset - basic offset property
      braceAdjustment - brace adjustment property
      caseIndent - case indent property
      throwsIndent - throws indent property
      arrayInitIndent - array-init indent property
      lineWrappingIndentation - line-wrapping indent property
      forceStrictCondition - force-strict-condition property
      indentationTabWidth - tab width for expanded-tabs math
      lineProvider - zero-based source line accessor
      handlerFactory - factory for AST handlers
      lineWrappingHandler - shared line-wrapping handler
      logger - sink for violations
  • Method Details

    • getBasicOffset

      Get the basic offset property.
      Returns:
      basic offset
    • getBraceAdjustment

      Get the brace adjustment property.
      Returns:
      brace adjustment
    • getCaseIndent

      Get the case indent property.
      Returns:
      case indent
    • getThrowsIndent

      Get the throws indent property.
      Returns:
      throws indent
    • getArrayInitIndent

      Get the array-init indent property.
      Returns:
      array-init indent
    • getLineWrappingIndentation

      Get the line-wrapping indentation property.
      Returns:
      line-wrapping indent
    • isForceStrictCondition

      Get the force-strict-condition property.
      Returns:
      true when strict line-wrap indent is enforced
    • getIndentationTabWidth

      Get the tab width used for expanded-tabs column math.
      Returns:
      tab width
    • getLine

      String getLine(int lineIndex)
      Get a source line by zero-based index.
      Parameters:
      lineIndex - zero-based line index
      Returns:
      the source line
    • getHandlerFactory

      Get the shared handler factory.
      Returns:
      handler factory
    • getLineWrappingHandler

      Get the shared line-wrapping handler.
      Returns:
      line-wrapping handler
    • indentationLog

      void indentationLog(DetailAST ast, String messageKey, Object... args)
      Report an indentation violation for the given AST.
      Parameters:
      ast - the AST that caused the violation
      messageKey - the message key
      args - message arguments