Docjar: A Java Source and Docuemnt Enginecom.*    java.*    javax.*    org.*    all    new    plug-in

Quick Search    Search Deep

com.puppycrawl.tools.checkstyle.checks
Class JavadocMethodCheck  view JavadocMethodCheck download JavadocMethodCheck.java

java.lang.Object
  extended bycom.puppycrawl.tools.checkstyle.api.AutomaticBean
      extended bycom.puppycrawl.tools.checkstyle.api.AbstractViolationReporter
          extended bycom.puppycrawl.tools.checkstyle.api.Check
              extended bycom.puppycrawl.tools.checkstyle.checks.AbstractImportCheck
                  extended bycom.puppycrawl.tools.checkstyle.checks.JavadocMethodCheck
All Implemented Interfaces:
com.puppycrawl.tools.checkstyle.api.Configurable, com.puppycrawl.tools.checkstyle.api.Contextualizable

public class JavadocMethodCheck
extends AbstractImportCheck

Checks the Javadoc of a method or constructor. By default, does not check for unused throws. To allow documented java.lang.RuntimeExceptions that are not declared, set property allowUndeclaredRTE to true. The scope to verify is specified using the com.puppycrawl.tools.checkstyle.api.Scope class and defaults to Scope.PRIVATE>Scope.PRIVATE 55 . To verify another scope, set property scope to one of the com.puppycrawl.tools.checkstyle.api.Scope constants.

An example of how to configure the check is:

 <module name="JavadocMethod"/>
 

An example of how to configure the check to check to allow documentation of undeclared RuntimeExceptions and for the Scope.PUBLIC>Scope.PUBLIC 55 scope is:

 <module name="JavadocMethod">
    <property name="scope" value="public"/>
    <property name="allowUndeclaredRTE" value="true"/>
 </module>
 

Version:
1.0

Field Summary
private static java.lang.String END_JAVADOC
          Multiline finished at end of comment
private  boolean mAllowUndeclaredRTE
          controls whether to allow documented exceptions that are not declared if they are a subclass of java.lang.RuntimeException.
private static org.apache.regexp.RE MATCH_JAVADOC_ARG
          compiled regexp to match Javadoc tags that take an argument
private static org.apache.regexp.RE MATCH_JAVADOC_ARG_MULTILINE_START
          compiled regexp to match first part of multilineJavadoc tags
private static java.lang.String MATCH_JAVADOC_ARG_MULTILINE_START_PAT
          the pattern to match the first line of a multi-line Javadoc tag that takes an argument.
private static java.lang.String MATCH_JAVADOC_ARG_PAT
          the pattern to match Javadoc tags that take an argument
private static org.apache.regexp.RE MATCH_JAVADOC_MULTILINE_CONT
          compiled regexp to look for a continuation of the comment
private static java.lang.String MATCH_JAVADOC_MULTILINE_CONT_PAT
          the pattern that looks for a continuation of the comment
private static org.apache.regexp.RE MATCH_JAVADOC_NOARG
          compiled regexp to match Javadoc tags with no argument
private static org.apache.regexp.RE MATCH_JAVADOC_NOARG_CURLY
          compiled regexp to match Javadoc tags with no argument and {}
private static java.lang.String MATCH_JAVADOC_NOARG_CURLY_PAT
          the pattern to match Javadoc tags with no argument and {}
private static org.apache.regexp.RE MATCH_JAVADOC_NOARG_MULTILINE_START
          compiled regexp to match first part of multilineJavadoc tags
private static java.lang.String MATCH_JAVADOC_NOARG_MULTILINE_START_PAT
          the pattern to match the first line of a multi-line Javadoc tag that takes no argument.
private static java.lang.String MATCH_JAVADOC_NOARG_PAT
          the pattern to match Javadoc tags with no argument
private  java.util.Set mImports
          imports details
private  com.puppycrawl.tools.checkstyle.api.FullIdent mPackageFullIdent
          full identifier for package of the method
private  com.puppycrawl.tools.checkstyle.api.Scope mScope
          the visibility scope where Javadoc comments are checked
private static java.lang.String NEXT_TAG
          Multiline finished at next Javadoc
 
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
JavadocMethodCheck()
           
 
Method Summary
private  java.lang.String basename(java.lang.String aType)
           
 void beginTree()
           
private  void checkComment(com.puppycrawl.tools.checkstyle.api.DetailAST aAST, java.lang.String[] aComment)
          Checks the Javadoc for a method.
private  void checkParamTags(java.util.List aTags, java.util.List aParams)
          Checks a set of tags for matching parameters.
