src/share/classes/com/sun/tools/javadoc/DocImpl.java

changeset 1443
cfde9737131e
parent 1359
25e14ad23cef
child 1490
fc4cb1577ad6
     1.1 --- a/src/share/classes/com/sun/tools/javadoc/DocImpl.java	Mon Dec 10 16:21:26 2012 +0000
     1.2 +++ b/src/share/classes/com/sun/tools/javadoc/DocImpl.java	Tue Dec 11 15:05:55 2012 -0800
     1.3 @@ -35,6 +35,9 @@
     1.4  import javax.tools.FileObject;
     1.5  
     1.6  import com.sun.javadoc.*;
     1.7 +import com.sun.source.util.TreePath;
     1.8 +import com.sun.tools.javac.tree.JCTree;
     1.9 +import com.sun.tools.javac.tree.JCTree.JCCompilationUnit;
    1.10  import com.sun.tools.javac.util.Position;
    1.11  
    1.12  /**
    1.13 @@ -61,6 +64,12 @@
    1.14      protected final DocEnv env;   //### Rename this everywhere to 'docenv' ?
    1.15  
    1.16      /**
    1.17 +     * Back pointer to the tree node for this doc item.
    1.18 +     * May be null if there is no associated tree.
    1.19 +     */
    1.20 +    protected TreePath treePath;
    1.21 +
    1.22 +    /**
    1.23       *  The complex comment object, lazily initialized.
    1.24       */
    1.25      private Comment comment;
    1.26 @@ -88,11 +97,21 @@
    1.27      /**
    1.28       * Constructor.
    1.29       */
    1.30 -    DocImpl(DocEnv env, String documentation) {
    1.31 -        this.documentation = documentation;
    1.32 +    DocImpl(DocEnv env, TreePath treePath) {
    1.33 +        this.treePath = treePath;
    1.34 +        this.documentation = getCommentText(treePath);
    1.35          this.env = env;
    1.36      }
    1.37  
    1.38 +    private static String getCommentText(TreePath p) {
    1.39 +        if (p == null)
    1.40 +            return null;
    1.41 +
    1.42 +        JCCompilationUnit topLevel = (JCCompilationUnit) p.getCompilationUnit();
    1.43 +        JCTree tree = (JCTree) p.getLeaf();
    1.44 +        return topLevel.docComments.getCommentText(tree);
    1.45 +    }
    1.46 +
    1.47      /**
    1.48       * So subclasses have the option to do lazy initialization of
    1.49       * "documentation" string.
    1.50 @@ -213,11 +232,21 @@
    1.51       * operations like internalization.
    1.52       */
    1.53      public void setRawCommentText(String rawDocumentation) {
    1.54 +        treePath = null;
    1.55          documentation = rawDocumentation;
    1.56          comment = null;
    1.57      }
    1.58  
    1.59      /**
    1.60 +     * Set the full unprocessed text of the comment and tree path.
    1.61 +     */
    1.62 +    void setTreePath(TreePath treePath) {
    1.63 +        this.treePath = treePath;
    1.64 +        documentation = getCommentText(treePath);
    1.65 +        comment = null;
    1.66 +    }
    1.67 +
    1.68 +    /**
    1.69       * return a key for sorting.
    1.70       */
    1.71      CollationKey key() {

mercurial