8004828: refactor init of *DocImpl classes

Tue, 11 Dec 2012 15:05:55 -0800

author
jjg
date
Tue, 11 Dec 2012 15:05:55 -0800
changeset 1443
cfde9737131e
parent 1442
fcf89720ae71
child 1444
170e486632d9

8004828: refactor init of *DocImpl classes
Reviewed-by: darcy

src/share/classes/com/sun/tools/javadoc/AnnotationTypeDocImpl.java file | annotate | diff | comparison | revisions
src/share/classes/com/sun/tools/javadoc/AnnotationTypeElementDocImpl.java file | annotate | diff | comparison | revisions
src/share/classes/com/sun/tools/javadoc/ClassDocImpl.java file | annotate | diff | comparison | revisions
src/share/classes/com/sun/tools/javadoc/ConstructorDocImpl.java file | annotate | diff | comparison | revisions
src/share/classes/com/sun/tools/javadoc/DocEnv.java file | annotate | diff | comparison | revisions
src/share/classes/com/sun/tools/javadoc/DocImpl.java file | annotate | diff | comparison | revisions
src/share/classes/com/sun/tools/javadoc/ExecutableMemberDocImpl.java file | annotate | diff | comparison | revisions
src/share/classes/com/sun/tools/javadoc/FieldDocImpl.java file | annotate | diff | comparison | revisions
src/share/classes/com/sun/tools/javadoc/JavadocEnter.java file | annotate | diff | comparison | revisions
src/share/classes/com/sun/tools/javadoc/JavadocMemberEnter.java file | annotate | diff | comparison | revisions
src/share/classes/com/sun/tools/javadoc/MemberDocImpl.java file | annotate | diff | comparison | revisions
src/share/classes/com/sun/tools/javadoc/MethodDocImpl.java file | annotate | diff | comparison | revisions
src/share/classes/com/sun/tools/javadoc/PackageDocImpl.java file | annotate | diff | comparison | revisions
src/share/classes/com/sun/tools/javadoc/ProgramElementDocImpl.java file | annotate | diff | comparison | revisions
src/share/classes/com/sun/tools/javadoc/RootDocImpl.java file | annotate | diff | comparison | revisions
     1.1 --- a/src/share/classes/com/sun/tools/javadoc/AnnotationTypeDocImpl.java	Mon Dec 10 16:21:26 2012 +0000
     1.2 +++ b/src/share/classes/com/sun/tools/javadoc/AnnotationTypeDocImpl.java	Tue Dec 11 15:05:55 2012 -0800
     1.3 @@ -27,13 +27,13 @@
     1.4  
     1.5  import com.sun.javadoc.*;
     1.6  
     1.7 +import com.sun.source.util.TreePath;
     1.8  import com.sun.tools.javac.code.Kinds;
     1.9  import com.sun.tools.javac.code.Scope;
    1.10  import com.sun.tools.javac.code.Symbol.*;
    1.11  import com.sun.tools.javac.tree.JCTree.*;
    1.12  import com.sun.tools.javac.util.List;
    1.13  import com.sun.tools.javac.util.Names;
    1.14 -import com.sun.tools.javac.util.Position;
    1.15  
    1.16  /**
    1.17   * Represents an annotation type.
    1.18 @@ -51,12 +51,11 @@
    1.19          extends ClassDocImpl implements AnnotationTypeDoc {
    1.20  
    1.21      public AnnotationTypeDocImpl(DocEnv env, ClassSymbol sym) {
    1.22 -        this(env, sym, null, null, null);
    1.23 +        this(env, sym, null);
    1.24      }
    1.25  
    1.26 -    public AnnotationTypeDocImpl(DocEnv env, ClassSymbol sym,
    1.27 -                          String doc, JCClassDecl tree, Position.LineMap lineMap) {
    1.28 -        super(env, sym, doc, tree, lineMap);
    1.29 +    public AnnotationTypeDocImpl(DocEnv env, ClassSymbol sym, TreePath treePath) {
    1.30 +        super(env, sym, treePath);
    1.31      }
    1.32  
    1.33      /**
     2.1 --- a/src/share/classes/com/sun/tools/javadoc/AnnotationTypeElementDocImpl.java	Mon Dec 10 16:21:26 2012 +0000
     2.2 +++ b/src/share/classes/com/sun/tools/javadoc/AnnotationTypeElementDocImpl.java	Tue Dec 11 15:05:55 2012 -0800
     2.3 @@ -27,9 +27,9 @@
     2.4  
     2.5  import com.sun.javadoc.*;
     2.6  
     2.7 +import com.sun.source.util.TreePath;
     2.8  import com.sun.tools.javac.code.Symbol.*;
     2.9  import com.sun.tools.javac.tree.JCTree.*;
    2.10 -import com.sun.tools.javac.util.Position;
    2.11  
    2.12  /**
    2.13   * Represents an element of an annotation type.
    2.14 @@ -50,9 +50,8 @@
    2.15          super(env, sym);
    2.16      }
    2.17  
    2.18 -    public AnnotationTypeElementDocImpl(DocEnv env, MethodSymbol sym,
    2.19 -                                 String doc, JCMethodDecl tree, Position.LineMap lineMap) {
    2.20 -        super(env, sym, doc, tree, lineMap);
    2.21 +    public AnnotationTypeElementDocImpl(DocEnv env, MethodSymbol sym, TreePath treePath) {
    2.22 +        super(env, sym, treePath);
    2.23      }
    2.24  
    2.25      /**
     3.1 --- a/src/share/classes/com/sun/tools/javadoc/ClassDocImpl.java	Mon Dec 10 16:21:26 2012 +0000
     3.2 +++ b/src/share/classes/com/sun/tools/javadoc/ClassDocImpl.java	Tue Dec 11 15:05:55 2012 -0800
     3.3 @@ -31,13 +31,14 @@
     3.4  import java.net.URI;
     3.5  import java.util.HashSet;
     3.6  import java.util.Set;
     3.7 +
     3.8  import javax.tools.FileObject;
     3.9  import javax.tools.JavaFileManager.Location;
    3.10  import javax.tools.StandardJavaFileManager;
    3.11  import javax.tools.StandardLocation;
    3.12  
    3.13  import com.sun.javadoc.*;
    3.14 -
    3.15 +import com.sun.source.util.TreePath;
    3.16  import com.sun.tools.javac.code.Flags;
    3.17  import com.sun.tools.javac.code.Kinds;
    3.18  import com.sun.tools.javac.code.Scope;
    3.19 @@ -45,22 +46,17 @@
    3.20  import com.sun.tools.javac.code.Symbol.*;
    3.21  import com.sun.tools.javac.code.Type;
    3.22  import com.sun.tools.javac.code.Type.ClassType;
    3.23 -
    3.24  import com.sun.tools.javac.comp.AttrContext;
    3.25  import com.sun.tools.javac.comp.Env;
    3.26 -
    3.27  import com.sun.tools.javac.tree.JCTree;
    3.28 -import com.sun.tools.javac.tree.JCTree.JCClassDecl;
    3.29  import com.sun.tools.javac.tree.JCTree.JCFieldAccess;
    3.30  import com.sun.tools.javac.tree.JCTree.JCImport;
    3.31  import com.sun.tools.javac.tree.TreeInfo;
    3.32 -
    3.33  import com.sun.tools.javac.util.List;
    3.34  import com.sun.tools.javac.util.ListBuffer;
    3.35  import com.sun.tools.javac.util.Name;
    3.36  import com.sun.tools.javac.util.Names;
    3.37  import com.sun.tools.javac.util.Position;
    3.38 -
    3.39  import static com.sun.tools.javac.code.Kinds.*;
    3.40  import static com.sun.tools.javac.code.TypeTag.CLASS;
    3.41  import static com.sun.tools.javac.tree.JCTree.Tag.*;
    3.42 @@ -100,15 +96,14 @@
    3.43       * Constructor
    3.44       */
    3.45      public ClassDocImpl(DocEnv env, ClassSymbol sym) {
    3.46 -        this(env, sym, null, null, null);
    3.47 +        this(env, sym, null);
    3.48      }
    3.49  
    3.50      /**
    3.51       * Constructor
    3.52       */
    3.53 -    public ClassDocImpl(DocEnv env, ClassSymbol sym, String documentation,
    3.54 -                        JCClassDecl tree, Position.LineMap lineMap) {
    3.55 -        super(env, sym, documentation, tree, lineMap);
    3.56 +    public ClassDocImpl(DocEnv env, ClassSymbol sym, TreePath treePath) {
    3.57 +        super(env, sym, treePath);
    3.58          this.type = (ClassType)sym.type;
    3.59          this.tsym = sym;
    3.60      }
     4.1 --- a/src/share/classes/com/sun/tools/javadoc/ConstructorDocImpl.java	Mon Dec 10 16:21:26 2012 +0000
     4.2 +++ b/src/share/classes/com/sun/tools/javadoc/ConstructorDocImpl.java	Tue Dec 11 15:05:55 2012 -0800
     4.3 @@ -27,10 +27,9 @@
     4.4  
     4.5  import com.sun.javadoc.*;
     4.6  
     4.7 +import com.sun.source.util.TreePath;
     4.8  import com.sun.tools.javac.code.Symbol.ClassSymbol;
     4.9  import com.sun.tools.javac.code.Symbol.MethodSymbol;
    4.10 -import com.sun.tools.javac.tree.JCTree.JCMethodDecl;
    4.11 -import com.sun.tools.javac.util.Position;
    4.12  
    4.13  /**
    4.14   * Represents a constructor of a java class.
    4.15 @@ -58,9 +57,8 @@
    4.16      /**
    4.17       * constructor.
    4.18       */
    4.19 -    public ConstructorDocImpl(DocEnv env, MethodSymbol sym,
    4.20 -                              String docComment, JCMethodDecl tree, Position.LineMap lineMap) {
    4.21 -        super(env, sym, docComment, tree, lineMap);
    4.22 +    public ConstructorDocImpl(DocEnv env, MethodSymbol sym, TreePath treePath) {
    4.23 +        super(env, sym, treePath);
    4.24      }
    4.25  
    4.26      /**
     5.1 --- a/src/share/classes/com/sun/tools/javadoc/DocEnv.java	Mon Dec 10 16:21:26 2012 +0000
     5.2 +++ b/src/share/classes/com/sun/tools/javadoc/DocEnv.java	Tue Dec 11 15:05:55 2012 -0800
     5.3 @@ -27,18 +27,20 @@
     5.4  
     5.5  import java.lang.reflect.Modifier;
     5.6  import java.util.*;
     5.7 +
     5.8  import javax.tools.JavaFileManager;
     5.9  
    5.10  import com.sun.javadoc.*;
    5.11 -
    5.12 +import com.sun.source.util.TreePath;
    5.13 +import com.sun.tools.javac.api.JavacTrees;
    5.14  import com.sun.tools.javac.code.*;
    5.15  import com.sun.tools.javac.code.Symbol.*;
    5.16  import com.sun.tools.javac.code.Type.ClassType;
    5.17  import com.sun.tools.javac.comp.Check;
    5.18 +import com.sun.tools.javac.tree.JCTree;
    5.19  import com.sun.tools.javac.tree.JCTree.*;
    5.20  import com.sun.tools.javac.util.Context;
    5.21  import com.sun.tools.javac.util.Names;
    5.22 -import com.sun.tools.javac.util.Position;
    5.23  
    5.24  /**
    5.25   * Holds the environment for a run of javadoc.
    5.26 @@ -104,6 +106,8 @@
    5.27      JavaFileManager fileManager;
    5.28      Context context;
    5.29  
    5.30 +    WeakHashMap<JCTree, TreePath> treePaths = new WeakHashMap<JCTree, TreePath>();
    5.31 +
    5.32      /** Allow documenting from class files? */
    5.33      boolean docClasses = false;
    5.34  
    5.35 @@ -540,13 +544,12 @@
    5.36      /**
    5.37       * Create the PackageDoc (or a subtype) for a package symbol.
    5.38       */
    5.39 -    void makePackageDoc(PackageSymbol pack, String docComment, JCCompilationUnit tree) {
    5.40 +    void makePackageDoc(PackageSymbol pack, TreePath treePath) {
    5.41          PackageDocImpl result = packageMap.get(pack);
    5.42          if (result != null) {
    5.43 -            if (docComment != null) result.setRawCommentText(docComment);
    5.44 -            if (tree != null) result.setTree(tree);
    5.45 +            if (treePath != null) result.setTreePath(treePath);
    5.46          } else {
    5.47 -            result = new PackageDocImpl(this, pack, docComment, tree);
    5.48 +            result = new PackageDocImpl(this, pack, treePath);
    5.49              packageMap.put(pack, result);
    5.50          }
    5.51      }
    5.52 @@ -572,17 +575,16 @@
    5.53      /**
    5.54       * Create the ClassDoc (or a subtype) for a class symbol.
    5.55       */
    5.56 -    protected void makeClassDoc(ClassSymbol clazz, String docComment, JCClassDecl tree, Position.LineMap lineMap) {
    5.57 +    protected void makeClassDoc(ClassSymbol clazz, TreePath treePath) {
    5.58          ClassDocImpl result = classMap.get(clazz);
    5.59          if (result != null) {
    5.60 -            if (docComment != null) result.setRawCommentText(docComment);
    5.61 -            if (tree != null) result.setTree(tree);
    5.62 +            if (treePath != null) result.setTreePath(treePath);
    5.63              return;
    5.64          }
    5.65 -        if (isAnnotationType(tree)) {   // flags of clazz may not yet be set
    5.66 -            result = new AnnotationTypeDocImpl(this, clazz, docComment, tree, lineMap);
    5.67 +        if (isAnnotationType((JCClassDecl) treePath.getLeaf())) {   // flags of clazz may not yet be set
    5.68 +            result = new AnnotationTypeDocImpl(this, clazz, treePath);
    5.69          } else {
    5.70 -            result = new ClassDocImpl(this, clazz, docComment, tree, lineMap);
    5.71 +            result = new ClassDocImpl(this, clazz, treePath);
    5.72          }
    5.73          classMap.put(clazz, result);
    5.74      }
    5.75 @@ -610,13 +612,12 @@
    5.76      /**
    5.77       * Create a FieldDoc for a var symbol.
    5.78       */
    5.79 -    protected void makeFieldDoc(VarSymbol var, String docComment, JCVariableDecl tree, Position.LineMap lineMap) {
    5.80 +    protected void makeFieldDoc(VarSymbol var, TreePath treePath) {
    5.81          FieldDocImpl result = fieldMap.get(var);
    5.82          if (result != null) {
    5.83 -            if (docComment != null) result.setRawCommentText(docComment);
    5.84 -            if (tree != null) result.setTree(tree);
    5.85 +            if (treePath != null) result.setTreePath(treePath);
    5.86          } else {
    5.87 -            result = new FieldDocImpl(this, var, docComment, tree, lineMap);
    5.88 +            result = new FieldDocImpl(this, var, treePath);
    5.89              fieldMap.put(var, result);
    5.90          }
    5.91      }
    5.92 @@ -627,14 +628,12 @@
    5.93       * Create a MethodDoc for this MethodSymbol.
    5.94       * Should be called only on symbols representing methods.
    5.95       */
    5.96 -    protected void makeMethodDoc(MethodSymbol meth, String docComment,
    5.97 -                       JCMethodDecl tree, Position.LineMap lineMap) {
    5.98 +    protected void makeMethodDoc(MethodSymbol meth, TreePath treePath) {
    5.99          MethodDocImpl result = (MethodDocImpl)methodMap.get(meth);
   5.100          if (result != null) {
   5.101 -            if (docComment != null) result.setRawCommentText(docComment);
   5.102 -            if (tree != null) result.setTree(tree);
   5.103 +            if (treePath != null) result.setTreePath(treePath);
   5.104          } else {
   5.105 -            result = new MethodDocImpl(this, meth, docComment, tree, lineMap);
   5.106 +            result = new MethodDocImpl(this, meth, treePath);
   5.107              methodMap.put(meth, result);
   5.108          }
   5.109      }
   5.110 @@ -656,14 +655,12 @@
   5.111       * Create the ConstructorDoc for a MethodSymbol.
   5.112       * Should be called only on symbols representing constructors.
   5.113       */
   5.114 -    protected void makeConstructorDoc(MethodSymbol meth, String docComment,
   5.115 -                            JCMethodDecl tree, Position.LineMap lineMap) {
   5.116 +    protected void makeConstructorDoc(MethodSymbol meth, TreePath treePath) {
   5.117          ConstructorDocImpl result = (ConstructorDocImpl)methodMap.get(meth);
   5.118          if (result != null) {
   5.119 -            if (docComment != null) result.setRawCommentText(docComment);
   5.120 -            if (tree != null) result.setTree(tree);
   5.121 +            if (treePath != null) result.setTreePath(treePath);
   5.122          } else {
   5.123 -            result = new ConstructorDocImpl(this, meth, docComment, tree, lineMap);
   5.124 +            result = new ConstructorDocImpl(this, meth, treePath);
   5.125              methodMap.put(meth, result);
   5.126          }
   5.127      }
   5.128 @@ -685,16 +682,14 @@
   5.129       * Create the AnnotationTypeElementDoc for a MethodSymbol.
   5.130       * Should be called only on symbols representing annotation type elements.
   5.131       */
   5.132 -    protected void makeAnnotationTypeElementDoc(MethodSymbol meth,
   5.133 -                                      String docComment, JCMethodDecl tree, Position.LineMap lineMap) {
   5.134 +    protected void makeAnnotationTypeElementDoc(MethodSymbol meth, TreePath treePath) {
   5.135          AnnotationTypeElementDocImpl result =
   5.136              (AnnotationTypeElementDocImpl)methodMap.get(meth);
   5.137          if (result != null) {
   5.138 -            if (docComment != null) result.setRawCommentText(docComment);
   5.139 -            if (tree != null) result.setTree(tree);
   5.140 +            if (treePath != null) result.setTreePath(treePath);
   5.141          } else {
   5.142              result =
   5.143 -                new AnnotationTypeElementDocImpl(this, meth, docComment, tree, lineMap);
   5.144 +                new AnnotationTypeElementDocImpl(this, meth, treePath);
   5.145              methodMap.put(meth, result);
   5.146          }
   5.147      }
   5.148 @@ -730,6 +725,18 @@
   5.149  //      return result;
   5.150      }
   5.151  
   5.152 +    TreePath getTreePath(JCCompilationUnit tree) {
   5.153 +        TreePath p = treePaths.get(tree);
   5.154 +        if (p == null)
   5.155 +            treePaths.put(tree, p = new TreePath(tree));
   5.156 +        return p;
   5.157 +    }
   5.158 +
   5.159 +    TreePath getTreePath(JCCompilationUnit toplevel, JCTree tree) {
   5.160 +        // don't bother to cache paths for classes and members
   5.161 +        return new TreePath(getTreePath(toplevel), tree);
   5.162 +    }
   5.163 +
   5.164      /**
   5.165       * Set the encoding.
   5.166       */
     6.1 --- a/src/share/classes/com/sun/tools/javadoc/DocImpl.java	Mon Dec 10 16:21:26 2012 +0000
     6.2 +++ b/src/share/classes/com/sun/tools/javadoc/DocImpl.java	Tue Dec 11 15:05:55 2012 -0800
     6.3 @@ -35,6 +35,9 @@
     6.4  import javax.tools.FileObject;
     6.5  
     6.6  import com.sun.javadoc.*;
     6.7 +import com.sun.source.util.TreePath;
     6.8 +import com.sun.tools.javac.tree.JCTree;
     6.9 +import com.sun.tools.javac.tree.JCTree.JCCompilationUnit;
    6.10  import com.sun.tools.javac.util.Position;
    6.11  
    6.12  /**
    6.13 @@ -61,6 +64,12 @@
    6.14      protected final DocEnv env;   //### Rename this everywhere to 'docenv' ?
    6.15  
    6.16      /**
    6.17 +     * Back pointer to the tree node for this doc item.
    6.18 +     * May be null if there is no associated tree.
    6.19 +     */
    6.20 +    protected TreePath treePath;
    6.21 +
    6.22 +    /**
    6.23       *  The complex comment object, lazily initialized.
    6.24       */
    6.25      private Comment comment;
    6.26 @@ -88,11 +97,21 @@
    6.27      /**
    6.28       * Constructor.
    6.29       */
    6.30 -    DocImpl(DocEnv env, String documentation) {
    6.31 -        this.documentation = documentation;
    6.32 +    DocImpl(DocEnv env, TreePath treePath) {
    6.33 +        this.treePath = treePath;
    6.34 +        this.documentation = getCommentText(treePath);
    6.35          this.env = env;
    6.36      }
    6.37  
    6.38 +    private static String getCommentText(TreePath p) {
    6.39 +        if (p == null)
    6.40 +            return null;
    6.41 +
    6.42 +        JCCompilationUnit topLevel = (JCCompilationUnit) p.getCompilationUnit();
    6.43 +        JCTree tree = (JCTree) p.getLeaf();
    6.44 +        return topLevel.docComments.getCommentText(tree);
    6.45 +    }
    6.46 +
    6.47      /**
    6.48       * So subclasses have the option to do lazy initialization of
    6.49       * "documentation" string.
    6.50 @@ -213,11 +232,21 @@
    6.51       * operations like internalization.
    6.52       */
    6.53      public void setRawCommentText(String rawDocumentation) {
    6.54 +        treePath = null;
    6.55          documentation = rawDocumentation;
    6.56          comment = null;
    6.57      }
    6.58  
    6.59      /**
    6.60 +     * Set the full unprocessed text of the comment and tree path.
    6.61 +     */
    6.62 +    void setTreePath(TreePath treePath) {
    6.63 +        this.treePath = treePath;
    6.64 +        documentation = getCommentText(treePath);
    6.65 +        comment = null;
    6.66 +    }
    6.67 +
    6.68 +    /**
    6.69       * return a key for sorting.
    6.70       */
    6.71      CollationKey key() {
     7.1 --- a/src/share/classes/com/sun/tools/javadoc/ExecutableMemberDocImpl.java	Mon Dec 10 16:21:26 2012 +0000
     7.2 +++ b/src/share/classes/com/sun/tools/javadoc/ExecutableMemberDocImpl.java	Tue Dec 11 15:05:55 2012 -0800
     7.3 @@ -30,13 +30,12 @@
     7.4  
     7.5  import com.sun.javadoc.*;
     7.6  
     7.7 +import com.sun.source.util.TreePath;
     7.8  import com.sun.tools.javac.code.Flags;
     7.9  import com.sun.tools.javac.code.Symbol.*;
    7.10  import com.sun.tools.javac.code.Type;
    7.11 -import com.sun.tools.javac.tree.JCTree.JCMethodDecl;
    7.12  import com.sun.tools.javac.util.List;
    7.13  import com.sun.tools.javac.util.ListBuffer;
    7.14 -import com.sun.tools.javac.util.Position;
    7.15  
    7.16  /**
    7.17   * Represents a method or constructor of a java class.
    7.18 @@ -60,9 +59,8 @@
    7.19      /**
    7.20       * Constructor.
    7.21       */
    7.22 -    public ExecutableMemberDocImpl(DocEnv env, MethodSymbol sym,
    7.23 -                                   String rawDocs, JCMethodDecl tree, Position.LineMap lineMap) {
    7.24 -        super(env, sym, rawDocs, tree, lineMap);
    7.25 +    public ExecutableMemberDocImpl(DocEnv env, MethodSymbol sym, TreePath treePath) {
    7.26 +        super(env, sym, treePath);
    7.27          this.sym = sym;
    7.28      }
    7.29  
    7.30 @@ -70,7 +68,7 @@
    7.31       * Constructor.
    7.32       */
    7.33      public ExecutableMemberDocImpl(DocEnv env, MethodSymbol sym) {
    7.34 -        this(env, sym, null, null, null);
    7.35 +        this(env, sym, null);
    7.36      }
    7.37  
    7.38      /**
     8.1 --- a/src/share/classes/com/sun/tools/javadoc/FieldDocImpl.java	Mon Dec 10 16:21:26 2012 +0000
     8.2 +++ b/src/share/classes/com/sun/tools/javadoc/FieldDocImpl.java	Tue Dec 11 15:05:55 2012 -0800
     8.3 @@ -25,6 +25,7 @@
     8.4  
     8.5  package com.sun.tools.javadoc;
     8.6  
     8.7 +import com.sun.source.util.TreePath;
     8.8  import java.lang.reflect.Modifier;
     8.9  
    8.10  import com.sun.javadoc.*;
    8.11 @@ -61,9 +62,8 @@
    8.12      /**
    8.13       * Constructor.
    8.14       */
    8.15 -    public FieldDocImpl(DocEnv env, VarSymbol sym,
    8.16 -                        String rawDocs, JCVariableDecl tree, Position.LineMap lineMap) {
    8.17 -        super(env, sym, rawDocs, tree, lineMap);
    8.18 +    public FieldDocImpl(DocEnv env, VarSymbol sym, TreePath treePath) {
    8.19 +        super(env, sym, treePath);
    8.20          this.sym = sym;
    8.21      }
    8.22  
    8.23 @@ -71,7 +71,7 @@
    8.24       * Constructor.
    8.25       */
    8.26      public FieldDocImpl(DocEnv env, VarSymbol sym) {
    8.27 -        this(env, sym, null, null, null);
    8.28 +        this(env, sym, null);
    8.29      }
    8.30  
    8.31      /**
     9.1 --- a/src/share/classes/com/sun/tools/javadoc/JavadocEnter.java	Mon Dec 10 16:21:26 2012 +0000
     9.2 +++ b/src/share/classes/com/sun/tools/javadoc/JavadocEnter.java	Tue Dec 11 15:05:55 2012 -0800
     9.3 @@ -25,13 +25,14 @@
     9.4  
     9.5  package com.sun.tools.javadoc;
     9.6  
     9.7 +
     9.8  import javax.tools.JavaFileObject;
     9.9  
    9.10 +import com.sun.source.util.TreePath;
    9.11  import com.sun.tools.javac.code.Kinds;
    9.12  import com.sun.tools.javac.code.Symbol.*;
    9.13  import com.sun.tools.javac.comp.Enter;
    9.14  import com.sun.tools.javac.tree.JCTree.*;
    9.15 -import com.sun.tools.javac.tree.TreeInfo;
    9.16  import com.sun.tools.javac.util.Context;
    9.17  import com.sun.tools.javac.util.JCDiagnostic.DiagnosticPosition;
    9.18  import com.sun.tools.javac.util.List;
    9.19 @@ -85,8 +86,7 @@
    9.20      public void visitTopLevel(JCCompilationUnit tree) {
    9.21          super.visitTopLevel(tree);
    9.22          if (tree.sourcefile.isNameCompatible("package-info", JavaFileObject.Kind.SOURCE)) {
    9.23 -            String comment = TreeInfo.getCommentText(env, tree);
    9.24 -            docenv.makePackageDoc(tree.packge, comment, tree);
    9.25 +            docenv.makePackageDoc(tree.packge, docenv.getTreePath(tree));
    9.26          }
    9.27      }
    9.28  
    9.29 @@ -95,9 +95,8 @@
    9.30          super.visitClassDef(tree);
    9.31          if (tree.sym == null) return;
    9.32          if (tree.sym.kind == Kinds.TYP || tree.sym.kind == Kinds.ERR) {
    9.33 -            String comment = TreeInfo.getCommentText(env, tree);
    9.34              ClassSymbol c = tree.sym;
    9.35 -            docenv.makeClassDoc(c, comment, tree, env.toplevel.lineMap);
    9.36 +            docenv.makeClassDoc(c, docenv.getTreePath(env.toplevel, tree));
    9.37          }
    9.38      }
    9.39  
    10.1 --- a/src/share/classes/com/sun/tools/javadoc/JavadocMemberEnter.java	Mon Dec 10 16:21:26 2012 +0000
    10.2 +++ b/src/share/classes/com/sun/tools/javadoc/JavadocMemberEnter.java	Tue Dec 11 15:05:55 2012 -0800
    10.3 @@ -25,14 +25,13 @@
    10.4  
    10.5  package com.sun.tools.javadoc;
    10.6  
    10.7 +import com.sun.source.util.TreePath;
    10.8  import com.sun.tools.javac.code.Flags;
    10.9  import com.sun.tools.javac.code.Kinds;
   10.10  import com.sun.tools.javac.code.Symbol.*;
   10.11  import com.sun.tools.javac.comp.MemberEnter;
   10.12  import com.sun.tools.javac.tree.JCTree.*;
   10.13 -import com.sun.tools.javac.tree.TreeInfo;
   10.14  import com.sun.tools.javac.util.Context;
   10.15 -import com.sun.tools.javac.util.Position;
   10.16  
   10.17  /**
   10.18   *  Javadoc's own memberEnter phase does a few things above and beyond that
   10.19 @@ -73,14 +72,13 @@
   10.20          super.visitMethodDef(tree);
   10.21          MethodSymbol meth = tree.sym;
   10.22          if (meth == null || meth.kind != Kinds.MTH) return;
   10.23 -        String docComment = TreeInfo.getCommentText(env, tree);
   10.24 -        Position.LineMap lineMap = env.toplevel.lineMap;
   10.25 +        TreePath treePath = docenv.getTreePath(env.toplevel, tree);
   10.26          if (meth.isConstructor())
   10.27 -            docenv.makeConstructorDoc(meth, docComment, tree, lineMap);
   10.28 +            docenv.makeConstructorDoc(meth, treePath);
   10.29          else if (isAnnotationTypeElement(meth))
   10.30 -            docenv.makeAnnotationTypeElementDoc(meth, docComment, tree, lineMap);
   10.31 +            docenv.makeAnnotationTypeElementDoc(meth, treePath);
   10.32          else
   10.33 -            docenv.makeMethodDoc(meth, docComment, tree, lineMap);
   10.34 +            docenv.makeMethodDoc(meth, treePath);
   10.35  
   10.36          // release resources
   10.37          tree.body = null;
   10.38 @@ -92,9 +90,7 @@
   10.39          if (tree.sym != null &&
   10.40                  tree.sym.kind == Kinds.VAR &&
   10.41                  !isParameter(tree.sym)) {
   10.42 -            String docComment = TreeInfo.getCommentText(env, tree);
   10.43 -            Position.LineMap lineMap = env.toplevel.lineMap;
   10.44 -            docenv.makeFieldDoc(tree.sym, docComment, tree, lineMap);
   10.45 +            docenv.makeFieldDoc(tree.sym, docenv.getTreePath(env.toplevel, tree));
   10.46          }
   10.47      }
   10.48  
    11.1 --- a/src/share/classes/com/sun/tools/javadoc/MemberDocImpl.java	Mon Dec 10 16:21:26 2012 +0000
    11.2 +++ b/src/share/classes/com/sun/tools/javadoc/MemberDocImpl.java	Tue Dec 11 15:05:55 2012 -0800
    11.3 @@ -27,9 +27,8 @@
    11.4  
    11.5  import com.sun.javadoc.*;
    11.6  
    11.7 +import com.sun.source.util.TreePath;
    11.8  import com.sun.tools.javac.code.Symbol;
    11.9 -import com.sun.tools.javac.tree.JCTree;
   11.10 -import com.sun.tools.javac.util.Position;
   11.11  
   11.12  /**
   11.13   * Represents a member of a java class: field, constructor, or method.
   11.14 @@ -57,8 +56,8 @@
   11.15      /**
   11.16       * constructor.
   11.17       */
   11.18 -    public MemberDocImpl(DocEnv env, Symbol sym, String doc, JCTree tree, Position.LineMap lineMap) {
   11.19 -        super(env, sym, doc, tree, lineMap);
   11.20 +    public MemberDocImpl(DocEnv env, Symbol sym, TreePath treePath) {
   11.21 +        super(env, sym, treePath);
   11.22      }
   11.23  
   11.24      /**
    12.1 --- a/src/share/classes/com/sun/tools/javadoc/MethodDocImpl.java	Mon Dec 10 16:21:26 2012 +0000
    12.2 +++ b/src/share/classes/com/sun/tools/javadoc/MethodDocImpl.java	Tue Dec 11 15:05:55 2012 -0800
    12.3 @@ -28,12 +28,10 @@
    12.4  import java.lang.reflect.Modifier;
    12.5  
    12.6  import com.sun.javadoc.*;
    12.7 +import com.sun.source.util.TreePath;
    12.8  import com.sun.tools.javac.code.*;
    12.9  import com.sun.tools.javac.code.Symbol.*;
   12.10  import com.sun.tools.javac.code.Type;
   12.11 -import com.sun.tools.javac.tree.JCTree.JCMethodDecl;
   12.12 -import com.sun.tools.javac.util.Position;
   12.13 -
   12.14  import static com.sun.tools.javac.code.TypeTag.CLASS;
   12.15  
   12.16  /**
   12.17 @@ -62,9 +60,8 @@
   12.18      /**
   12.19       * constructor.
   12.20       */
   12.21 -    public MethodDocImpl(DocEnv env, MethodSymbol sym,
   12.22 -                         String docComment, JCMethodDecl tree, Position.LineMap lineMap) {
   12.23 -        super(env, sym, docComment, tree, lineMap);
   12.24 +    public MethodDocImpl(DocEnv env, MethodSymbol sym, TreePath treePath) {
   12.25 +        super(env, sym, treePath);
   12.26      }
   12.27  
   12.28      /**
    13.1 --- a/src/share/classes/com/sun/tools/javadoc/PackageDocImpl.java	Mon Dec 10 16:21:26 2012 +0000
    13.2 +++ b/src/share/classes/com/sun/tools/javadoc/PackageDocImpl.java	Tue Dec 11 15:05:55 2012 -0800
    13.3 @@ -31,6 +31,7 @@
    13.4  import javax.tools.FileObject;
    13.5  
    13.6  import com.sun.javadoc.*;
    13.7 +import com.sun.source.util.TreePath;
    13.8  import com.sun.tools.javac.code.Attribute;
    13.9  import com.sun.tools.javac.code.Scope;
   13.10  import com.sun.tools.javac.code.Symbol.ClassSymbol;
   13.11 @@ -75,17 +76,16 @@
   13.12       * Constructor
   13.13       */
   13.14      public PackageDocImpl(DocEnv env, PackageSymbol sym) {
   13.15 -        this(env, sym, null, null);
   13.16 +        this(env, sym, null);
   13.17      }
   13.18  
   13.19      /**
   13.20       * Constructor
   13.21       */
   13.22 -    public PackageDocImpl(DocEnv env, PackageSymbol sym,
   13.23 -                          String documentation, JCTree tree) {
   13.24 -        super(env, documentation);
   13.25 +    public PackageDocImpl(DocEnv env, PackageSymbol sym, TreePath treePath) {
   13.26 +        super(env, treePath);
   13.27          this.sym = sym;
   13.28 -        this.tree = (JCCompilationUnit) tree;
   13.29 +        this.tree = (treePath == null) ? null : (JCCompilationUnit) treePath.getCompilationUnit();
   13.30          foundDoc = (documentation != null);
   13.31      }
   13.32  
   13.33 @@ -93,8 +93,8 @@
   13.34          this.tree = (JCCompilationUnit) tree;
   13.35      }
   13.36  
   13.37 -    public void setRawCommentText(String rawDocumentation) {
   13.38 -        super.setRawCommentText(rawDocumentation);
   13.39 +    public void setTreePath(TreePath treePath) {
   13.40 +        super.setTreePath(treePath);
   13.41          checkDoc();
   13.42      }
   13.43  
    14.1 --- a/src/share/classes/com/sun/tools/javadoc/ProgramElementDocImpl.java	Mon Dec 10 16:21:26 2012 +0000
    14.2 +++ b/src/share/classes/com/sun/tools/javadoc/ProgramElementDocImpl.java	Tue Dec 11 15:05:55 2012 -0800
    14.3 @@ -29,10 +29,12 @@
    14.4  import java.text.CollationKey;
    14.5  
    14.6  import com.sun.javadoc.*;
    14.7 +import com.sun.source.util.TreePath;
    14.8  import com.sun.tools.javac.code.Attribute;
    14.9  import com.sun.tools.javac.code.Symbol;
   14.10  import com.sun.tools.javac.code.Symbol.ClassSymbol;
   14.11  import com.sun.tools.javac.tree.JCTree;
   14.12 +import com.sun.tools.javac.tree.JCTree.JCCompilationUnit;
   14.13  import com.sun.tools.javac.util.Position;
   14.14  
   14.15  /**
   14.16 @@ -66,16 +68,20 @@
   14.17      // Cache for getModifiers().
   14.18      private int modifiers = -1;
   14.19  
   14.20 -    protected ProgramElementDocImpl(DocEnv env, Symbol sym,
   14.21 -                                    String doc, JCTree tree, Position.LineMap lineMap) {
   14.22 -        super(env, doc);
   14.23 +    protected ProgramElementDocImpl(DocEnv env, Symbol sym, TreePath treePath) {
   14.24 +        super(env, treePath);
   14.25          this.sym = sym;
   14.26 -        this.tree = tree;
   14.27 -        this.lineMap = lineMap;
   14.28 +        if (treePath != null) {
   14.29 +            tree = (JCTree) treePath.getLeaf();
   14.30 +            lineMap = ((JCCompilationUnit) treePath.getCompilationUnit()).lineMap;
   14.31 +        }
   14.32      }
   14.33  
   14.34 -    void setTree(JCTree tree) {
   14.35 -        this.tree = tree;
   14.36 +    @Override
   14.37 +    void setTreePath(TreePath treePath) {
   14.38 +        super.setTreePath(treePath);
   14.39 +        this.tree = (JCTree) treePath.getLeaf();
   14.40 +        this.lineMap = ((JCCompilationUnit) treePath.getCompilationUnit()).lineMap;
   14.41      }
   14.42  
   14.43      /**
    15.1 --- a/src/share/classes/com/sun/tools/javadoc/RootDocImpl.java	Mon Dec 10 16:21:26 2012 +0000
    15.2 +++ b/src/share/classes/com/sun/tools/javadoc/RootDocImpl.java	Tue Dec 11 15:05:55 2012 -0800
    15.3 @@ -331,7 +331,6 @@
    15.4      @Override
    15.5      protected String documentation() {
    15.6          if (documentation == null) {
    15.7 -            int cnt = options.length();
    15.8              JavaFileObject overviewPath = getOverviewPath();
    15.9              if (overviewPath == null) {
   15.10                  // no doc file to be had

mercurial