APIdia Launch Partner
Top Description Inners Fields Constructors Methods
jdk.javadoc.internal.doclets.toolkit

public Class CommentUtils

extends Object
Class Inheritance
Imports
java.net.URI, java.util.ArrayList, .HashMap, .List, java.util.regex.Matcher, .Pattern, javax.lang.model.element.Element, .ExecutableElement, .Name, .PackageElement, .RecordComponentElement, .TypeElement, .VariableElement, javax.lang.model.util.Elements, javax.tools.FileObject, .JavaFileObject, .SimpleJavaFileObject, com.sun.source.doctree.AttributeTree, .DocCommentTree, .DocTree, .IdentifierTree, .LiteralTree, .ParamTree, .ReferenceTree, .ReturnTree, .SinceTree, .TextTree, .UnknownBlockTagTree, com.sun.source.util.DocTreeFactory, .DocTreePath, .DocTrees, .TreePath, com.sun.tools.javac.util.DefinedBy, .DefinedBy.Api, jdk.javadoc.internal.doclets.toolkit.util.Utils, .VisibleMemberTable

A utility class for handling documentation comments.

Nested and Inner Type Summary

Modifier and TypeClass and Description
public static class
CommentUtils.DocCommentInfo

Info about a doc comment: the position in the enclosing AST, and the parsed doc comment itself.

Field Summary

Modifier and TypeField and Description
pack-priv final BaseConfiguration
pack-priv final HashMap<Element, CommentUtils.DocCommentInfo>
dcInfoMap

A map for storing automatically generated comments for various elements, such as mandated elements (Enum.values, Enum.valueOf, etc) and JavaFX properties.

pack-priv final Elements
pack-priv final Resources
pack-priv final DocTreeFactory
pack-priv final DocTrees
pack-priv final Utils

Constructor Summary

AccessConstructor and Description
protected

Method Summary

Modifier and TypeMethod and Description
private void
add(List<DocTree> contents, String resourceKey)

public List<? extends DocTree>

Returns:

a list containing the string for a given key in the doclet's resources, formatted with given arguments
getComment
(String
the key for the desired string
key
,
Object
string or DocTree argument to be formatted into the result
o0
)

Returns a list containing the string for a given key in the doclet's resources, formatted with given arguments.

public List<? extends DocTree>

Returns:

a list containing the string for a given key in the doclet's resources, formatted with given arguments
getComment
(String
the key for the desired strings
key
,
Object
string or a DocTree argument to be formatted into the result
o0
,
Object
string or a DocTree argument to be formatted into the result
o1
,
Object
string or a DocTree argument to be formatted into the result
o2
)

Returns a list containing the string for a given key in the doclet's resources, formatted with given arguments.

public CommentUtils.DocCommentInfo
public CommentUtils.DocCommentInfo
private boolean

Returns:

whether or not there is a @param} for the component
hasParamForComponent
(TypeElement
the record element
elem
,
Name
the name of the component
component
)

Returns whether or not the doc comment for a record contains an @param} for a state component of the record.

public LiteralTree
private List<DocTree>

Returns:

the description
makeDescriptionWithComponent
(String
the resource key for the description
key
,
TypeElement
the record element
elem
,
Name
the name of the component
component
)

Creates a description that contains a reference to a state component of a record.

private List<DocTree>

Returns:

the description
makeDescriptionWithName
(String
the resource key for the description
key
,
Name
the name
name
)

Creates a description that contains the simple name of a program element The description is looked up as a resource, and should contain {0} where the name is to be inserted.

public List<? extends DocTree>
public ParamTree
makeParamTree(Name name, List<? extends DocTree> description)

public List<? extends DocTree>
public ReturnTree
makeReturnTree(List<? extends DocTree> description)

public DocTree
public TextTree
public TextTree
private List<DocTree>

Returns:

the list of parsed DocTree nodes
parse
(String
the string
s
)

Parses a string, looking for simple embedded HTML.

public DocCommentTree
parse(URI uri, String text)

public CommentUtils.DocCommentInfo
public CommentUtils.DocCommentInfo
setDocCommentTree(Element element, List<? extends DocTree> fullBody, List<? extends DocTree> blockTags)

public void
public void
public void
setRecordAccessorTree(ExecutableElement
the accessor method
ee
)