private  void checkReturnTag(java.util.List aTags, int aLineNo)
          Checks for only one return tag.
private  void checkThrowsTags(java.util.List aTags, java.util.List aThrows)
          Checks a set of tags for matching throws.
 int[] getAcceptableTokens()
          The configurable token set.
 int[] getDefaultTokens()
          Returns the default token a check is interested in.
private  java.util.List getMethodTags(java.lang.String[] aLines, int aLastLineNo)
          Returns the tags in a javadoc comment.
private  java.util.List getParameters(com.puppycrawl.tools.checkstyle.api.DetailAST aAST)
          Computes the parameter nodes for a method.
 int[] getRequiredTokens()
          The tokens that this check must be registered for.
private  java.util.List getThrows(com.puppycrawl.tools.checkstyle.api.DetailAST aAST)
          Computes the exception nodes for a method.
private  boolean isFunction(com.puppycrawl.tools.checkstyle.api.DetailAST aAST)
          Checks whether a method is a function.
private  boolean isSameType(java.lang.String aDeclared, java.lang.String aDocumented)
          Return if two Strings represent the same type, inspecting the import statements if necessary
private  boolean isShortName(java.lang.String aShortName, java.lang.String aFullName)
          Calculate if one type name is a shortname for another type name.
private  void processImport(com.puppycrawl.tools.checkstyle.api.DetailAST aAST)
          Collects the details of imports.
private  void processMethod(com.puppycrawl.tools.checkstyle.api.DetailAST aAST)
          Checks Javadoc comments for a method or constructor.
private  void processPackage(com.puppycrawl.tools.checkstyle.api.DetailAST aAST)
          Collects the details of a package.
 void setAllowUndeclaredRTE(boolean aFlag)
          controls whether to allow documented exceptions that are not declared if they are a subclass of java.lang.RuntimeException.
 void setScope(java.lang.String aFrom)
          Set the scope.
 void visitToken(com.puppycrawl.tools.checkstyle.api.DetailAST aAST)
          Called to process a token.
 
Methods inherited from class com.puppycrawl.tools.checkstyle.checks.AbstractImportCheck
getImportText
 
Methods inherited from class com.puppycrawl.tools.checkstyle.api.Check
beginTree, destroy, finishTree, getClassLoader, getFileContents, getLines, 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

MATCH_JAVADOC_ARG_PAT

private static final java.lang.String MATCH_JAVADOC_ARG_PAT
the pattern to match Javadoc tags that take an argument

See Also:
Constant Field Values

MATCH_JAVADOC_ARG

private static final org.apache.regexp.RE MATCH_JAVADOC_ARG
compiled regexp to match Javadoc tags that take an argument


MATCH_JAVADOC_ARG_MULTILINE_START_PAT

private static final java.lang.String MATCH_JAVADOC_ARG_MULTILINE_START_PAT
the pattern to match the first line of a multi-line Javadoc tag that takes an argument.

See Also:
Constant Field Values

MATCH_JAVADOC_ARG_MULTILINE_START

private static final org.apache.regexp.RE MATCH_JAVADOC_ARG_MULTILINE_START
compiled regexp to match first part of multilineJavadoc tags


MATCH_JAVADOC_MULTILINE_CONT_PAT

private static final java.lang.String MATCH_JAVADOC_MULTILINE_CONT_PAT
the pattern that looks for a continuation of the comment

See Also:
Constant Field Values

MATCH_JAVADOC_MULTILINE_CONT

private static final org.apache.regexp.RE MATCH_JAVADOC_MULTILINE_CONT
compiled regexp to look for a continuation of the comment


END_JAVADOC

private static final java.lang.String END_JAVADOC
Multiline finished at end of comment

See Also:
Constant Field Values

NEXT_TAG

private static final java.lang.String NEXT_TAG
Multiline finished at next Javadoc

See Also:
Constant Field Values

MATCH_JAVADOC_NOARG_PAT

private static final java.lang.String MATCH_JAVADOC_NOARG_PAT
the pattern to match Javadoc tags with no argument

See Also:
Constant Field Values

MATCH_JAVADOC_NOARG

private static final org.apache.regexp.RE MATCH_JAVADOC_NOARG
compiled regexp to match Javadoc tags with no argument


MATCH_JAVADOC_NOARG_MULTILINE_START_PAT

private static final java.lang.String MATCH_JAVADOC_NOARG_MULTILINE_START_PAT
the pattern to match the first line of a multi-line Javadoc tag that takes no argument.

