Class WriteTagCheck
java.lang.Object
com.puppycrawl.tools.checkstyle.AbstractAutomaticBean
com.puppycrawl.tools.checkstyle.api.AbstractViolationReporter
com.puppycrawl.tools.checkstyle.api.AbstractCheck
com.puppycrawl.tools.checkstyle.checks.javadoc.AbstractJavadocCheck
com.puppycrawl.tools.checkstyle.checks.javadoc.WriteTagCheck
- All Implemented Interfaces:
Configurable,Contextualizable
Requires user defined Javadoc tag to be present in Javadoc comment with defined format.
To define the format for a tag, set property tagFormat to a regular expression.
Violations are reported only when the configured tag is missing or when the tag content
does not match tagFormat.
No violation is reported when the tag is present and matches tagFormat (or when tagFormat
is not configured).
No violation reported in case there is no javadoc.
To forbid tags instead of requiring them, use IllegalBlockTag.
- Since:
- 4.2
-
Nested Class Summary
Nested classes/interfaces inherited from class com.puppycrawl.tools.checkstyle.AbstractAutomaticBean
AbstractAutomaticBean.OutputStreamOptions -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final StringA key is pointing to the warning message text in "messages.properties" file.static final StringA key is pointing to the warning message text in "messages.properties" file.private DetailASTParent AST for the missing tag report in the current Javadoc tree.private StringSpecify the name of tag.private PatternSpecify the regexp to match tag content.private booleanWhether the target tag was found in the current Javadoc tree.Fields inherited from class com.puppycrawl.tools.checkstyle.checks.javadoc.AbstractJavadocCheck
MSG_JAVADOC_PARSE_RULE_ERROR, MSG_KEY_UNCLOSED_HTML_TAG -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidbeginJavadocTree(DetailNode rootAst) Called before the starting to process a tree.private static DetailASTfindJavadoc(DetailAST ast) Finds the Javadoc comment associated with a structural AST node.voidfinishJavadocTree(DetailNode rootAst) Called after finished processing a tree.int[]The configurable token set.int[]Returns the default javadoc token types a check is interested in.int[]Returns the default token a check is interested in.int[]The javadoc tokens that this check must be registered for.int[]The tokens that this check must be registered for.private static StringgetTagContent(DetailNode javadocBlockTagNode) Returns the raw content of the tag.voidSetter to specify the name of tag.voidsetTagFormat(Pattern pattern) Setter to specify the regexp to match tag content.voidsetViolateExecutionOnNonTightHtml(boolean shouldReportViolation) Setter to control when to print violations if the Javadoc being examined by this check violates the tight html rules defined at Tight-HTML Rules.voidCalled to process a Javadoc token.voidvisitToken(DetailAST ast) Called to process a token.Methods inherited from class com.puppycrawl.tools.checkstyle.checks.javadoc.AbstractJavadocCheck
acceptJavadocWithNonTightHtml, beginTree, destroy, getAcceptableJavadocTokens, getBlockCommentAst, init, isCommentNodesRequired, leaveJavadocToken, log, setJavadocTokensMethods inherited from class com.puppycrawl.tools.checkstyle.api.AbstractCheck
clearViolations, finishTree, getFileContents, getFilePath, getLine, getLineCodePoints, getLines, getTabWidth, getTokenNames, getViolations, leaveToken, log, log, log, setFileContents, setTabWidth, setTokensMethods inherited from class com.puppycrawl.tools.checkstyle.api.AbstractViolationReporter
finishLocalSetup, getCustomMessages, getId, getMessageBundle, getSeverity, getSeverityLevel, setId, setSeverityMethods inherited from class com.puppycrawl.tools.checkstyle.AbstractAutomaticBean
configure, contextualize, getConfiguration, setupChild
-
Field Details
-
MSG_MISSING_TAG
A key is pointing to the warning message text in "messages.properties" file.- See Also:
-
MSG_TAG_FORMAT
A key is pointing to the warning message text in "messages.properties" file.- See Also:
-
tagFormat
Specify the regexp to match tag content. -
tag
Specify the name of tag. -
tagFound
Whether the target tag was found in the current Javadoc tree. -
parentAst
Parent AST for the missing tag report in the current Javadoc tree.
-
-
Constructor Details
-
WriteTagCheck
public WriteTagCheck()Creates a newWriteTagCheckinstance.
-
-
Method Details
-
setTag
Setter to specify the name of tag.- Parameters:
tag- tag to check- Since:
- 4.2
-
setTagFormat
Setter to specify the regexp to match tag content.- Parameters:
pattern- aStringvalue- Since:
- 4.2
-
setViolateExecutionOnNonTightHtml
Setter to control when to print violations if the Javadoc being examined by this check violates the tight html rules defined at Tight-HTML Rules.- Overrides:
setViolateExecutionOnNonTightHtmlin classAbstractJavadocCheck- Parameters:
shouldReportViolation- value to which the field shall be set to- Since:
- 8.3
-
getRequiredTokens
Description copied from class:AbstractCheckThe tokens that this check must be registered for.- Overrides:
getRequiredTokensin classAbstractJavadocCheck- Returns:
- the token set this must be registered for.
- See Also:
-
getDefaultTokens
Description copied from class:AbstractCheckReturns the default token a check is interested in. Only used if the configuration for a check does not define the tokens.- Overrides:
getDefaultTokensin classAbstractJavadocCheck- Returns:
- the default tokens
- See Also:
-
getAcceptableTokens
Description copied from class:AbstractCheckThe 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.- Overrides:
getAcceptableTokensin classAbstractJavadocCheck- Returns:
- the token set this check is designed for.
- See Also:
-
getDefaultJavadocTokens
Description copied from class:AbstractJavadocCheckReturns the default javadoc token types a check is interested in.- Specified by:
getDefaultJavadocTokensin classAbstractJavadocCheck- Returns:
- the default javadoc token types
- See Also:
-
getRequiredJavadocTokens
Description copied from class:AbstractJavadocCheckThe javadoc tokens that this check must be registered for.- Overrides:
getRequiredJavadocTokensin classAbstractJavadocCheck- Returns:
- the javadoc token set this must be registered for.
- See Also:
-
visitToken
Description copied from class:AbstractCheckCalled to process a token.- Overrides:
visitTokenin classAbstractJavadocCheck- Parameters:
ast- the token to process
-
beginJavadocTree
Description copied from class:AbstractJavadocCheckCalled before the starting to process a tree.- Overrides:
beginJavadocTreein classAbstractJavadocCheck- Parameters:
rootAst- the root of the tree
-
visitJavadocToken
Description copied from class:AbstractJavadocCheckCalled to process a Javadoc token.- Specified by:
visitJavadocTokenin classAbstractJavadocCheck- Parameters:
ast- the token to process
-
finishJavadocTree
Description copied from class:AbstractJavadocCheckCalled after finished processing a tree.- Overrides:
finishJavadocTreein classAbstractJavadocCheck- Parameters:
rootAst- the root of the tree
-
getTagContent
Returns the raw content of the tag.- Parameters:
javadocBlockTagNode- The node representing a Javadoc block tag. This node must be of typeJavadocCommentsTokenTypes.JAVADOC_BLOCK_TAG- Returns:
- The raw content of the tag.
-
findJavadoc
Finds the Javadoc comment associated with a structural AST node.- Parameters:
ast- the structural node (e.g., CLASS_DEF, METHOD_DEF)- Returns:
- the Javadoc block comment if found, or null
-