Class AbstractCheck
java.lang.Object
com.puppycrawl.tools.checkstyle.AbstractAutomaticBean
com.puppycrawl.tools.checkstyle.api.AbstractViolationReporter
com.puppycrawl.tools.checkstyle.api.AbstractCheck
- All Implemented Interfaces:
- Configurable,- Contextualizable
- Direct Known Subclasses:
- AbbreviationAsWordInNameCheck,- AbstractClassCouplingCheck,- AbstractClassNameCheck,- AbstractJavadocCheck,- AbstractNameCheck,- AbstractParenPadCheck,- AbstractSuperCheck,- AnnotationLocationCheck,- AnnotationOnSameLineCheck,- AnnotationUseStyleCheck,- AnonInnerLengthCheck,- ArrayTrailingCommaCheck,- ArrayTypeStyleCheck,- AvoidDoubleBraceInitializationCheck,- AvoidEscapedUnicodeCharactersCheck,- AvoidInlineConditionalsCheck,- AvoidNestedBlocksCheck,- AvoidNoArgumentSuperConstructorCallCheck,- AvoidStarImportCheck,- AvoidStaticImportCheck,- BooleanExpressionComplexityCheck,- ClassMemberImpliedModifierCheck,- CommentsIndentationCheck,- ConstructorsDeclarationGroupingCheck,- CovariantEqualsCheck,- CustomImportOrderCheck,- CyclomaticComplexityCheck,- DeclarationOrderCheck,- DefaultComesLastCheck,- DescendantTokenCheck,- DesignForExtensionCheck,- EmptyBlockCheck,- EmptyCatchBlockCheck,- EmptyForInitializerPadCheck,- EmptyForIteratorPadCheck,- EmptyLineSeparatorCheck,- EmptyStatementCheck,- EqualsAvoidNullCheck,- EqualsHashCodeCheck,- ExecutableStatementCountCheck,- ExplicitInitializationCheck,- FallThroughCheck,- FinalClassCheck,- FinalLocalVariableCheck,- FinalParametersCheck,- GenericWhitespaceCheck,- HiddenFieldCheck,- HideUtilityClassConstructorCheck,- IllegalCatchCheck,- IllegalImportCheck,- IllegalInstantiationCheck,- IllegalThrowsCheck,- IllegalTokenCheck,- IllegalTokenTextCheck,- IllegalTypeCheck,- ImportControlCheck,- ImportOrderCheck,- IndentationCheck,- InnerAssignmentCheck,- InnerTypeLastCheck,- InterfaceIsTypeCheck,- InterfaceMemberImpliedModifierCheck,- InvalidJavadocPositionCheck,- JavadocContentLocationCheck,- JavadocMethodCheck,- JavadocStyleCheck,- JavadocTypeCheck,- JavadocVariableCheck,- JavaNCSSCheck,- LambdaBodyLengthCheck,- LeftCurlyCheck,- MagicNumberCheck,- MatchXpathCheck,- MethodCountCheck,- MethodLengthCheck,- MethodParamPadCheck,- MissingCtorCheck,- MissingJavadocMethodCheck,- MissingJavadocPackageCheck,- MissingJavadocTypeCheck,- MissingNullCaseInSwitchCheck,- MissingOverrideCheck,- MissingSwitchDefaultCheck,- ModifiedControlVariableCheck,- ModifierOrderCheck,- MultipleStringLiteralsCheck,- MultipleVariableDeclarationsCheck,- MutableExceptionCheck,- NeedBracesCheck,- NestedForDepthCheck,- NestedIfDepthCheck,- NestedTryDepthCheck,- NoArrayTrailingCommaCheck,- NoCloneCheck,- NoCodeInFileCheck,- NoEnumTrailingCommaCheck,- NoFinalizerCheck,- NoLineWrapCheck,- NoWhitespaceAfterCheck,- NoWhitespaceBeforeCaseDefaultColonCheck,- NoWhitespaceBeforeCheck,- NPathComplexityCheck,- OneStatementPerLineCheck,- OneTopLevelClassCheck,- OperatorWrapCheck,- OuterTypeFilenameCheck,- OuterTypeNumberCheck,- OverloadMethodsDeclarationOrderCheck,- PackageAnnotationCheck,- PackageDeclarationCheck,- PackageNameCheck,- ParameterAssignmentCheck,- ParameterNumberCheck,- PatternVariableAssignmentCheck,- RecordComponentNumberCheck,- RedundantImportCheck,- RedundantModifierCheck,- RegexpCheck,- RegexpSinglelineJavaCheck,- RequireThisCheck,- ReturnCountCheck,- RightCurlyCheck,- SealedShouldHavePermitsListCheck,- SeparatorWrapCheck,- SimplifyBooleanExpressionCheck,- SimplifyBooleanReturnCheck,- SingleSpaceSeparatorCheck,- StringLiteralEqualityCheck,- SuppressWarningsCheck,- SuppressWarningsHolder,- ThrowsCountCheck,- TodoCommentCheck,- TrailingCommentCheck,- UncommentedMainCheck,- UnnecessaryNullCheckWithInstanceOfCheck,- UnnecessaryParenthesesCheck,- UnnecessarySemicolonAfterOuterTypeDeclarationCheck,- UnnecessarySemicolonAfterTypeMemberDeclarationCheck,- UnnecessarySemicolonInEnumerationCheck,- UnnecessarySemicolonInTryWithResourcesCheck,- UnusedCatchParameterShouldBeUnnamedCheck,- UnusedImportsCheck,- UnusedLambdaParameterShouldBeUnnamedCheck,- UnusedLocalVariableCheck,- UpperEllCheck,- VariableDeclarationUsageDistanceCheck,- VisibilityModifierCheck,- WhenShouldBeUsedCheck,- WhitespaceAfterCheck,- WhitespaceAroundCheck,- WriteTagCheck
The base class for checks.
- See Also:
- 
Nested Class SummaryNested ClassesModifier and TypeClassDescriptionprivate static final classThe actual context holder.Nested classes/interfaces inherited from class com.puppycrawl.tools.checkstyle.AbstractAutomaticBeanAbstractAutomaticBean.OutputStreamOptions
- 
Field SummaryFieldsModifier and TypeFieldDescriptionprivate final ThreadLocal<AbstractCheck.FileContext>The check context.private intThe tab width for column reporting.The tokens the check is interested in.
- 
Constructor SummaryConstructors
- 
Method SummaryModifier and TypeMethodDescriptionvoidCalled before the starting to process a tree.final voidClears the sorted set ofViolationof the check.voiddestroy()Destroy the check.voidfinishTree(DetailAST rootAST) Called after finished processing a tree.abstract int[]The configurable token set.abstract int[]Returns the default token a check is interested in.final FileContentsDeprecated.Usage of this method is no longer accepted.final StringReturns full path to the file.final StringgetLine(int index) Returns the line associated with the tree.final int[]getLineCodePoints(int index) Returns code point representation of file text from given line number.final String[]getLines()Returns the lines associated with the tree.abstract int[]The tokens that this check must be registered for.protected final intGet tab width to report audit events with.Returns the tokens registered for the check.Returns the sorted set ofViolation.voidinit()Initialize the check.booleanWhether comment nodes are required or not.voidleaveToken(DetailAST ast) Called after all the child nodes have been process.final voidLog a message that has column information.final voidLog a message that has no column information.final voidHelper method to log a Violation.final voidsetFileContents(FileContents contents) Set the file contents associated with the tree.final voidsetTabWidth(int tabWidth) Set the tab width to report audit events with.final voidAdds a set of tokens the check is interested in.voidvisitToken(DetailAST ast) Called to process a token.Methods inherited from class com.puppycrawl.tools.checkstyle.api.AbstractViolationReporterfinishLocalSetup, getCustomMessages, getId, getMessageBundle, getSeverity, getSeverityLevel, setId, setSeverityMethods inherited from class com.puppycrawl.tools.checkstyle.AbstractAutomaticBeanconfigure, contextualize, getConfiguration, setupChild
- 
Field Details- 
contextThe check context.
- 
tokensThe tokens the check is interested in.
- 
tabWidthThe tab width for column reporting. Default is uninitialized as the value is inherited from the parent module.
 
