Class JavadocLeadingAsteriskAlignCheck
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.JavadocLeadingAsteriskAlignCheck
- All Implemented Interfaces:
Configurable,Contextualizable
Checks the alignment of
leading asterisks in a Javadoc comment. The Check ensures that leading asterisks
are aligned vertically at the number of columns to the right of the slash ( / ) of the
opening Javadoc tag specified by the
indentation property. By default they are
aligned under the first asterisk ( * )
of opening Javadoc tag. The alignment of closing Javadoc tag ( */ ) is also checked.
If a closing Javadoc tag contains non-whitespace character before it
then it's alignment will be ignored.
If the ending javadoc line contains a leading asterisk, then that leading asterisk's alignment
will be considered, the closing Javadoc tag will be ignored.
If the opening Javadoc tag line contains leading asterisks, then that line defines
the expected alignment and the indentation property is not applied.
If you're using tabs then specify the the tab width in the tabWidth property.
- Since:
- 10.18.0
-
Nested Class Summary
Nested classes/interfaces inherited from class com.puppycrawl.tools.checkstyle.AbstractAutomaticBean
AbstractAutomaticBean.OutputStreamOptions -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate static final intDefault indentation of leading asterisks.private intSpecifies the expected column number of leading asterisks with tabs expanded.private String[]Specifies the lines of the file being processed.private intSpecify the number of columns to the right of the slash ( / ) of the opening javadoc tag at which the leading asterisks are expected.private intSpecifies the column number of the slash of the opening javadoc tag with tabs expanded.private intSpecifies the line number of starting block of the javadoc comment.static final StringA key is pointing to the warning message text in "messages.properties" file.Fields inherited from class com.puppycrawl.tools.checkstyle.checks.javadoc.AbstractJavadocCheck
MSG_JAVADOC_PARSE_RULE_ERROR, MSG_KEY_UNCLOSED_HTML_TAG -
Constructor Summary
ConstructorsConstructorDescriptionCreates a newJavadocLeadingAsteriskAlignCheckinstance. -
Method Summary
Modifier and TypeMethodDescriptionvoidbeginJavadocTree(DetailNode rootAst) Called before the starting to process a tree.voidfinishJavadocTree(DetailNode rootAst) Called after finished processing a tree.Processes and returns an OptionalInt containing the column number of leading asterisk without tabs expanded.private intReturns the tab-expanded, one-based column number of the leading asterisk node.int[]Returns the default javadoc token types a check is interested in.private intgetIndentationLevel(int columnNumberTabsExpanded) Converts a tab-expanded column number into an indentation level, which is the number of columns the given column is to the right of the slash ( / ) of the opening javadoc tag.int[]The javadoc tokens that this check must be registered for.private static booleanhasValidAlignment(int expectedColNumber, int asteriskColNumber) Checks the column difference between expected column number and leading asterisk column number.voidsetIndentation(int indentation) Setter to specify the number of columns to the right of the slash ( / ) of the opening javadoc tag at which the leading asterisks are expected.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_KEY
A key is pointing to the warning message text in "messages.properties" file.- See Also:
-
DEFAULT_INDENTATION
Default indentation of leading asterisks.- See Also:
-
javadocStartLineNumber
Specifies the line number of starting block of the javadoc comment. -
javadocStartColumnNumberTabsExpanded
Specifies the column number of the slash of the opening javadoc tag with tabs expanded. -
expectedColumnNumberTabsExpanded
Specifies the expected column number of leading asterisks with tabs expanded. -
fileLines
Specifies the lines of the file being processed. -
indentation
Specify the number of columns to the right of the slash ( / ) of the opening javadoc tag at which the leading asterisks are expected. A negative value expects the leading asterisks to the left of the slash ( / ).
-
-
Constructor Details
-
JavadocLeadingAsteriskAlignCheck
public JavadocLeadingAsteriskAlignCheck()Creates a newJavadocLeadingAsteriskAlignCheckinstance.
-
-
Method Details
-
setIndentation
Setter to specify the number of columns to the right of the slash ( / ) of the opening javadoc tag at which the leading asterisks are expected. A negative value expects the leading asterisks to the left of the slash ( / ).- Parameters:
indentation- number of columns- Since:
- 14.4.0
-
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:
-
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
-
getAsteriskColumnNumber
Processes and returns an OptionalInt containing the column number of leading asterisk without tabs expanded.- Parameters:
line- javadoc comment line- Returns:
- asterisk's column number
-
getColumnNumberTabsExpanded
Returns the tab-expanded, one-based column number of the leading asterisk node.- Parameters:
ast- leading asterisk node- Returns:
- tab-expanded column number
-
getIndentationLevel
Converts a tab-expanded column number into an indentation level, which is the number of columns the given column is to the right of the slash ( / ) of the opening javadoc tag.- Parameters:
columnNumberTabsExpanded- tab-expanded column number- Returns:
- indentation level
-
hasValidAlignment
Checks the column difference between expected column number and leading asterisk column number.- Parameters:
expectedColNumber- column number of javadoc starting tokenasteriskColNumber- column number of leading asterisk- Returns:
- true if the asterisk is aligned properly, false otherwise
-