com.sun.source.util

## Class DocTrees

- java.lang.Object
- - com.sun.source.util.Trees
  - - com.sun.source.util.DocTrees

-     @Exported
      public abstract class DocTrees
      extends Trees

  Provides access to syntax trees for doc comments.
  Since:
    1.8

- - ### Constructor Summary

    Constructors
    Constructor and Description
    `DocTrees()`

  - ### Method Summary

    All Methods Static Methods Instance Methods Abstract Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `abstract DocCommentTree` | `getDocCommentTree(TreePath path)` Gets the doc comment tree, if any, for the Tree node identified by a given TreePath.
    `abstract Element` | `getElement(DocTreePath path)` Gets the language model element referred to by the leaf node of the given `DocTreePath`, or null if unknown.
    `abstract DocSourcePositions` | `getSourcePositions()` Gets a utility object for obtaining source positions.
    `static DocTrees` | `instance(JavaCompiler.CompilationTask task)` Gets a DocTrees object for a given CompilationTask.
    `static DocTrees` | `instance(ProcessingEnvironment env)` Gets a DocTrees object for a given ProcessingEnvironment.
    `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

    - ### Methods inherited from class com.sun.source.util.Trees

      `getDocComment, getElement, getLub, getOriginalType, getPath, getPath, getPath, getPath, getScope, getTree, getTree, getTree, getTree, getTree, getTypeMirror, isAccessible, isAccessible, printMessage`

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Constructor Detail

    - #### DocTrees

          public DocTrees()

  - ### Method Detail

    - #### instance

          public static DocTrees instance(JavaCompiler.CompilationTask task)

      Gets a DocTrees object for a given CompilationTask.
      Parameters:
        `task` - the compilation task for which to get the Trees object
      Throws:
        `IllegalArgumentException` - if the task does not support the Trees API.

    - #### instance

          public static DocTrees instance(ProcessingEnvironment env)

      Gets a DocTrees object for a given ProcessingEnvironment.
      Parameters:
        `env` - the processing environment for which to get the Trees object
      Throws:
        `IllegalArgumentException` - if the env does not support the Trees API.

    - #### getDocCommentTree

          public abstract DocCommentTree getDocCommentTree(TreePath path)

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

    - #### getElement

          public abstract Element getElement(DocTreePath path)

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

    - #### getSourcePositions

          public abstract DocSourcePositions getSourcePositions()

      Description copied from class: `Trees`
      Gets a utility object for obtaining source positions.
      Specified by:
        `getSourcePositions` in class `Trees`

    - #### printMessage

          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` - the kind of message
        `msg` - the message, or an empty string if none
        `t` - the tree to use as a position hint
        `root` - the compilation unit that contains tree

Copyright © 2005, 2016, Oracle and/or its affiliates. All rights reserved.