- 
- 
Constructor Details- 
AbstractCheckpublic AbstractCheck()
 
- 
- 
Method Details- 
getDefaultTokensReturns the default token a check is interested in. Only used if the configuration for a check does not define the tokens.- Returns:
- the default tokens
- See Also:
 
- 
getAcceptableTokensThe configurable token set. Used to protect Checks against malicious users who specify an unacceptable token set in the configuration file. The default implementation returns the check's default tokens.- Returns:
- the token set this check is designed for.
- See Also:
 
- 
getRequiredTokensThe tokens that this check must be registered for.- Returns:
- the token set this must be registered for.
- See Also:
 
- 
isCommentNodesRequiredWhether comment nodes are required or not.- Returns:
- false as a default value.
 
- 
setTokensAdds a set of tokens the check is interested in.- Parameters:
- strRep- the string representation of the tokens interested in
 
- 
getTokenNamesReturns the tokens registered for the check.- Returns:
- the set of token names
 
- 
getViolationsReturns the sorted set ofViolation.- Returns:
- the sorted set of Violation.
 
- 
clearViolationsClears the sorted set ofViolationof the check.
- 
initInitialize the check. This is the time to verify that the check has everything required to perform its job.
- 
destroyDestroy the check. It is being retired from service.
- 
beginTreeCalled before the starting to process a tree. Ideal place to initialize information that is to be collected whilst processing a tree.- Parameters:
- rootAST- the root of the tree
 
