Class JavadocRegexpCheck
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.JavadocRegexpCheck
- All Implemented Interfaces:
Configurable,Contextualizable
Checks that Javadoc comments do not match a configured regular expression.
The check can operate on raw Javadoc source or on the text visible to readers. Raw matching includes Javadoc tags, HTML tags, HTML attributes, and formatting characters. Visible-text matching ignores markup and matches only Javadoc text content.
- 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 StringSpecify the regular expression to match forbidden Javadoc content.private booleanControl whether to ignore case when matching.private booleanControl whether to ignore Javadoc and HTML markup when matching.static final StringA key is pointing to the warning message text in "messages.properties" file.private intLine number of the previous collected text node.Text fragments visible to readers of the current Javadoc comment.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 voidappendVisibleText(DetailNode textNode) Appends visible text from a Javadoc text node.voidbeginJavadocTree(DetailNode rootAst) Called before the starting to process a tree.private PatternCreates the regexp based onformatandignoreCase.voidfinishJavadocTree(DetailNode rootAst) Called after finished processing a tree.int[]Returns the default javadoc token types a check is interested in.int[]The javadoc tokens that this check must be registered for.private static booleanisIgnoredText(DetailNode textNode) Checks whether a text node belongs to a non-rendered HTML comment.voidSetter to specify the regular expression to match forbidden Javadoc content.voidsetIgnoreCase(boolean ignoreCase) Setter to control whether to ignore case when matching.voidsetIgnoreMarkup(boolean ignoreMarkup) Setter to control whether to ignore Javadoc and HTML markup when matching.voidCalled to process a Javadoc token.Methods inherited from class com.puppycrawl.tools.checkstyle.checks.javadoc.AbstractJavadocCheck
acceptJavadocWithNonTightHtml, beginTree, destroy, getAcceptableJavadocTokens, getAcceptableTokens, getBlockCommentAst, getDefaultTokens, getRequiredTokens, init, isCommentNodesRequired, leaveJavadocToken, log, setJavadocTokens, setViolateExecutionOnNonTightHtml, visitTokenMethods 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_JAVADOC_REGEXP
A key is pointing to the warning message text in "messages.properties" file.- See Also:
-
visibleText
Text fragments visible to readers of the current Javadoc comment. -
format
Specify the regular expression to match forbidden Javadoc content. -
ignoreCase
Control whether to ignore case when matching. -
ignoreMarkup
Control whether to ignore Javadoc and HTML markup when matching. -
previousTextLineNumber
Line number of the previous collected text node.
-
-
Constructor Details
-
JavadocRegexpCheck
public JavadocRegexpCheck()Creates a newJavadocRegexpCheckinstance.
-
-
Method Details
-
setFormat
Setter to specify the regular expression to match forbidden Javadoc content.- Parameters:
format- regular expression to match forbidden Javadoc content.- Since:
- 13.10.0
-
setIgnoreCase
Setter to control whether to ignore case when matching.- Parameters:
ignoreCase- whether to ignore case when matching.- Since:
- 13.10.0
-
setIgnoreMarkup
Setter to control whether to ignore Javadoc and HTML markup when matching.- Parameters:
ignoreMarkup- whether to ignore Javadoc and HTML markup when matching.- Since:
- 13.10.0
-
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:
-
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:
-
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
-
createRegexp
Creates the regexp based onformatandignoreCase.- Returns:
- pattern used to find forbidden content.
-
appendVisibleText
Appends visible text from a Javadoc text node.- Parameters:
textNode- text node to append.
-
isIgnoredText
Checks whether a text node belongs to a non-rendered HTML comment.- Parameters:
textNode- text node to check.- Returns:
trueif the text node should be ignored.
-