java.lang.Object
com.sun.source.util.Trees
com.sun.source.util.DocTrees
Provides access to syntax trees for doc comments.
- Since:
- 1.8
- 
Constructor SummaryConstructors
- 
Method SummaryModifier and TypeMethodDescriptionabstract BreakIteratorReturns the break iterator used to compute the first sentence of documentation comments.abstract StringgetCharacters(EntityTree tree) Returns a string containing the characters for the entity in a given entity tree, ornullif the tree does not represent a valid series of characters.abstract DocCommentTreegetDocCommentTree(TreePath path) Returns the doc comment tree, if any, for the Tree node identified by a given TreePath.abstract DocCommentTreeReturns the doc comment tree of the given element.abstract DocCommentTreegetDocCommentTree(Element e, String relativePath) Returns the doc comment tree of the given file whose path is specified relative to the given element.abstract DocCommentTreegetDocCommentTree(FileObject fileObject) Returns the doc comment tree of the given file.abstract DocTreeFactoryReturns a utility object for creatingDocTreeobjects.abstract DocTreePathgetDocTreePath(FileObject fileObject, PackageElement packageElement) Returns a doc tree path containing the doc comment tree of the given file.abstract ElementgetElement(DocTreePath path) Returns the language model element referred to by the leaf node of the givenDocTreePath, ornullif unknown.getFirstSentence(List<? extends DocTree> list) Returns the list ofDocTreerepresenting the first sentence of a comment.abstract DocSourcePositionsReturns a utility object for accessing the source positions of documentation tree nodes.abstract TypeMirrorgetType(DocTreePath path) Returns the language model type referred to by the leaf node of the givenDocTreePath, ornullif unknown.static DocTreesReturns a DocTrees object for a given ProcessingEnvironment.static DocTreesReturns a DocTrees object for a given CompilationTask.abstract voidprintMessage(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.abstract voidsetBreakIterator(BreakIterator breakIterator) Sets the break iterator to compute the first sentence of documentation comments.Methods declared in class com.sun.source.util.TreesgetDocComment, getElement, getLub, getOriginalType, getPath, getPath, getPath, getPath, getScope, getTree, getTree, getTree, getTree, getTree, getTypeMirror, isAccessible, isAccessible, printMessage
- 
Constructor Details- 
DocTreespublic DocTrees()Constructor for subclasses to call.
 
- 
- 
Method Details- 
instanceReturns a DocTrees object for a given CompilationTask.- 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.
 
- 
instanceReturns a DocTrees object for a given ProcessingEnvironment.- 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.
 
- 
getBreakIteratorReturns the break iterator used to compute the first sentence of documentation comments. Returnsnullif none has been specified.- Returns:
- the break iterator
- Since:
- 9
 
- 
getDocCommentTreeReturns the doc comment tree, if any, for the Tree node identified by a given TreePath. Returnsnullif 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
 
- 
getDocCommentTreeReturns the doc comment tree of the given element. Returnsnullif 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
 
- 
getDocCommentTreeReturns 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. Returnsnullif no doc comment was found. Future releases may support additional file types.- 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
- Since:
- 9
 
- 
getDocCommentTreeReturns 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. Returnsnullif no doc comment was found. Future releases may support additional file types.- 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
- Since:
- 9
 
- 
getDocTreePathReturns 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@seeand{@link}tags in the doc comment tree will be evaluated in the context of the given package element. Returnsnullif 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 fileObject is not an HTML file
- Since:
- 9
 
- 
getElementReturns the language model element referred to by the leaf node of the givenDocTreePath, ornullif unknown.- Parameters:
- path- the path for the tree node
- Returns:
- the element
 
- 
getTypeReturns the language model type referred to by the leaf node of the givenDocTreePath, ornullif unknown. This method usually returns the same value asgetElement(path).asType()for apathargument for whichgetElement(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- the path for the tree node
- Returns:
- the referenced type, or null
- Since:
- 15
 
- 
getFirstSentenceReturns the list ofDocTreerepresenting the first sentence of a comment.- Parameters:
- list- the DocTree list to interrogate
- Returns:
- the first sentence
- Since:
- 9
 
- 
getSourcePositionsReturns a utility object for accessing the source positions of documentation tree nodes.- Specified by:
- getSourcePositionsin class- Trees
- Returns:
- the utility object
 
- 
printMessagepublic 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- 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
 
- 
setBreakIteratorSets the break iterator to compute the first sentence of documentation comments.- Parameters:
- breakIterator- a break iterator or- nullto specify the default sentence breaker
- Since:
- 9
 
- 
getDocTreeFactoryReturns a utility object for creatingDocTreeobjects.- Returns:
- a utility object for creating DocTreeobjects
- Since:
- 9
 
- 
getCharactersReturns a string containing the characters for the entity in a given entity tree, ornullif 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
- External Specifications
 
 
-