Generates the description for the accessor method for a state component of a record.

public void
setRecordConstructorTree(ExecutableElement
the constructor
ee
)

Generates the description for the canonical constructor for a record.

public void
setRecordEqualsTree(ExecutableElement
the equals method
ee
)

Generates the description for the standard equals method for a record.

public void
setRecordFieldTree(VariableElement
the field
ve
)

Generates the description for the field for a state component of a record.

public void
setRecordHashCodeTree(ExecutableElement
the hashCode method
ee
)

Generates the description for the standard hashCode method for a record.

public void
setRecordToStringTree(ExecutableElement
the toString method
ee
)

Generates the description for the standard toString method for a record.

public void
updatePropertyMethodComment(ExecutableElement
the member which is to be augmented
member
,
Element
the element containing the preferred property description
property
)

Update the property method, property setter and/or property getter comment text so that it contains the documentation from the preferred property description (field or property method).

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

configurationback to summary
pack-priv final BaseConfiguration configuration
dcInfoMapback to summary
pack-priv final HashMap<Element, CommentUtils.DocCommentInfo> dcInfoMap

A map for storing automatically generated comments for various elements, such as mandated elements (Enum.values, Enum.valueOf, etc) and JavaFX properties.

See Also
Utils#dcTreeCache
elementUtilsback to summary
pack-priv final Elements elementUtils
resourcesback to summary
pack-priv final Resources resources
treeFactoryback to summary
pack-priv final DocTreeFactory treeFactory
treesback to summary
pack-priv final DocTrees trees
utilsback to summary
pack-priv final Utils utils

Constructor Detail

CommentUtilsback to summary
protected CommentUtils(BaseConfiguration configuration)

Method Detail

addback to summary
private void add(List<DocTree> contents, String resourceKey)
getCommentback to summary
public List<? extends DocTree> getComment(String key, Object o0)

Returns a list containing the string for a given key in the doclet's resources, formatted with given arguments.

Parameters
key:String

the key for the desired string

o0:Object

string or DocTree argument to be formatted into the result

Returns:List<? extends DocTree>

a list containing the string for a given key in the doclet's resources, formatted with given arguments

getCommentback to summary
public List<? extends DocTree> getComment(String key, Object o0, Object o1, Object o2)

Returns a list containing the string for a given key in the doclet's resources, formatted with given arguments.

Parameters
key:String

the key for the desired strings

o0:Object

string or a DocTree argument to be formatted into the result

o1:Object

string or a DocTree argument to be formatted into the result

o2:Object

string or a DocTree argument to be formatted into the result

Returns:List<? extends DocTree>

a list containing the string for a given key in the doclet's resources, formatted with given arguments

getHtmlCommentInfoback to summary
public CommentUtils.DocCommentInfo getHtmlCommentInfo(Element e)
getSyntheticCommentInfoback to summary
public CommentUtils.DocCommentInfo getSyntheticCommentInfo(Element e)
hasParamForComponentback to summary
private boolean hasParamForComponent(TypeElement elem, Name component)

Returns whether or not the doc comment for a record contains an @param} for a state component of the record.

Parameters
elem:TypeElement

the record element

component:Name

the name of the component

Returns:boolean

whether or not there is a @param} for the component

makeCodeTreeback to summary
public LiteralTree makeCodeTree(String text)
makeDescriptionWithComponentback to summary
private List<DocTree> makeDescriptionWithComponent(String key, TypeElement elem, Name component)

Creates a description that contains a reference to a state component of a record. The description is looked up as a resource, and should contain {0} where the reference to the component is to be inserted. The reference will be a link if the doc comment for the record has a @param tag for the component.

Parameters
key:String

the resource key for the description

elem:TypeElement

the record element

component:Name

the name of the component

Returns:List<DocTree>

the description

makeDescriptionWithNameback to summary
private List<DocTree> makeDescriptionWithName(String key, Name name)

Creates a description that contains the simple name of a program element The description is looked up as a resource, and should contain {0} where the name is to be inserted.

Parameters
key:String

the resource key for the description

name:Name

the name

Returns:List<DocTree>

the description

