Top Description Constructors Methods
com.sun.source.util

public abstract Class DocTrees

extends Trees
Class Inheritance
Known Direct Subclasses
com.sun.tools.javac.api.JavacTrees
Imports
java.io.IOException, java.text.BreakIterator, java.util.List, javax.annotation.processing.ProcessingEnvironment, javax.lang.model.element.Element, .PackageElement, javax.lang.model.type.TypeMirror, javax.tools.Diagnostic, .FileObject, .JavaCompiler.CompilationTask, com.sun.source.doctree.DocCommentTree, .DocTree, .EntityTree, com.sun.source.tree.CompilationUnitTree

Provides access to syntax trees for doc comments.
Since
1.8

Constructor Summary

AccessConstructor and Description
public
DocTrees()

Constructor for subclasses to call.

Method Summary

Modifier and TypeMethod and Description
public abstract BreakIterator

Returns:

the break iterator
getBreakIterator
()

Returns the break iterator used to compute the first sentence of documentation comments.

public abstract String

Returns:

a string containing the characters
getCharacters
(EntityTree
the tree containing the entity
tree
)

Returns a string containing the characters for the entity in a given entity tree, or null if the tree does not represent a valid series of characters.

public abstract DocCommentTree

Returns:

the doc comment tree
getDocCommentTree
(TreePath
the path for the tree node
path
)

Returns the doc comment tree, if any, for the Tree node identified by a given TreePath.

public abstract DocCommentTree

Returns:

the doc comment tree
getDocCommentTree
(Element
an element whose documentation is required
e
)

Returns the doc comment tree of the given element.

public abstract DocCommentTree

Returns:

the doc comment tree
getDocCommentTree
(FileObject
the content container
fileObject
)

Returns the doc comment tree of the given file.

public abstract DocCommentTree

Returns:

the doc comment tree
getDocCommentTree
(Element
an element whose path is used as a reference
e
,
String
the relative path from the Element
relativePath
)

Returns the doc comment tree of the given file whose path is specified relative to the given element.

public abstract DocTreeFactory

Returns:

a utility object for creating DocTree objects
getDocTreeFactory
()

Returns a utility object for creating DocTree objects.

public abstract DocTreePath

Returns:

a doc tree path containing the doc comment parsed from the given file
getDocTreePath
(FileObject
a file object encapsulating the HTML content
fileObject
,
PackageElement
a package element to associate with the given file object representing a legacy package.html, null otherwise
packageElement
)

Returns a doc tree path containing the doc comment tree of the given file.

public abstract Element

Returns:

the element
getElement
(DocTreePath
the path for the tree node
path
)

Returns the language model element referred to by the leaf node of the given DocTreePath, or null if unknown.

public abstract List<DocTree>

Returns:

the first sentence
getFirstSentence
(List<? extends DocTree>
the DocTree list to interrogate
list
)

Returns the list of DocTree representing the first sentence of a comment.

public abstract DocSourcePositions

Returns:

the utility object
getSourcePositions
()

Implements abstract com.sun.source.util.Trees.getSourcePositions.

Returns a utility object for accessing the source positions of documentation tree nodes.

public abstract TypeMirror

Returns:

the referenced type, or null
getType
(DocTreePath
the path for the tree node
path
)

Returns the language model type referred to by the leaf node of the given DocTreePath, or null if unknown.

public static DocTrees

Returns:

the DocTrees object
instance
(JavaCompiler.CompilationTask
the compilation task for which to get the Trees object
task
)

Hides com.sun.source.util.Trees.instance.

Returns a DocTrees object for a given CompilationTask.

public static DocTrees

Returns:

the DocTrees object
instance
(ProcessingEnvironment
the processing environment for which to get the Trees object
env
)

Hides com.sun.source.util.Trees.instance.

Returns a DocTrees object for a given ProcessingEnvironment.

public abstract void
printMessage(Diagnostic.Kind
the kind of message
kind
,
CharSequence
the message, or an empty string if none
msg
,
DocTree
the tree to use as a position hint
t
,
DocCommentTree
the doc comment tree to use as a position hint
c
,
CompilationUnitTree
the compilation unit that contains tree
root
)

Prints a message of the specified kind at the location of the tree within the provided compilation unit.

public abstract void
setBreakIterator(BreakIterator
a break iterator or null to specify the default sentence breaker
breakIterator
)

Sets the break iterator to compute the first sentence of documentation comments.

Inherited from com.sun.source.util.Trees:
getDocCommentgetElementgetJavacTreesgetLubgetOriginalTypegetPathgetPathgetPathgetPathgetScopegetTreegetTreegetTreegetTreegetTreegetTypeMirrorisAccessibleisAccessibleprintMessage

Constructor Detail

DocTreesback to summary
public DocTrees()

Constructor for subclasses to call.

Method Detail

getBreakIteratorback to summary
public abstract BreakIterator getBreakIterator()

Returns the break iterator used to compute the first sentence of documentation comments. Returns null if none has been specified.

Returns:BreakIterator

the break iterator

Since
9
getCharactersback to summary
public abstract String getCharacters(EntityTree tree)

Returns a string containing the characters for the entity in a given entity tree, or null if the tree does not represent a valid series of characters.

The interpretation of entities is based on section 8.1.4. Character references in the HTML 5.2 specification.

Parameters
tree:EntityTree

the tree containing the entity

Returns:String

a string containing the characters

External Specification
https://www.w3.org/TR/html52
getDocCommentTreeback to summary
public abstract DocCommentTree getDocCommentTree(TreePath path)

Returns the doc comment tree, if any, for the Tree node identified by a given TreePath. Returns null if no doc comment was found.

