equal
deleted
inserted
replaced
60 * @author Robert Field |
60 * @author Robert Field |
61 * @author Neal Gafter (rewrite) |
61 * @author Neal Gafter (rewrite) |
62 * @author Scott Seligman (generics) |
62 * @author Scott Seligman (generics) |
63 */ |
63 */ |
64 public class DocEnv { |
64 public class DocEnv { |
65 protected static final Context.Key<DocEnv> docEnvKey = |
65 protected static final Context.Key<DocEnv> docEnvKey = new Context.Key<>(); |
66 new Context.Key<DocEnv>(); |
|
67 |
66 |
68 public static DocEnv instance(Context context) { |
67 public static DocEnv instance(Context context) { |
69 DocEnv instance = context.get(docEnvKey); |
68 DocEnv instance = context.get(docEnvKey); |
70 if (instance == null) |
69 if (instance == null) |
71 instance = new DocEnv(context); |
70 instance = new DocEnv(context); |
108 Types types; |
107 Types types; |
109 JavaFileManager fileManager; |
108 JavaFileManager fileManager; |
110 Context context; |
109 Context context; |
111 DocLint doclint; |
110 DocLint doclint; |
112 |
111 |
113 WeakHashMap<JCTree, TreePath> treePaths = new WeakHashMap<JCTree, TreePath>(); |
112 WeakHashMap<JCTree, TreePath> treePaths = new WeakHashMap<>(); |
114 |
113 |
115 /** Allow documenting from class files? */ |
114 /** Allow documenting from class files? */ |
116 boolean docClasses = false; |
115 boolean docClasses = false; |
117 |
116 |
118 /** Does the doclet only expect pre-1.5 doclet API? */ |
117 /** Does the doclet only expect pre-1.5 doclet API? */ |
542 // compilation environment. This can probably |
541 // compilation environment. This can probably |
543 // subsume DocEnv as well. |
542 // subsume DocEnv as well. |
544 messager.exit(); |
543 messager.exit(); |
545 } |
544 } |
546 |
545 |
547 protected Map<PackageSymbol, PackageDocImpl> packageMap = |
546 protected Map<PackageSymbol, PackageDocImpl> packageMap = new HashMap<>(); |
548 new HashMap<PackageSymbol, PackageDocImpl>(); |
|
549 /** |
547 /** |
550 * Return the PackageDoc of this package symbol. |
548 * Return the PackageDoc of this package symbol. |
551 */ |
549 */ |
552 public PackageDocImpl getPackageDoc(PackageSymbol pack) { |
550 public PackageDocImpl getPackageDoc(PackageSymbol pack) { |
553 PackageDocImpl result = packageMap.get(pack); |
551 PackageDocImpl result = packageMap.get(pack); |
569 packageMap.put(pack, result); |
567 packageMap.put(pack, result); |
570 } |
568 } |
571 } |
569 } |
572 |
570 |
573 |
571 |
574 protected Map<ClassSymbol, ClassDocImpl> classMap = |
572 protected Map<ClassSymbol, ClassDocImpl> classMap = new HashMap<>(); |
575 new HashMap<ClassSymbol, ClassDocImpl>(); |
|
576 /** |
573 /** |
577 * Return the ClassDoc (or a subtype) of this class symbol. |
574 * Return the ClassDoc (or a subtype) of this class symbol. |
578 */ |
575 */ |
579 public ClassDocImpl getClassDoc(ClassSymbol clazz) { |
576 public ClassDocImpl getClassDoc(ClassSymbol clazz) { |
580 ClassDocImpl result = classMap.get(clazz); |
577 ClassDocImpl result = classMap.get(clazz); |
611 |
608 |
612 protected static boolean isAnnotationType(JCClassDecl tree) { |
609 protected static boolean isAnnotationType(JCClassDecl tree) { |
613 return (tree.mods.flags & Flags.ANNOTATION) != 0; |
610 return (tree.mods.flags & Flags.ANNOTATION) != 0; |
614 } |
611 } |
615 |
612 |
616 protected Map<VarSymbol, FieldDocImpl> fieldMap = |
613 protected Map<VarSymbol, FieldDocImpl> fieldMap = new HashMap<>(); |
617 new HashMap<VarSymbol, FieldDocImpl>(); |
|
618 /** |
614 /** |
619 * Return the FieldDoc of this var symbol. |
615 * Return the FieldDoc of this var symbol. |
620 */ |
616 */ |
621 public FieldDocImpl getFieldDoc(VarSymbol var) { |
617 public FieldDocImpl getFieldDoc(VarSymbol var) { |
622 FieldDocImpl result = fieldMap.get(var); |
618 FieldDocImpl result = fieldMap.get(var); |
636 result = new FieldDocImpl(this, var, treePath); |
632 result = new FieldDocImpl(this, var, treePath); |
637 fieldMap.put(var, result); |
633 fieldMap.put(var, result); |
638 } |
634 } |
639 } |
635 } |
640 |
636 |
641 protected Map<MethodSymbol, ExecutableMemberDocImpl> methodMap = |
637 protected Map<MethodSymbol, ExecutableMemberDocImpl> methodMap = new HashMap<>(); |
642 new HashMap<MethodSymbol, ExecutableMemberDocImpl>(); |
|
643 /** |
638 /** |
644 * Create a MethodDoc for this MethodSymbol. |
639 * Create a MethodDoc for this MethodSymbol. |
645 * Should be called only on symbols representing methods. |
640 * Should be called only on symbols representing methods. |
646 */ |
641 */ |
647 protected void makeMethodDoc(MethodSymbol meth, TreePath treePath) { |
642 protected void makeMethodDoc(MethodSymbol meth, TreePath treePath) { |
803 result |= Modifier.VOLATILE; |
798 result |= Modifier.VOLATILE; |
804 return result; |
799 return result; |
805 } |
800 } |
806 |
801 |
807 void initDoclint(Collection<String> opts, Collection<String> customTagNames) { |
802 void initDoclint(Collection<String> opts, Collection<String> customTagNames) { |
808 ArrayList<String> doclintOpts = new ArrayList<String>(); |
803 ArrayList<String> doclintOpts = new ArrayList<>(); |
809 |
804 |
810 for (String opt: opts) { |
805 for (String opt: opts) { |
811 doclintOpts.add(opt == null ? DocLint.XMSGS_OPTION : DocLint.XMSGS_CUSTOM_PREFIX + opt); |
806 doclintOpts.add(opt == null ? DocLint.XMSGS_OPTION : DocLint.XMSGS_CUSTOM_PREFIX + opt); |
812 } |
807 } |
813 |
808 |