Class DocTrees
public abstract class DocTrees extends Trees
- Since:
- 1.8
Constructor Summary
| Constructor | Description |
|---|---|
DocTrees() |
Constructor for subclasses to call. |
Method Summary
| Modifier and Type | Method | Description |
|---|---|---|
abstract BreakIterator |
getBreakIterator() |
Returns the break iterator used to compute the first sentence of documentation comments. |
abstract String |
getCharacters |
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. |
abstract Elements.DocCommentKind |
getDocCommentKind |
Returns the style of the documentation comment associated with a tree node. |
abstract DocCommentTree |
getDocCommentTree |
Returns the doc comment tree, if any, for the Tree node identified by a given TreePath. |
abstract DocCommentTree |
getDocCommentTree |
Returns the doc comment tree of the given element. |
abstract DocCommentTree |
getDocCommentTree |
Returns the doc comment tree of the given file, which must be of one of the supported file types, and whose path is specified relative to the given element. |
abstract DocCommentTree |
getDocCommentTree |
Returns the doc comment tree of the given file, which must be of one of the supported file types. |
abstract DocTreeFactory |
getDocTreeFactory() |
Returns a utility object for creating DocTree objects. |
abstract DocTreePath |
getDocTreePath |
Returns a doc tree path containing the doc comment tree of the given file, which must be of one of the supported file types. |
abstract Element |
getElement |
Returns the language model element referred to by the leaf node of the given DocTreePath, or null if the leaf node of path does not refer to an element. |
abstract List |
getFirstSentence |
Returns the list of DocTree representing the first sentence of a comment. |
abstract DocSourcePositions |
getSourcePositions() |
Returns a utility object for accessing the source positions of documentation tree nodes. |
abstract TypeMirror |
getType |
Returns the language model type referred to by the leaf node of the given DocTreePath, or null if the leaf node of path does not refer to a type. |
static DocTrees |
instance |
Returns a DocTrees object for a given ProcessingEnvironment. |
static DocTrees |
instance |
Returns a DocTrees object for a given CompilationTask. |
abstract void |
printMessage |
Prints a message of the specified kind at the location of the tree within the provided compilation unit. |
abstract void |
setBreakIterator |
Sets the break iterator to compute the first sentence of documentation comments. |
Methods declared in class Trees
getDocComment, getElement, getLub, getOriginalType, getPath, getPath, getPath, getPath, getScope, getTree, getTree, getTree, getTree, getTree, getTypeMirror, isAccessible, isAccessible, printMessage | Modifier and Type | Method | Description |
|---|---|---|
abstract String |
getDocComment |
Returns the doc comment, if any, for the Tree node identified by a given TreePath. |
abstract Element |
getElement |
Returns the Element for the Tree node identified by a given TreePath. |
abstract TypeMirror |
getLub |
Returns the lub of an exception parameter declared in a catch clause. |
abstract TypeMirror |
getOriginalType |
Returns the original type from the ErrorType object. |
abstract TreePath |
getPath |
Returns the path to tree node within the specified compilation unit. |
abstract TreePath |
getPath |
Returns the TreePath node for a given Element. |
abstract TreePath |
getPath |
Returns the TreePath node for an AnnotationMirror on a given Element. |
abstract TreePath |
getPath |
Returns the TreePath node for an AnnotationValue for an AnnotationMirror on a given Element. |
abstract Scope |
getScope |
Returns the Scope for the Tree node identified by a given TreePath. |
abstract Tree |
getTree |
Returns the Tree node for a given Element. |
abstract Tree |
getTree |
Returns the Tree node for an AnnotationMirror on a given Element. |
abstract Tree |
getTree |
Returns the Tree node for an AnnotationValue for an AnnotationMirror on a given Element. |
abstract MethodTree |
getTree |
Returns the MethodTree node for a given ExecutableElement. |
abstract ClassTree |
getTree |
Returns the ClassTree node for a given TypeElement. |
abstract TypeMirror |
getTypeMirror |
Returns the TypeMirror for the Tree node identified by a given TreePath. |
abstract boolean |
isAccessible |
Checks whether the given element is accessible as a member of the given type in a given scope. |
abstract boolean |
isAccessible |
Checks whether a given type is accessible in a given scope. |
abstract void |
printMessage |
Prints a message of the specified kind at the location of the tree within the provided compilation unit |
Methods declared in class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait | Modifier and Type | Method | Description |
|---|---|---|
protected Object |
clone() |
Creates and returns a copy of this object. |
boolean |
equals |
Indicates whether some other object is "equal to" this one. |
protected void |
finalize() |
Deprecated, for removal: This API element is subject to removal in a future version. Finalization is deprecated and subject to removal in a future release. |
final Class |
getClass() |
Returns the runtime class of this Object. |
int |
hashCode() |
Returns a hash code value for this object. |
final void |
notify() |
Wakes up a single thread that is waiting on this object's monitor. |
final void |
notifyAll() |
Wakes up all threads that are waiting on this object's monitor. |
String |
toString() |
Returns a string representation of the object. |
final void |
wait() |
Causes the current thread to wait until it is awakened, typically by being notified or interrupted. |
final void |
wait |
Causes the current thread to wait until it is awakened, typically by being notified or interrupted, or until a certain amount of real time has elapsed. |
final void |
wait |
Causes the current thread to wait until it is awakened, typically by being notified or interrupted, or until a certain amount of real time has elapsed. |
Constructor Details
DocTrees
public DocTrees()
Method Details
instance
public static DocTrees instance(JavaCompiler.CompilationTask task)
- Parameters:
-
task- the compilation task for which to get the Trees object - Returns:
- the DocTrees object
- Throws:
-
IllegalArgumentException- if the task does not support the Trees API.
instance
public static DocTrees instance(ProcessingEnvironment env)
- Parameters:
-
env- the processing environment for which to get the Trees object - Returns:
- the DocTrees object
- Throws:
-
IllegalArgumentException- if the env does not support the Trees API.
getBreakIterator
public abstract BreakIterator getBreakIterator()
null if none has been specified.- Returns:
- the break iterator
- Since:
- 9
getDocCommentKind
public abstract Elements.DocCommentKind getDocCommentKind(TreePath path)
- Parameters:
-
path- the path for the tree node - Returns:
- the style of the documentation comment associated with a tree node
- Since:
- 23
- See Also:
getDocCommentTree
public abstract DocCommentTree getDocCommentTree(TreePath path)
null if no doc comment was found.- Implementation Note:
- The default implementation of this method returns the same
DocCommentTreeinstance for repeated invocations with the same argument. - Parameters:
-
path- the path for the tree node - Returns:
- the doc comment tree
getDocCommentTree
public abstract DocCommentTree getDocCommentTree(Element e)
null if no doc comment was found.- Implementation Note:
- The default implementation of this method returns the same
DocCommentTreeinstance for repeated invocations with the same argument. - Parameters:
-
e- an element whose documentation is required - Returns:
- the doc comment tree
- Since:
- 9
getDocCommentTree
public abstract DocCommentTree getDocCommentTree(FileObject fileObject)
The supported file types are:
- HTML files, identified by a file name ending in
.html, - Markdown files, identified by a file name ending in
.md.
- Implementation Note:
- The default implementation of this method returns a new
DocCommentTreeinstance for each invocation. - Parameters:
-
fileObject- the content container - Returns:
- the doc comment tree
- Throws:
-
IllegalArgumentException- if the file type is not supported - Since:
- 9
getDocCommentTree
public abstract DocCommentTree getDocCommentTree(Element e, String relativePath) throws IOException
The supported file types are:
- HTML files, identified by a file name ending in
.html, - Markdown files, identified by a file name ending in
.md.
- Implementation Note:
- The default implementation of this method returns a new
DocCommentTreeinstance for each invocation. - Parameters:
-
e- an element whose path is used as a reference -
relativePath- the relative path from the Element - Returns:
- the doc comment tree
- Throws:
-
IOException- if an exception occurs -
IllegalArgumentException- if the file type is not supported - Since:
- 9
getDocTreePath
public abstract DocTreePath getDocTreePath(FileObject fileObject, PackageElement packageElement)
@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- a file object encapsulating the HTML content -
packageElement- a package element to associate with the given file object representing a legacy package.html, null otherwise - Returns:
- a doc tree path containing the doc comment parsed from the given file
- Throws:
-
IllegalArgumentException- if the file type is not supported - Since:
- 9
getElement
public abstract Element getElement(DocTreePath path)
DocTreePath, or null if the leaf node of path does not refer to an element.- Parameters:
-
path- the path for the tree node - Returns:
- the referenced element, or null
- See Also:
getType
public abstract TypeMirror getType(DocTreePath path)
DocTreePath, or null if the leaf node of path does not refer to a type. If getElement(DocTreePath) returns a non-null value for a given path argument, this method usally returns the same value as getElement(path).asType(). However, there are cases where the returned type includes additional information, such as a parameterized generic type instead of a raw type. In other cases, such as with primitive or array types, the returned type may not have a corresponding element returned by getElement(DocTreePath).
- Parameters:
-
path- the path for the tree node - Returns:
- the referenced type, or null
- Since:
- 15
- See Also:
getFirstSentence
public abstract List<DocTree> getFirstSentence(List<? extends DocTree> list)
DocTree representing the first sentence of a comment.- Parameters:
-
list- the DocTree list to interrogate - Returns:
- the first sentence
- Since:
- 9
getSourcePositions
public abstract DocSourcePositions getSourcePositions()
- Specified by:
-
getSourcePositionsin classTrees - Returns:
- the utility object
printMessage
public abstract void printMessage(Diagnostic.Kind kind, CharSequence msg, DocTree t, DocCommentTree c, CompilationUnitTree root)
- Parameters:
-
kind- the kind of message -
msg- the message, or an empty string if none -
t- the tree to use as a position hint -
c- the doc comment tree to use as a position hint -
root- the compilation unit that contains tree
setBreakIterator
public abstract void setBreakIterator(BreakIterator breakIterator)
- Parameters:
-
breakIterator- a break iterator ornullto specify the default sentence breaker - Since:
- 9
getDocTreeFactory
public abstract DocTreeFactory getDocTreeFactory()
DocTree objects.- Returns:
- a utility object for creating
DocTreeobjects - Since:
- 9
getCharacters
public abstract String getCharacters(EntityTree tree)
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- the tree containing the entity - Returns:
- a string containing the characters
- Since:
- 16
- External Specifications
© 1993, 2025, Oracle and/or its affiliates. All rights reserved.
Documentation extracted from Debian's OpenJDK Development Kit package.
Licensed under the GNU General Public License, version 2, with the Classpath Exception.
Various third party code in OpenJDK is licensed under different licenses (see Debian package).
Java and OpenJDK are trademarks or registered trademarks of Oracle and/or its affiliates.