Class IllegalBlockTagCheck
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.IllegalBlockTagCheck
- All Implemented Interfaces:
Configurable,Contextualizable
Detects a user-defined Javadoc block tag and reports a violation when the tag
is present with text that does not match
tagTextPattern.
With the default pattern ^$ (same as Regexp format default;
matches only empty content), any non-empty text of the configured tag is a
violation. No violation is reported when there is no Javadoc or when
tag is not configured.
- Since:
- 13.10.0
-
Nested Class Summary
Nested classes/interfaces inherited from class com.puppycrawl.tools.checkstyle.AbstractAutomaticBean
AbstractAutomaticBean.OutputStreamOptions -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate static final PatternPattern that matches only empty content (Regexp format default).static final StringA key is pointing to the warning message text in "messages.properties" file.private StringSpecify the name of tag.private PatternSpecify the regexp that tag content is allowed to match.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 TypeMethodDescriptionprivate static DetailASTfindJavadoc(DetailAST ast) Finds the Javadoc comment associated with a structural AST node.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.voidsetTagTextPattern(Pattern pattern) Setter to specify the regexp that tag content is allowed to match.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, beginJavadocTree, beginTree, destroy, finishJavadocTree, 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_ILLEGAL_PATTERN
A key is pointing to the warning message text in "messages.properties" file.- See Also:
-
MATCH_NOTHING
Pattern that matches only empty content (Regexp format default). -
tagTextPattern
Specify the regexp that tag content is allowed to match. -
tag
Specify the name of tag.
-
-
Constructor Details
-
IllegalBlockTagCheck
public IllegalBlockTagCheck()Creates a newIllegalBlockTagCheckinstance.
-
-
Method Details
-
setTag
Setter to specify the name of tag.- Parameters:
tag- tag to check- Since:
- 13.10.0
-
setTagTextPattern
Setter to specify the regexp that tag content is allowed to match. Content that does not match is treated as illegal.- Parameters:
pattern- aPatternvalue- Since:
- 13.10.0
-
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:
- 13.10.0
-
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
-
visitJavadocToken
Description copied from class:AbstractJavadocCheckCalled to process a Javadoc token.- Specified by:
visitJavadocTokenin classAbstractJavadocCheck- Parameters:
ast- the token to process
-
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
-