Class JavadocParamOrderCheck
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.JavadocParamOrderCheck
- All Implemented Interfaces:
Configurable,Contextualizable
Checks that
@param tags in Javadoc comments are in the same order as the
parameters in the declaration.
Type parameters must come before regular parameters. For record declarations, record components are treated as regular parameters and must be documented after type parameters. For compact constructors, the expected parameter order is the order of the record components in the record declaration.
The check does not validate missing, extra, or duplicate @param tags. It reports only
tags that move backward in the declaration order.
- Since:
- 14.1.0
-
Nested Class Summary
Nested classes/interfaces inherited from class com.puppycrawl.tools.checkstyle.AbstractAutomaticBean
AbstractAutomaticBean.OutputStreamOptions -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate static final StringHtml element end symbol.private static final StringHtml element start symbol.private final Map<DetailNode, String> Javadoc param tag names, mapped by their corresponding Javadoc node.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
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprivate static voidaddParameterName(Collection<String> paramNames, DetailAST paramDef) Adds a parameter name from the supplied parameter definition AST node.private static voidaddParameterNames(Collection<String> paramNames, DetailAST ast) Adds parameter names from the supplied method or constructor AST node.private static voidaddRecordComponentNames(Collection<String> paramNames, DetailAST recordDef) Adds record component names from the supplied record AST node.private static voidaddTypeParameterNames(Collection<String> paramNames, DetailAST ast) Adds type parameter names from the supplied AST node.private voidcollectParam(DetailNode ast) Collects a param tag.int[]Returns the default javadoc token types a check is interested in.int[]Returns the default token a check is interested in.Gets expected param tag order for the current AST node.private List<Map.Entry<DetailNode, String>> Gets collected Javadoc param tags that violate the expected declaration order.getRecordComponents(DetailAST recordDef) Gets record component identifier nodes from a record definition.private static DetailASTgetRecordDef(DetailAST ast) Finds the nearest ancestor record definition node for the given AST node.int[]The javadoc tokens that this check must be registered for.final int[]The tokens that this check must be registered for.voidCalled to process a Javadoc token.final 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, getAcceptableTokens, getBlockCommentAst, init, isCommentNodesRequired, leaveJavadocToken, log, setJavadocTokens, setViolateExecutionOnNonTightHtmlMethods 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:
-
ELEMENT_START
Html element start symbol.- See Also:
-
ELEMENT_END
Html element end symbol.- See Also:
-
javadocTags
Javadoc param tag names, mapped by their corresponding Javadoc node.
-
-
Constructor Details
-
JavadocParamOrderCheck
public JavadocParamOrderCheck()Creates a newJavadocParamOrderCheckinstance.
-
-
Method Details
-
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:
-
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:
-
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
-
collectParam
Collects a param tag.- Parameters:
ast- the param tag node
-
getMisorderedParamTags
Gets collected Javadoc param tags that violate the expected declaration order.- Parameters:
ast- Java AST node whose Javadoc is being checked- Returns:
- collected Javadoc param tags that violate the expected declaration order
-
getExpectedParamOrder
Gets expected param tag order for the current AST node.- Parameters:
ast- Java AST node whose Javadoc is being checked- Returns:
- expected param tag order
-
addTypeParameterNames
Adds type parameter names from the supplied AST node.- Parameters:
paramNames- destination listast- node to inspect
-
addParameterNames
Adds parameter names from the supplied method or constructor AST node.- Parameters:
paramNames- destination listast- node to inspect
-
addParameterName
Adds a parameter name from the supplied parameter definition AST node.- Parameters:
paramNames- destination listparamDef- parameter definition node
-
addRecordComponentNames
Adds record component names from the supplied record AST node.- Parameters:
paramNames- destination listrecordDef- record definition node
-
getRecordDef
Finds the nearest ancestor record definition node for the given AST node.- Parameters:
ast- the AST node to start searching from- Returns:
- the nearest
RECORD_DEFAST node
-
getRecordComponents
Gets record component identifier nodes from a record definition.- Parameters:
recordDef- record definition node- Returns:
- record component identifier nodes
-