makeFirstSentenceTreeback to summary
public List<? extends DocTree> makeFirstSentenceTree(String content)
makeParamTreeback to summary
public ParamTree makeParamTree(Name name, List<? extends DocTree> description)
makePropertyDescriptionTreeback to summary
public List<? extends DocTree> makePropertyDescriptionTree(List<? extends DocTree> content)
makeReturnTreeback to summary
public ReturnTree makeReturnTree(List<? extends DocTree> description)
makeSeeTreeback to summary
public DocTree makeSeeTree(String sig, Element e)
makeTextTreeback to summary
public TextTree makeTextTree(String content)
makeTextTreeForResourceback to summary
public TextTree makeTextTreeForResource(String key)
parseback to summary
private List<DocTree> parse(String s)

Parses a string, looking for simple embedded HTML.

Parameters
s:String

the string

Returns:List<DocTree>

the list of parsed DocTree nodes

parseback to summary
public DocCommentTree parse(URI uri, String text)
setDocCommentInfoback to summary
public CommentUtils.DocCommentInfo setDocCommentInfo(Element element, CommentUtils.DocCommentInfo dci)
setDocCommentTreeback to summary
public CommentUtils.DocCommentInfo setDocCommentTree(Element element, List<? extends DocTree> fullBody, List<? extends DocTree> blockTags)
setEnumValueOfTreeback to summary
public void setEnumValueOfTree(ExecutableElement ee)
setEnumValuesTreeback to summary
public void setEnumValuesTree(ExecutableElement ee)
setRecordAccessorTreeback to summary
public void setRecordAccessorTree(ExecutableElement ee)

Generates the description for the accessor method for a state component of a record.

Parameters
ee:ExecutableElement

the accessor method

setRecordConstructorTreeback to summary
public void setRecordConstructorTree(ExecutableElement ee)

Generates the description for the canonical constructor for a record.

Parameters
ee:ExecutableElement

the constructor

setRecordEqualsTreeback to summary
public void setRecordEqualsTree(ExecutableElement ee)

Generates the description for the standard equals method for a record.

Parameters
ee:ExecutableElement

the equals method

setRecordFieldTreeback to summary
public void setRecordFieldTree(VariableElement ve)

Generates the description for the field for a state component of a record.

Parameters
ve:VariableElement

the field

setRecordHashCodeTreeback to summary
public void setRecordHashCodeTree(ExecutableElement ee)

Generates the description for the standard hashCode method for a record.

Parameters
ee:ExecutableElement

the hashCode method

setRecordToStringTreeback to summary
public void setRecordToStringTree(ExecutableElement ee)

Generates the description for the standard toString method for a record.

Parameters
ee:ExecutableElement

the toString method

updatePropertyMethodCommentback to summary
public void updatePropertyMethodComment(ExecutableElement member, Element property)

Update the property method, property setter and/or property getter comment text so that it contains the documentation from the preferred property description (field or property method). The method adds the leading sentence, copied documentation including the defaultValue tag and the @see tags if the appropriate methods are available.

Parameters
member:ExecutableElement

the member which is to be augmented

property:Element

the element containing the preferred property description

jdk.javadoc.internal.doclets.toolkit back to summary

public Class CommentUtils.DocCommentInfo

extends Object
Class Inheritance
  • java.lang.Object
  • jdk.javadoc.internal.doclets.toolkit.CommentUtils.DocCommentInfo

Info about a doc comment: the position in the enclosing AST, and the parsed doc comment itself. The position in the AST is null for automatically generated comments, such as for Enum.values, Enum.valuesOf, and JavaFX properties.

Field Summary

Modifier and TypeField and Description
public final DocCommentTree
dcTree

The doc comment tree that is the root node of a parsed doc comment, or null if there is no comment.

public final TreePath
treePath

The position of the comment in the enclosing AST, or null for automatically generated comments.

Constructor Summary

AccessConstructor and Description
public

Method Summary

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

dcTreeback to summary
public final DocCommentTree dcTree

The doc comment tree that is the root node of a parsed doc comment, or null if there is no comment.

treePathback to summary
public final TreePath treePath

The position of the comment in the enclosing AST, or null for automatically generated comments.

Constructor Detail

DocCommentInfoback to summary
public DocCommentInfo(TreePath treePath, DocCommentTree dcTree)