public class RefCheckDoclet
extends java.lang.Object
Sometimes your javadoc documentation of a public method contains a reference
(i.e. "see" or "link"-tags) to an undocumented private method. Usually you do
not want such a reference, because the reader of the of your documentation
can't make any use of it. This doclet helps you to avoid such dangling
references. It emits a warning, if a reference points to an undocumented
item, for witch the source is available. (You don't want a warning for a
reference to an undocumented item without source-code, like
java.lang.Object
.)
In contrast to PublishedApiDoclet
this class is a
conventional doclet without any magic. The only connection to
PublishedApiDoclet is the PublishedApiDoclet option -padWarnOn
,
that makes PublishedApiDoclet to call this doclet.
Modifier and Type | Class and Description |
---|---|
protected static class |
RefCheckDoclet.Option
Option handling for doclets.
|
Modifier and Type | Field and Description |
---|---|
private com.sun.javadoc.DocErrorReporter |
errorReporter |
static java.lang.String |
OPTION_WARN_ON |
static java.lang.String |
WARNING_ALL |
static java.lang.String |
WARNING_ANNOTATION |
static java.lang.String |
WARNING_ANNOTATION_DEFAULT_VALUE |
static java.lang.String |
WARNING_ANNOTATION_ELEMENT |
static java.lang.String |
WARNING_CONTAINING_CLASS |
static java.lang.String |
WARNING_CONTAINING_PACKAGE |
static java.lang.String |
WARNING_FIELD_TYPE |
static java.lang.String |
WARNING_IMPLEMENTED_INTERFACE |
static java.lang.String |
WARNING_NESTED_CLASS |
static java.lang.String |
WARNING_OVERRIDDEN_METHOD |
static java.lang.String |
WARNING_PARAMETER_TYPE |
static java.lang.String |
WARNING_PRIVATE_ANNOTATION |
static java.lang.String |
WARNING_RETURN_TYPE |
static java.lang.String |
WARNING_SEE_OR_LINK_REFERENCE |
static java.lang.String |
WARNING_SUPER_CLASS |
static java.lang.String |
WARNING_THROWN_CLASS |
private java.util.Set<java.lang.String> |
warnOn |
Constructor and Description |
---|
RefCheckDoclet()
Create a new RefCheckDoclet instance.
|
Modifier and Type | Method and Description |
---|---|
private void |
check(com.sun.javadoc.AnnotationTypeElementDoc elementDoc)
Check an annotation type element doc.
|
private void |
check(com.sun.javadoc.ClassDoc doc)
Check a class doc.
|
private void |
check(com.sun.javadoc.ExecutableMemberDoc emember)
Check an executable member doc.
|
private void |
check(com.sun.javadoc.FieldDoc field)
Check a field doc.
|
private void |
check(com.sun.javadoc.MethodDoc method)
Check a method doc.
|
(package private) boolean |
check(com.sun.javadoc.RootDoc root)
Check for references to undocumented items.
|
private void |
checkAnnotations(com.sun.javadoc.Doc doc,
com.sun.javadoc.AnnotationDesc[] annotations)
Check an array of annotations
|
private void |
checkDoc(com.sun.javadoc.Doc doc)
Check the tags of a Doc-Interface.
|
private void |
checkReference(com.sun.javadoc.Doc doc,
com.sun.javadoc.AnnotationDesc annotationDesc,
java.lang.String warning)
Check an AnnotationDesc-Interface.
|
private void |
checkReference(com.sun.javadoc.Doc doc,
com.sun.javadoc.AnnotationValue annotationValue,
java.lang.String warning)
Check an AnnotationValue-Interface.
|
private void |
checkReference(com.sun.javadoc.Doc doc,
com.sun.javadoc.ClassDoc classDoc,
java.lang.String warning)
Check a ClassDoc-Interface.
|
private void |
checkReference(com.sun.javadoc.Doc doc,
com.sun.javadoc.Doc referenced,
java.lang.String warning)
Check a Doc-Interface.
|
private void |
checkReference(com.sun.javadoc.Doc doc,
com.sun.javadoc.Type type,
java.lang.String warning)
Check a type-Interface.
|
private void |
checkTags(com.sun.javadoc.Doc doc,
com.sun.javadoc.Tag[] tags)
Check an array of tags.
|
com.sun.javadoc.DocErrorReporter |
getErrorReporter()
Get the error reporter for this doclet.
|
boolean |
isWarnOn(java.lang.String condition)
Warn on a certain condition?
|
static com.sun.javadoc.LanguageVersion |
languageVersion()
Implements the doclet languageVersion method.
|
static void |
main(java.lang.String[] args)
A main method.
|
static int |
optionLength(java.lang.String option)
The doclet optionLength method.
|
void |
setErrorReporter(com.sun.javadoc.DocErrorReporter errorReporter)
Set the error reporter for this doclet.
|
void |
setWarnOn(java.lang.String warnOn)
Set the warnOn propertiy.
|
static boolean |
start(com.sun.javadoc.RootDoc root)
The doclet start method.
|
static boolean |
validOptions(java.lang.String[][] options,
com.sun.javadoc.DocErrorReporter reporter)
Implements the doclet validOptions method
|
public static final java.lang.String OPTION_WARN_ON
public static final java.lang.String WARNING_FIELD_TYPE
public static final java.lang.String WARNING_THROWN_CLASS
public static final java.lang.String WARNING_PARAMETER_TYPE
public static final java.lang.String WARNING_OVERRIDDEN_METHOD
public static final java.lang.String WARNING_RETURN_TYPE
public static final java.lang.String WARNING_NESTED_CLASS
public static final java.lang.String WARNING_IMPLEMENTED_INTERFACE
public static final java.lang.String WARNING_CONTAINING_PACKAGE
public static final java.lang.String WARNING_CONTAINING_CLASS
public static final java.lang.String WARNING_SEE_OR_LINK_REFERENCE
public static final java.lang.String WARNING_SUPER_CLASS
public static final java.lang.String WARNING_ANNOTATION_ELEMENT
public static final java.lang.String WARNING_ANNOTATION_DEFAULT_VALUE
public static final java.lang.String WARNING_ANNOTATION
public static final java.lang.String WARNING_PRIVATE_ANNOTATION
public static final java.lang.String WARNING_ALL
private com.sun.javadoc.DocErrorReporter errorReporter
private java.util.Set<java.lang.String> warnOn
private void checkReference(com.sun.javadoc.Doc doc, com.sun.javadoc.Type type, java.lang.String warning)
doc
- the containing Doc-Interfacetype
- the Type to be checkedwarning
- the warning constantprivate void checkReference(com.sun.javadoc.Doc doc, com.sun.javadoc.ClassDoc classDoc, java.lang.String warning)
doc
- the containing Doc-InterfaceclassDoc
- the ClassDoc to be checkedwarning
- the warning constantprivate void checkReference(com.sun.javadoc.Doc doc, com.sun.javadoc.AnnotationDesc annotationDesc, java.lang.String warning)
doc
- the containing Doc-InterfaceannotationDesc
- the AnnotationDesc to be checkedwarning
- the warning constantprivate void checkReference(com.sun.javadoc.Doc doc, com.sun.javadoc.AnnotationValue annotationValue, java.lang.String warning)
doc
- the containing Doc-InterfaceannotationValue
- the value.warning
- the warning constantprivate void checkReference(com.sun.javadoc.Doc doc, com.sun.javadoc.Doc referenced, java.lang.String warning)
doc
- the containing Doc-Interfacereferenced
- the referenced Doc to be checkedwarning
- the warning constantboolean check(com.sun.javadoc.RootDoc root)
root
- the root of the javadoc treetrue
private void checkDoc(com.sun.javadoc.Doc doc)
doc
- private void checkAnnotations(com.sun.javadoc.Doc doc, com.sun.javadoc.AnnotationDesc[] annotations)
private void checkTags(com.sun.javadoc.Doc doc, com.sun.javadoc.Tag[] tags)
\@see
or \@link
tags and check the
reference contained within the tag.doc
- the containing doc-Interface.tags
- an array of tagsprivate void check(com.sun.javadoc.ClassDoc doc)
doc
- the class documentationprivate void check(com.sun.javadoc.AnnotationTypeElementDoc elementDoc)
elementDoc
- the type element doc.private void check(com.sun.javadoc.MethodDoc method)
method
- the method documentationprivate void check(com.sun.javadoc.ExecutableMemberDoc emember)
emember
- the executable member documentationprivate void check(com.sun.javadoc.FieldDoc field)
field
- the field documentation.public final void setWarnOn(java.lang.String warnOn)
"-"
, the corresponding warning is disabled.warnOn
- The list of warning conditions to set.public final boolean isWarnOn(java.lang.String condition)
condition
- the condition to testtrue
, if the warnig is activepublic final com.sun.javadoc.DocErrorReporter getErrorReporter()
public final void setErrorReporter(com.sun.javadoc.DocErrorReporter errorReporter)
errorReporter
- The errorReporter to set.public static int optionLength(java.lang.String option)
option
- the name of the optionDoclet.optionLength(java.lang.String)
public static boolean validOptions(java.lang.String[][] options, com.sun.javadoc.DocErrorReporter reporter) throws java.io.IOException
options
- the optionsreporter
- used to emit messagestrue
, is everything is ok, false
otherwise.java.io.IOException
Doclet.validOptions(java.lang.String[][],
com.sun.javadoc.DocErrorReporter)
public static boolean start(com.sun.javadoc.RootDoc root) throws java.io.IOException
root
- the RootDoc objecttrue
, if everything is ok, otherwise
false
.java.io.IOException
Doclet.start(com.sun.javadoc.RootDoc)
public static com.sun.javadoc.LanguageVersion languageVersion()
LanguageVersion.JAVA_1_5
.public static void main(java.lang.String[] args)
args
- the command line argumentsMain.execute(java.lang.String, java.lang.String, java.lang.String[])