- 
finishTreeCalled after finished processing a tree. Ideal place to report on information collected whilst processing a tree.- Parameters:
- rootAST- the root of the tree
 
- 
visitTokenCalled to process a token.- Parameters:
- ast- the token to process
 
- 
leaveTokenCalled after all the child nodes have been process.- Parameters:
- ast- the token leaving
 
- 
setFileContentsSet the file contents associated with the tree.- Parameters:
- contents- the manager
 
- 
getFileContentsDeprecated.Usage of this method is no longer accepted. Please use AST based methods instead.Returns the file contents associated with the tree.- Returns:
- the file contents
 
- 
getTabWidthGet tab width to report audit events with.- Returns:
- the tab width to audit events with
 
- 
setTabWidthSet the tab width to report audit events with.- Parameters:
- tabWidth- an- intvalue
 
- 
logDescription copied from class:AbstractViolationReporterLog a message that has no column information.- Specified by:
- login class- AbstractViolationReporter
- Parameters:
- line- the line number where the audit event was found
- key- the message that describes the audit event
- args- the details of the message
- See Also:
 
- 
logDescription copied from class:AbstractViolationReporterLog a message that has column information.- Specified by:
- login class- AbstractViolationReporter
- Parameters:
- lineNo- the line number where the audit event was found
- colNo- the column number where the audit event was found
- key- the message that describes the audit event
- args- the details of the message
- See Also:
 
- 
logHelper method to log a Violation.- Parameters:
- ast- a node to get line id column numbers associated with the violation
- key- key to locale violation format
- args- arguments to format
 
- 
getLinesReturns the lines associated with the tree.- Returns:
- the file contents
 
- 
getLineReturns the line associated with the tree.- Parameters:
- index- index of the line
- Returns:
- the line from the file contents
 
- 
getFilePathReturns full path to the file.- Returns:
- full path to file.
 
- 
getLineCodePointsReturns code point representation of file text from given line number.- Parameters:
- index- index of the line
- Returns:
- the array of Unicode code points
 
 
-