public class JavadocTypeCheck extends AbstractCheck
Does not perform checks for author and version tags for inner classes, as they should be redundant because of outer class.
Modifier and Type | Field and Description |
---|---|
private boolean |
allowMissingParamTags
Controls whether to ignore errors when a method has type parameters but
does not have matching param tags in the javadoc.
|
private boolean |
allowUnknownTags
Controls whether to flag errors for unknown tags.
|
private java.util.regex.Pattern |
authorFormat
Compiled regexp to match author tag content.
|
private static java.lang.String |
CLOSE_ANGLE_BRACKET
Close angle bracket literal.
|
private Scope |
excludeScope
The visibility scope where Javadoc comments shouldn't be checked.
|
static java.lang.String |
MSG_JAVADOC_MISSING
A key is pointing to the warning message text in "messages.properties"
file.
|
static java.lang.String |
MSG_MISSING_TAG
A key is pointing to the warning message text in "messages.properties"
file.
|
static java.lang.String |
MSG_TAG_FORMAT
A key is pointing to the warning message text in "messages.properties"
file.
|
static java.lang.String |
MSG_UNKNOWN_TAG
A key is pointing to the warning message text in "messages.properties"
file.
|
static java.lang.String |
MSG_UNUSED_TAG
A key is pointing to the warning message text in "messages.properties"
file.
|
static java.lang.String |
MSG_UNUSED_TAG_GENERAL
A key is pointing to the warning message text in "messages.properties"
file.
|
private static java.lang.String |
OPEN_ANGLE_BRACKET
Open angle bracket literal.
|
private Scope |
scope
The scope to check for.
|
private static java.util.regex.Pattern |
TYPE_NAME_IN_JAVADOC_TAG
Pattern to match type name within angle brackets in javadoc param tag.
|
private static java.util.regex.Pattern |
TYPE_NAME_IN_JAVADOC_TAG_SPLITTER
Pattern to split type name field in javadoc param tag.
|
private java.util.regex.Pattern |
versionFormat
Compiled regexp to match version tag content.
|
Constructor and Description |
---|
JavadocTypeCheck() |
Modifier and Type | Method and Description |
---|---|
private void |
checkTag(int lineNo,
java.util.List<JavadocTag> tags,
java.lang.String tagName,
java.util.regex.Pattern formatPattern)
Verifies that a type definition has a required tag.
|
private void |
checkTypeParamTag(int lineNo,
java.util.List<JavadocTag> tags,
java.lang.String typeParamName)
Verifies that a type definition has the specified param tag for
the specified type parameter name.
|
private void |
checkUnusedTypeParamTags(java.util.List<JavadocTag> tags,
java.util.List<java.lang.String> typeParamNames)
Checks for unused param tags for type parameters.
|
private static java.lang.String |
extractTypeParamNameFromTag(JavadocTag tag)
Extracts type parameter name from tag.
|
int[] |
getAcceptableTokens()
The configurable token set.
|
int[] |
getDefaultTokens()
Returns the default token a check is interested in.
|
private java.util.List<JavadocTag> |
getJavadocTags(TextBlock textBlock)
Gets all standalone tags from a given javadoc.
|
int[] |
getRequiredTokens()
The tokens that this check must be registered for.
|
void |
setAllowMissingParamTags(boolean flag)
Controls whether to allow a type which has type parameters to
omit matching param tags in the javadoc.
|
void |
setAllowUnknownTags(boolean flag)
Controls whether to flag errors for unknown tags.
|
void |
setAuthorFormat(java.util.regex.Pattern pattern)
Set the author tag pattern.
|
void |
setExcludeScope(Scope excludeScope)
Set the excludeScope.
|
void |
setScope(Scope scope)
Sets the scope to check.
|
void |
setVersionFormat(java.util.regex.Pattern pattern)
Set the version format pattern.
|
private boolean |
shouldCheck(DetailAST ast)
Whether we should check this node.
|
void |
visitToken(DetailAST ast)
Called to process a token.
|
beginTree, destroy, finishTree, getClassLoader, getFileContents, getLine, getLines, getTabWidth, getTokenNames, init, isCommentNodesRequired, leaveToken, log, log, setClassLoader, setFileContents, setMessages, setTabWidth, setTokens
getCustomMessages, getId, getMessageBundle, getSeverity, getSeverityLevel, log, setId, setSeverity
configure, contextualize, finishLocalSetup, getConfiguration, setupChild
public static final java.lang.String MSG_JAVADOC_MISSING
public static final java.lang.String MSG_UNKNOWN_TAG
public static final java.lang.String MSG_TAG_FORMAT
public static final java.lang.String MSG_MISSING_TAG
public static final java.lang.String MSG_UNUSED_TAG
public static final java.lang.String MSG_UNUSED_TAG_GENERAL
private static final java.lang.String OPEN_ANGLE_BRACKET
private static final java.lang.String CLOSE_ANGLE_BRACKET
private static final java.util.regex.Pattern TYPE_NAME_IN_JAVADOC_TAG
private static final java.util.regex.Pattern TYPE_NAME_IN_JAVADOC_TAG_SPLITTER
private Scope scope
private Scope excludeScope
private java.util.regex.Pattern authorFormat
private java.util.regex.Pattern versionFormat
private boolean allowMissingParamTags
private boolean allowUnknownTags
public void setScope(Scope scope)
scope
- a scope.public void setExcludeScope(Scope excludeScope)
excludeScope
- a scope.public void setAuthorFormat(java.util.regex.Pattern pattern)
pattern
- a pattern.public void setVersionFormat(java.util.regex.Pattern pattern)
pattern
- a pattern.public void setAllowMissingParamTags(boolean flag)
flag
- a Boolean
valuepublic void setAllowUnknownTags(boolean flag)
flag
- a Boolean
valuepublic int[] getDefaultTokens()
AbstractCheck
getDefaultTokens
in class AbstractCheck
TokenTypes
public int[] getAcceptableTokens()
AbstractCheck
getAcceptableTokens
in class AbstractCheck
TokenTypes
public int[] getRequiredTokens()
AbstractCheck
getRequiredTokens
in class AbstractCheck
TokenTypes
public void visitToken(DetailAST ast)
AbstractCheck
visitToken
in class AbstractCheck
ast
- the token to processprivate boolean shouldCheck(DetailAST ast)
ast
- a given node.private java.util.List<JavadocTag> getJavadocTags(TextBlock textBlock)
textBlock
- the Javadoc comment to process.private void checkTag(int lineNo, java.util.List<JavadocTag> tags, java.lang.String tagName, java.util.regex.Pattern formatPattern)
lineNo
- the line number for the type definition.tags
- tags from the Javadoc comment for the type definition.tagName
- the required tag name.formatPattern
- regexp for the tag value.private void checkTypeParamTag(int lineNo, java.util.List<JavadocTag> tags, java.lang.String typeParamName)
lineNo
- the line number for the type definition.tags
- tags from the Javadoc comment for the type definition.typeParamName
- the name of the type parameterprivate void checkUnusedTypeParamTags(java.util.List<JavadocTag> tags, java.util.List<java.lang.String> typeParamNames)
tags
- tags from the Javadoc comment for the type definition.typeParamNames
- names of type parametersprivate static java.lang.String extractTypeParamNameFromTag(JavadocTag tag)
tag
- javadoc tag to extract parameter name