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

    • MSG_ERROR

      static final String MSG_ERROR
      Message key for an indentation error.
      See Also:
    • MSG_ERROR_MULTI

      static final String MSG_ERROR_MULTI
      Message key for a multi-level indentation error.
      See Also:
    • MSG_CHILD_ERROR

      static final String MSG_CHILD_ERROR
      Message key for a child indentation error.
      See Also:
    • MSG_CHILD_ERROR_MULTI

      static final String MSG_CHILD_ERROR_MULTI
      Message key for a multi-level child indentation error.
      See Also:
    • basicOffset

      private final int basicOffset
      Basic offset property value.
    • braceAdjustment

      private final int braceAdjustment
      Brace adjustment property value.
    • caseIndent

      private final int caseIndent
      Case indent property value.
    • throwsIndent

      private final int throwsIndent
      Throws indent property value.
    • arrayInitIndent

      private final int arrayInitIndent
      Array initialization indent property value.
    • lineWrappingIndentation

      private final int lineWrappingIndentation
      Line wrapping indentation property value.
    • forceStrictCondition

      private final boolean forceStrictCondition
      Force-strict-condition property value.
    • indentationTabWidth

      private final int indentationTabWidth
      Tab width used for expanded-tabs column calculations.
    • lineProvider

      private final IntFunction<String> lineProvider
      Provides a source line by zero-based index.
    • handlerFactory

      private final HandlerFactory handlerFactory
      Factory that creates handlers for AST nodes.
    • lineWrappingHandler

      private final LineWrappingHandler lineWrappingHandler
      Shared line-wrapping handler used by expression handlers.
    • logger

      private final IndentationLogger logger
      Sink for indentation violations.
  • 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

      int getBasicOffset()
      Get the basic offset property.
      Returns:
      basic offset
    • getBraceAdjustment

      int getBraceAdjustment()
      Get the brace adjustment property.
      Returns:
      brace adjustment
    • getCaseIndent

      int getCaseIndent()
      Get the case indent property.
      Returns:
      case indent
    • getThrowsIndent

      int getThrowsIndent()
      Get the throws indent property.
      Returns:
      throws indent
    • getArrayInitIndent

      int getArrayInitIndent()
      Get the array-init indent property.
      Returns:
      array-init indent
    • getLineWrappingIndentation

      int getLineWrappingIndentation()
      Get the line-wrapping indentation property.
      Returns:
      line-wrapping indent
    • isForceStrictCondition

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

      int 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

      HandlerFactory getHandlerFactory()
      Get the shared handler factory.
      Returns:
      handler factory
    • getLineWrappingHandler

      LineWrappingHandler 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