1 /* |
1 /* |
2 * Copyright (c) 1998, 2013, Oracle and/or its affiliates. All rights reserved. |
2 * Copyright (c) 1998, 2014, Oracle and/or its affiliates. All rights reserved. |
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 * |
4 * |
5 * This code is free software; you can redistribute it and/or modify it |
5 * This code is free software; you can redistribute it and/or modify it |
6 * under the terms of the GNU General Public License version 2 only, as |
6 * under the terms of the GNU General Public License version 2 only, as |
7 * published by the Free Software Foundation. Oracle designates this |
7 * published by the Free Software Foundation. Oracle designates this |
79 /** |
79 /** |
80 * Mapping for each Interface with classes who implement it. |
80 * Mapping for each Interface with classes who implement it. |
81 */ |
81 */ |
82 private Map<ClassDoc,List<ClassDoc>> implementingclasses = new HashMap<>(); |
82 private Map<ClassDoc,List<ClassDoc>> implementingclasses = new HashMap<>(); |
83 |
83 |
|
84 private final Configuration configuration; |
|
85 private final Utils utils; |
84 /** |
86 /** |
85 * Constructor. Build the Tree using the Root of this Javadoc run. |
87 * Constructor. Build the Tree using the Root of this Javadoc run. |
86 * |
88 * |
87 * @param configuration the configuration of the doclet. |
89 * @param configuration the configuration of the doclet. |
88 * @param noDeprecated Don't add deprecated classes in the class tree, if |
90 * @param noDeprecated Don't add deprecated classes in the class tree, if |
89 * true. |
91 * true. |
90 */ |
92 */ |
91 public ClassTree(Configuration configuration, boolean noDeprecated) { |
93 public ClassTree(Configuration configuration, boolean noDeprecated) { |
92 configuration.message.notice("doclet.Building_Tree"); |
94 configuration.message.notice("doclet.Building_Tree"); |
93 buildTree(configuration.root.classes(), configuration); |
95 this.configuration = configuration; |
|
96 this.utils = configuration.utils; |
|
97 buildTree(configuration.root.classes()); |
94 } |
98 } |
95 |
99 |
96 /** |
100 /** |
97 * Constructor. Build the Tree using the Root of this Javadoc run. |
101 * Constructor. Build the Tree using the Root of this Javadoc run. |
98 * |
102 * |
99 * @param root Root of the Document. |
103 * @param root Root of the Document. |
100 * @param configuration The curren configuration of the doclet. |
104 * @param configuration The current configuration of the doclet. |
101 */ |
105 */ |
102 public ClassTree(RootDoc root, Configuration configuration) { |
106 public ClassTree(RootDoc root, Configuration configuration) { |
103 buildTree(root.classes(), configuration); |
107 this.configuration = configuration; |
|
108 this.utils = configuration.utils; |
|
109 buildTree(root.classes()); |
104 } |
110 } |
105 |
111 |
106 /** |
112 /** |
107 * Constructor. Build the tree for the given array of classes. |
113 * Constructor. Build the tree for the given array of classes. |
108 * |
114 * |
109 * @param classes Array of classes. |
115 * @param classes Array of classes. |
110 * @param configuration The curren configuration of the doclet. |
116 * @param configuration The curren configuration of the doclet. |
111 */ |
117 */ |
112 public ClassTree(ClassDoc[] classes, Configuration configuration) { |
118 public ClassTree(ClassDoc[] classes, Configuration configuration) { |
113 buildTree(classes, configuration); |
119 this.configuration = configuration; |
|
120 this.utils = configuration.utils; |
|
121 buildTree(classes); |
114 } |
122 } |
115 |
123 |
116 /** |
124 /** |
117 * Generate mapping for the sub-classes for every class in this run. |
125 * Generate mapping for the sub-classes for every class in this run. |
118 * Return the sub-class list for java.lang.Object which will be having |
126 * Return the sub-class list for java.lang.Object which will be having |
120 * have their own sub-class lists. |
128 * have their own sub-class lists. |
121 * |
129 * |
122 * @param classes all the classes in this run. |
130 * @param classes all the classes in this run. |
123 * @param configuration the current configuration of the doclet. |
131 * @param configuration the current configuration of the doclet. |
124 */ |
132 */ |
125 private void buildTree(ClassDoc[] classes, Configuration configuration) { |
133 private void buildTree(ClassDoc[] classes) { |
126 for (ClassDoc aClass : classes) { |
134 for (ClassDoc aClass : classes) { |
127 // In the tree page (e.g overview-tree.html) do not include |
135 // In the tree page (e.g overview-tree.html) do not include |
128 // information of classes which are deprecated or are a part of a |
136 // information of classes which are deprecated or are a part of a |
129 // deprecated package. |
137 // deprecated package. |
130 if (configuration.nodeprecated && |
138 if (configuration.nodeprecated && |
131 (Util.isDeprecated(aClass) || |
139 (utils.isDeprecated(aClass) || |
132 Util.isDeprecated(aClass.containingPackage()))) { |
140 utils.isDeprecated(aClass.containingPackage()))) { |
133 continue; |
141 continue; |
134 } |
142 } |
135 |
143 |
136 if (configuration.javafx |
144 if (configuration.javafx |
137 && aClass.tags("treatAsPrivate").length > 0) { |
145 && aClass.tags("treatAsPrivate").length > 0) { |
175 * @param cd class for which sub-class mapping to be generated. |
183 * @param cd class for which sub-class mapping to be generated. |
176 * @param configuration the current configurtation of the doclet. |
184 * @param configuration the current configurtation of the doclet. |
177 */ |
185 */ |
178 private void processType(ClassDoc cd, Configuration configuration, |
186 private void processType(ClassDoc cd, Configuration configuration, |
179 List<ClassDoc> bases, Map<ClassDoc,List<ClassDoc>> subs) { |
187 List<ClassDoc> bases, Map<ClassDoc,List<ClassDoc>> subs) { |
180 ClassDoc superclass = Util.getFirstVisibleSuperClassCD(cd, configuration); |
188 ClassDoc superclass = utils.getFirstVisibleSuperClassCD(cd, configuration); |
181 if (superclass != null) { |
189 if (superclass != null) { |
182 if (!add(subs, superclass, cd)) { |
190 if (!add(subs, superclass, cd)) { |
183 return; |
191 return; |
184 } else { |
192 } else { |
185 processType(superclass, configuration, bases, subs); |
193 processType(superclass, configuration, bases, subs); |
187 } else { // cd is java.lang.Object, add it once to the list |
195 } else { // cd is java.lang.Object, add it once to the list |
188 if (!bases.contains(cd)) { |
196 if (!bases.contains(cd)) { |
189 bases.add(cd); |
197 bases.add(cd); |
190 } |
198 } |
191 } |
199 } |
192 List<Type> intfacs = Util.getAllInterfaces(cd, configuration); |
200 List<Type> intfacs = utils.getAllInterfaces(cd, configuration); |
193 for (Type intfac : intfacs) { |
201 for (Type intfac : intfacs) { |
194 add(implementingclasses, intfac.asClassDoc(), cd); |
202 add(implementingclasses, intfac.asClassDoc(), cd); |
195 } |
203 } |
196 } |
204 } |
197 |
205 |