Class IndentationContext
java.lang.Object
com.puppycrawl.tools.checkstyle.checks.indentation.IndentationContext
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 Summary
FieldsModifier and TypeFieldDescriptionprivate final intArray initialization indent property value.private final intBasic offset property value.private final intBrace adjustment property value.private final intCase indent property value.private final booleanForce-strict-condition property value.private final HandlerFactoryFactory that creates handlers for AST nodes.private final intTab width used for expanded-tabs column calculations.private final IntFunction<String> Provides a source line by zero-based index.private final LineWrappingHandlerShared line-wrapping handler used by expression handlers.private final intLine wrapping indentation property value.private final IndentationLoggerSink for indentation violations.(package private) static final StringMessage key for a child indentation error.(package private) static final StringMessage key for a multi-level child indentation error.(package private) static final StringMessage key for an indentation error.(package private) static final StringMessage key for a multi-level indentation error.private final intThrows indent property value. -
Constructor Summary
ConstructorsConstructorDescriptionIndentationContext(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. -
Method Summary
Modifier and TypeMethodDescription(package private) intGet the array-init indent property.(package private) intGet the basic offset property.(package private) intGet the brace adjustment property.(package private) intGet the case indent property.(package private) HandlerFactoryGet the shared handler factory.(package private) intGet the tab width used for expanded-tabs column math.(package private) StringgetLine(int lineIndex) Get a source line by zero-based index.(package private) LineWrappingHandlerGet the shared line-wrapping handler.(package private) intGet the line-wrapping indentation property.(package private) intGet the throws indent property.(package private) voidindentationLog(DetailAST ast, String messageKey, Object... args) Report an indentation violation for the given AST.(package private) booleanGet the force-strict-condition property.
-
Field Details
-
MSG_ERROR
Message key for an indentation error.- See Also:
-
MSG_ERROR_MULTI
Message key for a multi-level indentation error.- See Also:
-
MSG_CHILD_ERROR
Message key for a child indentation error.- See Also:
-
MSG_CHILD_ERROR_MULTI
Message key for a multi-level child indentation error.- See Also:
-
basicOffset
Basic offset property value. -
braceAdjustment
Brace adjustment property value. -
caseIndent
Case indent property value. -
throwsIndent
Throws indent property value. -
arrayInitIndent
Array initialization indent property value. -
lineWrappingIndentation
Line wrapping indentation property value. -
forceStrictCondition
Force-strict-condition property value. -
indentationTabWidth
Tab width used for expanded-tabs column calculations. -
lineProvider
Provides a source line by zero-based index. -
handlerFactory
Factory that creates handlers for AST nodes. -
lineWrappingHandler
Shared line-wrapping handler used by expression handlers. -
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 propertybraceAdjustment- brace adjustment propertycaseIndent- case indent propertythrowsIndent- throws indent propertyarrayInitIndent- array-init indent propertylineWrappingIndentation- line-wrapping indent propertyforceStrictCondition- force-strict-condition propertyindentationTabWidth- tab width for expanded-tabs mathlineProvider- zero-based source line accessorhandlerFactory- factory for AST handlerslineWrappingHandler- shared line-wrapping handlerlogger- 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
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
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
Report an indentation violation for the given AST.- Parameters:
ast- the AST that caused the violationmessageKey- the message keyargs- message arguments
-