Implementation Note

The default implementation of this method returns the same DocCommentTree instance for repeated invocations with the same argument.

Parameters
path:TreePath

the path for the tree node

Returns:DocCommentTree

the doc comment tree

getDocCommentTreeback to summary
public abstract DocCommentTree getDocCommentTree(Element e)

Returns the doc comment tree of the given element. Returns null if no doc comment was found.

Implementation Note

The default implementation of this method returns the same DocCommentTree instance for repeated invocations with the same argument.

Parameters
e:Element

an element whose documentation is required

Returns:DocCommentTree

the doc comment tree

Since
9
getDocCommentTreeback to summary
public abstract DocCommentTree getDocCommentTree(FileObject fileObject)

Returns the doc comment tree of the given file. The file must be an HTML file, in which case the doc comment tree represents the entire contents of the file. Returns null if no doc comment was found. Future releases may support additional file types.

Implementation Note

The default implementation of this method returns a new DocCommentTree instance for each invocation.

Parameters
fileObject:FileObject

the content container

Returns:DocCommentTree

the doc comment tree

Since
9
getDocCommentTreeback to summary
public abstract DocCommentTree getDocCommentTree(Element e, String relativePath) throws IOException

Returns the doc comment tree of the given file whose path is specified relative to the given element. The file must be an HTML file, in which case the doc comment tree represents the contents of the <body> tag, and any enclosing tags are ignored. Returns null if no doc comment was found. Future releases may support additional file types.

Implementation Note

The default implementation of this method returns a new DocCommentTree instance for each invocation.

Parameters
e:Element

an element whose path is used as a reference

relativePath:String

the relative path from the Element

Returns:DocCommentTree

the doc comment tree

Exceptions
IOException:
if an exception occurs
Since
9
getDocTreeFactoryback to summary
public abstract DocTreeFactory getDocTreeFactory()

Returns a utility object for creating DocTree objects.

Returns:DocTreeFactory

a utility object for creating DocTree objects

Since
9
getDocTreePathback to summary
public abstract DocTreePath getDocTreePath(FileObject fileObject, PackageElement packageElement)

Returns a doc tree path containing the doc comment tree of the given file. The file must be an HTML file, in which case the doc comment tree represents the contents of the <body> tag, and any enclosing tags are ignored. Any references to source code elements contained in @see and {@link} tags in the doc comment tree will be evaluated in the context of the given package element. Returns null if no doc comment was found.

Parameters
fileObject:FileObject

a file object encapsulating the HTML content

packageElement:PackageElement

a package element to associate with the given file object representing a legacy package.html, null otherwise

Returns:DocTreePath

a doc tree path containing the doc comment parsed from the given file

Exceptions
IllegalArgumentException:
if the fileObject is not an HTML file
Since
9
getElementback to summary
public abstract Element getElement(DocTreePath path)

Returns the language model element referred to by the leaf node of the given DocTreePath, or null if unknown.

Parameters
path:DocTreePath

the path for the tree node

Returns:Element

the element

getFirstSentenceback to summary
public abstract List<DocTree> getFirstSentence(List<? extends DocTree> list)

Returns the list of DocTree representing the first sentence of a comment.

Parameters
list:List<? extends DocTree>

the DocTree list to interrogate

Returns:List<DocTree>

the first sentence

Since
9
getSourcePositionsback to summary
public abstract DocSourcePositions getSourcePositions()

Implements abstract com.sun.source.util.Trees.getSourcePositions.

Returns a utility object for accessing the source positions of documentation tree nodes.

Returns:DocSourcePositions

the utility object

getTypeback to summary
public abstract TypeMirror getType(DocTreePath path)

Returns the language model type referred to by the leaf node of the given DocTreePath, or null if unknown. This method usually returns the same value as getElement(path).asType() for a path argument for which getElement(DocTreePath) returns a non-null value, but may return a type that includes additional information, such as a parameterized generic type instead of a raw type.

Parameters
path:DocTreePath

the path for the tree node

Returns:TypeMirror

the referenced type, or null

Since
15
instanceback to summary
public static DocTrees instance(JavaCompiler.CompilationTask task)

Hides com.sun.source.util.Trees.instance.

Returns a DocTrees object for a given CompilationTask.

Parameters
task:JavaCompiler.CompilationTask

the compilation task for which to get the Trees object

Returns:DocTrees

the DocTrees object

Exceptions
IllegalArgumentException:
if the task does not support the Trees API.
instanceback to summary
public static DocTrees instance(ProcessingEnvironment env)

Hides com.sun.source.util.Trees.instance.

Returns a DocTrees object for a given ProcessingEnvironment.

Parameters
env:ProcessingEnvironment

the processing environment for which to get the Trees object

Returns:DocTrees

the DocTrees object

Exceptions
IllegalArgumentException:
if the env does not support the Trees API.
printMessageback to summary
public abstract void printMessage(Diagnostic.Kind kind, CharSequence msg, DocTree t, DocCommentTree c, CompilationUnitTree root)

Prints a message of the specified kind at the location of the tree within the provided compilation unit.

Parameters
kind:Diagnostic.Kind

the kind of message

msg:CharSequence

the message, or an empty string if none

t:DocTree

the tree to use as a position hint

c:DocCommentTree

the doc comment tree to use as a position hint

root:CompilationUnitTree

the compilation unit that contains tree

setBreakIteratorback to summary
public abstract void setBreakIterator(BreakIterator breakIterator)

Sets the break iterator to compute the first sentence of documentation comments.

Parameters
breakIterator:BreakIterator

a break iterator or null to specify the default sentence breaker

Since
9