See Also:
Constant Field Values

MATCH_JAVADOC_NOARG_MULTILINE_START

private static final org.apache.regexp.RE MATCH_JAVADOC_NOARG_MULTILINE_START
compiled regexp to match first part of multilineJavadoc tags


MATCH_JAVADOC_NOARG_CURLY_PAT

private static final java.lang.String MATCH_JAVADOC_NOARG_CURLY_PAT
the pattern to match Javadoc tags with no argument and {}

See Also:
Constant Field Values

MATCH_JAVADOC_NOARG_CURLY

private static final org.apache.regexp.RE MATCH_JAVADOC_NOARG_CURLY
compiled regexp to match Javadoc tags with no argument and {}


mPackageFullIdent

private com.puppycrawl.tools.checkstyle.api.FullIdent mPackageFullIdent
full identifier for package of the method


mImports

private java.util.Set mImports
imports details


mScope

private com.puppycrawl.tools.checkstyle.api.Scope mScope
the visibility scope where Javadoc comments are checked


mAllowUndeclaredRTE

private boolean mAllowUndeclaredRTE
controls whether to allow documented exceptions that are not declared if they are a subclass of java.lang.RuntimeException.

Constructor Detail

JavadocMethodCheck

public JavadocMethodCheck()
Method Detail

setScope

public void setScope(java.lang.String aFrom)
Set the scope.


setAllowUndeclaredRTE

public void setAllowUndeclaredRTE(boolean aFlag)
controls whether to allow documented exceptions that are not declared if they are a subclass of java.lang.RuntimeException.


getDefaultTokens

public int[] getDefaultTokens()
Description copied from class: com.puppycrawl.tools.checkstyle.api.Check
Returns the default token a check is interested in. Only used if the configuration for a check does not define the tokens.


getAcceptableTokens

public int[] getAcceptableTokens()
Description copied from class: com.puppycrawl.tools.checkstyle.api.Check
The configurable token set. Used to protect Checks against malicious users who specify an unacceptable token set in the configuration file. The default implementation returns the check's default tokens.


getRequiredTokens

public int[] getRequiredTokens()
Description copied from class: com.puppycrawl.tools.checkstyle.api.Check
The tokens that this check must be registered for.


beginTree

public void beginTree()

visitToken

public void visitToken(com.puppycrawl.tools.checkstyle.api.DetailAST aAST)
Description copied from class: com.puppycrawl.tools.checkstyle.api.Check
Called to process a token.


processPackage

private void processPackage(com.puppycrawl.tools.checkstyle.api.DetailAST aAST)
Collects the details of a package.


processImport

private void processImport(com.puppycrawl.tools.checkstyle.api.DetailAST aAST)
Collects the details of imports.


processMethod

private void processMethod(com.puppycrawl.tools.checkstyle.api.DetailAST aAST)
Checks Javadoc comments for a method or constructor.


checkComment

private void checkComment(com.puppycrawl.tools.checkstyle.api.DetailAST aAST,
                          java.lang.String[] aComment)
Checks the Javadoc for a method.


getMethodTags

private java.util.List getMethodTags(java.lang.String[] aLines,
                                     int aLastLineNo)
Returns the tags in a javadoc comment. Only finds throws, exception, param, return and see tags.


getParameters

private java.util.List getParameters(com.puppycrawl.tools.checkstyle.api.DetailAST aAST)
Computes the parameter nodes for a method.


getThrows

private java.util.List getThrows(com.puppycrawl.tools.checkstyle.api.DetailAST aAST)
Computes the exception nodes for a method.


checkParamTags

private void checkParamTags(java.util.List aTags,
                            java.util.List aParams)
Checks a set of tags for matching parameters.


isSameType

private boolean isSameType(java.lang.String aDeclared,
                           java.lang.String aDocumented)
Return if two Strings represent the same type, inspecting the import statements if necessary


isShortName

private boolean isShortName(java.lang.String aShortName,
                            java.lang.String aFullName)
Calculate if one type name is a shortname for another type name.


isFunction

private boolean isFunction(com.puppycrawl.tools.checkstyle.api.DetailAST aAST)
Checks whether a method is a function.


checkReturnTag

private void checkReturnTag(java.util.List aTags,
                            int aLineNo)
Checks for only one return tag. All return tags will be removed from the supplied list.


checkThrowsTags

private void checkThrowsTags(java.util.List aTags,
                             java.util.List aThrows)
Checks a set of tags for matching throws.


basename

private java.lang.String basename(java.lang.String aType)