|
|||||||||
| Home >> All >> com >> puppycrawl >> tools >> checkstyle >> checks >> [ javadoc overview ] | PREV CLASS NEXT CLASS | ||||||||
SUMMARY: JAVADOC | SOURCE | DOWNLOAD | NESTED | FIELD | CONSTR | METHOD |
DETAIL: FIELD | CONSTR | METHOD | ||||||||
com.puppycrawl.tools.checkstyle.checks.javadoc
Class JavadocStyleCheck

java.lang.Objectcom.puppycrawl.tools.checkstyle.api.AutomaticBean
com.puppycrawl.tools.checkstyle.api.AbstractViolationReporter
com.puppycrawl.tools.checkstyle.api.Check
com.puppycrawl.tools.checkstyle.checks.javadoc.JavadocStyleCheck
- All Implemented Interfaces:
- com.puppycrawl.tools.checkstyle.api.Configurable, com.puppycrawl.tools.checkstyle.api.Contextualizable
- public class JavadocStyleCheck
- extends com.puppycrawl.tools.checkstyle.api.Check
Custom Checkstyle Check to validate Javadoc. The following checks are performed:
- Ensures the first sentence ends with proper punctuation (That is a period, question mark, or exclaimation mark). Javadoc automatically places the first sentence in the method summary table and index. With out proper punctuation the Javadoc may be malformed.
- Check text for incomplete html tags. Verifies that HTML tags have corresponding end tags and issues an UNCLOSED_HTML error if not. An EXTRA_HTML error is issued if an end tag is found without a previous open tag.
These checks were patterned after the checks made by the doclet
com.sun.tools.doclets.doccheck.DocCheck
- Version:
- 1.1
| Field Summary | |
private static java.lang.String |
EXTRA_HTML
Message property key for the Extra HTML message. |
private boolean |
mCheckFirstSentence
Indicates if the first sentence should be checked for proper end of sentence punctuation. |
private boolean |
mCheckHtml
Indicates if the HTML within the comment should be checked. |
private org.apache.regexp.RE |
mEndOfSentenceRE
Regular expression for matching the end of a sentence. |
private com.puppycrawl.tools.checkstyle.api.Scope |
mScope
The scope to check. |
private static java.lang.String[] |
SINGLE_TAG
HTML tags that do not require a close tag. |
private static java.lang.String |
UNCLOSED_HTML
Message property key for the Unclosed HTML message. |
| Fields inherited from class com.puppycrawl.tools.checkstyle.api.Check |
|
| Fields inherited from class com.puppycrawl.tools.checkstyle.api.AbstractViolationReporter |
|
| Fields inherited from class com.puppycrawl.tools.checkstyle.api.AutomaticBean |
|
| Constructor Summary | |
JavadocStyleCheck()
|
|
| Method Summary | |
private void |
checkComment(com.puppycrawl.tools.checkstyle.api.DetailAST aAST,
java.lang.String[] aComment)
Performs the various checks agains the Javadoc comment. |
private void |
checkFirstSentence(com.puppycrawl.tools.checkstyle.api.DetailAST aAST,
java.lang.String[] aComment)
Checks that the first sentence ends with proper puctuation. |
private void |
checkHtml(com.puppycrawl.tools.checkstyle.api.DetailAST aAST,
java.lang.String[] aComment)
Checks the comment for HTML tags that do not have a corresponding close tag or a close tage that has no previous open tag. |
private void |
checkUnclosedTags(java.util.Stack aHtmlStack,
java.lang.String aToken)
Checks to see if there are any unclosed tags on the stack. |
private int |
findTextStart(java.lang.String aLine)
Finds the index of the first non-whitespace character ignoring the Javadoc comment start and end strings (/** and */) as well as any leading asterisk. |
private java.lang.String |
getCommentText(java.lang.String[] aComments)
Returns the comment text from the Javadoc. |
int[] |
getDefaultTokens()
The default tokens this Check is used for. |
private org.apache.regexp.RE |
getEndOfSentenceRE()
Returns a regular expression for matching the end of a sentence. |
private boolean |
isExtraHtml(java.lang.String aToken,
java.util.Stack aHtmlStack)
Determines if the given token is an extra HTML tag. |
private boolean |
isSingleTag(HtmlTag aTag)
Determines if the HtmlTag is one which does not require a close tag. |
void |
setCheckFirstSentence(boolean aFlag)
Sets the flag that determines if the first sentence is checked for proper end of sentence punctuation. |
void |
setCheckHtml(boolean aFlag)
Sets the flag that determines if HTML checking is to be performed. |
void |
setScope(java.lang.String aFrom)
Sets the scope to check. |
private void |
trimTail(java.lang.StringBuffer aBuffer)
Trims any trailing whitespace or the end of Javadoc comment string. |
void |
visitToken(com.puppycrawl.tools.checkstyle.api.DetailAST aAST)
Called to process a token. |
| Methods inherited from class com.puppycrawl.tools.checkstyle.api.Check |
beginTree, destroy, finishTree, getAcceptableTokens, getClassLoader, getFileContents, getLines, getRequiredTokens, getTabWidth, getTokenNames, init, leaveToken, log, log, setClassLoader, setFileContents, setMessages, setTabWidth, setTokens |
| Methods inherited from class com.puppycrawl.tools.checkstyle.api.AbstractViolationReporter |
getMessageBundle, getSeverity, getSeverityLevel, log, log, log, log, log, log, setSeverity |
| Methods inherited from class com.puppycrawl.tools.checkstyle.api.AutomaticBean |
configure, contextualize, finishLocalSetup, getConfiguration, setupChild |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
UNCLOSED_HTML
private static final java.lang.String UNCLOSED_HTML
- Message property key for the Unclosed HTML message.
- See Also:
- Constant Field Values
EXTRA_HTML
private static final java.lang.String EXTRA_HTML
- Message property key for the Extra HTML message.
- See Also:
- Constant Field Values
SINGLE_TAG
private static final java.lang.String[] SINGLE_TAG
- HTML tags that do not require a close tag.
mScope
private com.puppycrawl.tools.checkstyle.api.Scope mScope
- The scope to check.
mEndOfSentenceRE
private org.apache.regexp.RE mEndOfSentenceRE
- Regular expression for matching the end of a sentence.
mCheckFirstSentence
private boolean mCheckFirstSentence
- Indicates if the first sentence should be checked for proper end of
sentence punctuation.
mCheckHtml
private boolean mCheckHtml
- Indicates if the HTML within the comment should be checked.
| Constructor Detail |
JavadocStyleCheck
public JavadocStyleCheck()
| Method Detail |
getDefaultTokens
public int[] getDefaultTokens()
- The default tokens this Check is used for.
visitToken
public void visitToken(com.puppycrawl.tools.checkstyle.api.DetailAST aAST)
- Called to process a token.
checkComment
private void checkComment(com.puppycrawl.tools.checkstyle.api.DetailAST aAST, java.lang.String[] aComment)
- Performs the various checks agains the Javadoc comment.
checkFirstSentence
private void checkFirstSentence(com.puppycrawl.tools.checkstyle.api.DetailAST aAST, java.lang.String[] aComment)
- Checks that the first sentence ends with proper puctuation. This method
uses a regular expression that checks for the presence of a period,
question mark, or exclaimation mark followed either by whitespace, an
HTML element, or the end of string. This method ignores null
comments.
getCommentText
private java.lang.String getCommentText(java.lang.String[] aComments)
- Returns the comment text from the Javadoc.
findTextStart
private int findTextStart(java.lang.String aLine)
- Finds the index of the first non-whitespace character ignoring the
Javadoc comment start and end strings (/** and */) as well as any
leading asterisk.
trimTail
private void trimTail(java.lang.StringBuffer aBuffer)
- Trims any trailing whitespace or the end of Javadoc comment string.
checkHtml
private void checkHtml(com.puppycrawl.tools.checkstyle.api.DetailAST aAST, java.lang.String[] aComment)
- Checks the comment for HTML tags that do not have a corresponding close
tag or a close tage that has no previous open tag. This code was
primarily copied from the DocCheck checkHtml method.
checkUnclosedTags
private void checkUnclosedTags(java.util.Stack aHtmlStack, java.lang.String aToken)
- Checks to see if there are any unclosed tags on the stack. The token
represents a html tag that has been closed and has a corresponding open
tag on the stack. Any tags, except single tags, that were opened
(pushed on the stack) after the token are missing a close.
isSingleTag
private boolean isSingleTag(HtmlTag aTag)
- Determines if the HtmlTag is one which does not require a close tag.
isExtraHtml
private boolean isExtraHtml(java.lang.String aToken, java.util.Stack aHtmlStack)
- Determines if the given token is an extra HTML tag. This indicates that
a close tag was found that does not have a corresponding open tag.
setScope
public void setScope(java.lang.String aFrom)
- Sets the scope to check.
getEndOfSentenceRE
private org.apache.regexp.RE getEndOfSentenceRE()
- Returns a regular expression for matching the end of a sentence.
setCheckFirstSentence
public void setCheckFirstSentence(boolean aFlag)
- Sets the flag that determines if the first sentence is checked for
proper end of sentence punctuation.
setCheckHtml
public void setCheckHtml(boolean aFlag)
- Sets the flag that determines if HTML checking is to be performed.
|
|||||||||
| Home >> All >> com >> puppycrawl >> tools >> checkstyle >> checks >> [ javadoc overview ] | PREV CLASS NEXT CLASS | ||||||||
SUMMARY: JAVADOC | SOURCE | DOWNLOAD | NESTED | FIELD | CONSTR | METHOD |
DETAIL: FIELD | CONSTR | METHOD | ||||||||
JAVADOC