author | ksrini |
Tue, 28 Jun 2016 16:43:41 -0700 | |
changeset 39364 | bd6d4a7936b4 |
parent 37009 | 476d8d615222 |
child 40303 | 96a1226aca18 |
permissions | -rw-r--r-- |
10 | 1 |
/* |
35426
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
26270
diff
changeset
|
2 |
* Copyright (c) 1998, 2016, Oracle and/or its affiliates. All rights reserved. |
10 | 3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 |
* |
|
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 |
|
5520 | 7 |
* published by the Free Software Foundation. Oracle designates this |
10 | 8 |
* particular file as subject to the "Classpath" exception as provided |
5520 | 9 |
* by Oracle in the LICENSE file that accompanied this code. |
10 | 10 |
* |
11 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
|
12 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
|
13 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
|
14 |
* version 2 for more details (a copy is included in the LICENSE file that |
|
15 |
* accompanied this code). |
|
16 |
* |
|
17 |
* You should have received a copy of the GNU General Public License version |
|
18 |
* 2 along with this work; if not, write to the Free Software Foundation, |
|
19 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
|
20 |
* |
|
5520 | 21 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
22 |
* or visit www.oracle.com if you need additional information or have any |
|
23 |
* questions. |
|
10 | 24 |
*/ |
25 |
||
35426
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
26270
diff
changeset
|
26 |
package jdk.javadoc.internal.doclets.toolkit.util; |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
26270
diff
changeset
|
27 |
|
10 | 28 |
|
35426
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
26270
diff
changeset
|
29 |
import java.util.ArrayList; |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
26270
diff
changeset
|
30 |
import java.util.Collection; |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
26270
diff
changeset
|
31 |
import java.util.Collections; |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
26270
diff
changeset
|
32 |
import java.util.Comparator; |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
26270
diff
changeset
|
33 |
import java.util.HashMap; |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
26270
diff
changeset
|
34 |
import java.util.Iterator; |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
26270
diff
changeset
|
35 |
import java.util.List; |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
26270
diff
changeset
|
36 |
import java.util.Map; |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
26270
diff
changeset
|
37 |
import java.util.Set; |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
26270
diff
changeset
|
38 |
import java.util.SortedSet; |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
26270
diff
changeset
|
39 |
import java.util.TreeSet; |
14258 | 40 |
|
35426
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
26270
diff
changeset
|
41 |
import javax.lang.model.element.Element; |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
26270
diff
changeset
|
42 |
import javax.lang.model.element.TypeElement; |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
26270
diff
changeset
|
43 |
import javax.lang.model.type.TypeMirror; |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
26270
diff
changeset
|
44 |
|
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
26270
diff
changeset
|
45 |
import jdk.javadoc.doclet.DocletEnvironment; |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
26270
diff
changeset
|
46 |
import jdk.javadoc.internal.doclets.toolkit.Configuration; |
10 | 47 |
|
48 |
/** |
|
49 |
* Build Class Hierarchy for all the Classes. This class builds the Class |
|
50 |
* Tree and the Interface Tree separately. |
|
51 |
* |
|
14260
727a84636f12
8000665: fix "internal API" comments on javadoc files
jjg
parents:
14258
diff
changeset
|
52 |
* <p><b>This is NOT part of any supported API. |
727a84636f12
8000665: fix "internal API" comments on javadoc files
jjg
parents:
14258
diff
changeset
|
53 |
* If you write code that depends on this, you do so at your own risk. |
727a84636f12
8000665: fix "internal API" comments on javadoc files
jjg
parents:
14258
diff
changeset
|
54 |
* This code and its internal interfaces are subject to change or |
727a84636f12
8000665: fix "internal API" comments on javadoc files
jjg
parents:
14258
diff
changeset
|
55 |
* deletion without notice.</b> |
10 | 56 |
* |
57 |
* @see java.util.HashMap |
|
58 |
* @see java.util.List |
|
59 |
* @author Atul M Dambalkar |
|
60 |
*/ |
|
61 |
public class ClassTree { |
|
62 |
||
63 |
/** |
|
35426
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
26270
diff
changeset
|
64 |
* List of base classes. Used to get the mapped listing of sub-classes. |
10 | 65 |
*/ |
35426
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
26270
diff
changeset
|
66 |
private final SortedSet<TypeElement> baseClasses; |
10 | 67 |
|
68 |
/** |
|
35426
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
26270
diff
changeset
|
69 |
* Mapping for each Class with their sub classes |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
26270
diff
changeset
|
70 |
*/ |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
26270
diff
changeset
|
71 |
private final Map<TypeElement, SortedSet<TypeElement>> subClasses = new HashMap<>(); |
10 | 72 |
|
73 |
/** |
|
35426
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
26270
diff
changeset
|
74 |
* List of base-interfaces. Contains set of all the interfaces who do not |
10 | 75 |
* have super-interfaces. Can be used to get the mapped listing of |
76 |
* sub-interfaces. |
|
77 |
*/ |
|
35426
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
26270
diff
changeset
|
78 |
private final SortedSet<TypeElement> baseInterfaces; |
10 | 79 |
|
35426
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
26270
diff
changeset
|
80 |
/** |
10 | 81 |
* Mapping for each Interface with their SubInterfaces |
82 |
*/ |
|
35426
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
26270
diff
changeset
|
83 |
private final Map<TypeElement, SortedSet<TypeElement>> subInterfaces = new HashMap<>(); |
10 | 84 |
|
35426
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
26270
diff
changeset
|
85 |
private final SortedSet<TypeElement> baseEnums; |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
26270
diff
changeset
|
86 |
private final Map<TypeElement, SortedSet<TypeElement>> subEnums = new HashMap<>(); |
10 | 87 |
|
35426
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
26270
diff
changeset
|
88 |
private final SortedSet<TypeElement> baseAnnotationTypes; |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
26270
diff
changeset
|
89 |
private final Map<TypeElement, SortedSet<TypeElement>> subAnnotationTypes = new HashMap<>(); |
10 | 90 |
|
35426
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
26270
diff
changeset
|
91 |
/** |
10 | 92 |
* Mapping for each Interface with classes who implement it. |
93 |
*/ |
|
35426
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
26270
diff
changeset
|
94 |
private final Map<TypeElement, SortedSet<TypeElement>> implementingClasses = new HashMap<>(); |
10 | 95 |
|
25454
376a52c9540c
8039028: [javadoc] refactor the usage of Util.java
ksrini
parents:
22163
diff
changeset
|
96 |
private final Configuration configuration; |
376a52c9540c
8039028: [javadoc] refactor the usage of Util.java
ksrini
parents:
22163
diff
changeset
|
97 |
private final Utils utils; |
35426
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
26270
diff
changeset
|
98 |
private final Comparator<Element> comparator; |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
26270
diff
changeset
|
99 |
|
10 | 100 |
/** |
101 |
* Constructor. Build the Tree using the Root of this Javadoc run. |
|
102 |
* |
|
103 |
* @param configuration the configuration of the doclet. |
|
104 |
* @param noDeprecated Don't add deprecated classes in the class tree, if |
|
105 |
* true. |
|
106 |
*/ |
|
107 |
public ClassTree(Configuration configuration, boolean noDeprecated) { |
|
108 |
configuration.message.notice("doclet.Building_Tree"); |
|
25454
376a52c9540c
8039028: [javadoc] refactor the usage of Util.java
ksrini
parents:
22163
diff
changeset
|
109 |
this.configuration = configuration; |
376a52c9540c
8039028: [javadoc] refactor the usage of Util.java
ksrini
parents:
22163
diff
changeset
|
110 |
this.utils = configuration.utils; |
35426
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
26270
diff
changeset
|
111 |
comparator = utils.makeClassUseComparator(); |
26270
a3635e6d3d78
8050031: [javadoc] class-use pages have duplicates and missing entries
ksrini
parents:
25874
diff
changeset
|
112 |
baseAnnotationTypes = new TreeSet<>(comparator); |
a3635e6d3d78
8050031: [javadoc] class-use pages have duplicates and missing entries
ksrini
parents:
25874
diff
changeset
|
113 |
baseEnums = new TreeSet<>(comparator); |
35426
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
26270
diff
changeset
|
114 |
baseClasses = new TreeSet<>(comparator); |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
26270
diff
changeset
|
115 |
baseInterfaces = new TreeSet<>(comparator); |
39364
bd6d4a7936b4
8160301: javadoc RootDoclmpl and DocEnv needs to be renamed
ksrini
parents:
37009
diff
changeset
|
116 |
buildTree(configuration.docEnv.getIncludedClasses()); |
10 | 117 |
} |
118 |
||
119 |
/** |
|
120 |
* Constructor. Build the Tree using the Root of this Javadoc run. |
|
121 |
* |
|
122 |
* @param root Root of the Document. |
|
25454
376a52c9540c
8039028: [javadoc] refactor the usage of Util.java
ksrini
parents:
22163
diff
changeset
|
123 |
* @param configuration The current configuration of the doclet. |
10 | 124 |
*/ |
35426
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
26270
diff
changeset
|
125 |
public ClassTree(DocletEnvironment root, Configuration configuration) { |
25454
376a52c9540c
8039028: [javadoc] refactor the usage of Util.java
ksrini
parents:
22163
diff
changeset
|
126 |
this.configuration = configuration; |
376a52c9540c
8039028: [javadoc] refactor the usage of Util.java
ksrini
parents:
22163
diff
changeset
|
127 |
this.utils = configuration.utils; |
35426
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
26270
diff
changeset
|
128 |
comparator = utils.makeClassUseComparator(); |
26270
a3635e6d3d78
8050031: [javadoc] class-use pages have duplicates and missing entries
ksrini
parents:
25874
diff
changeset
|
129 |
baseAnnotationTypes = new TreeSet<>(comparator); |
a3635e6d3d78
8050031: [javadoc] class-use pages have duplicates and missing entries
ksrini
parents:
25874
diff
changeset
|
130 |
baseEnums = new TreeSet<>(comparator); |
35426
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
26270
diff
changeset
|
131 |
baseClasses = new TreeSet<>(comparator); |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
26270
diff
changeset
|
132 |
baseInterfaces = new TreeSet<>(comparator); |
39364
bd6d4a7936b4
8160301: javadoc RootDoclmpl and DocEnv needs to be renamed
ksrini
parents:
37009
diff
changeset
|
133 |
buildTree(configuration.docEnv.getIncludedClasses()); |
10 | 134 |
} |
135 |
||
136 |
/** |
|
137 |
* Constructor. Build the tree for the given array of classes. |
|
138 |
* |
|
35426
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
26270
diff
changeset
|
139 |
* @param classesSet a set of classes |
26270
a3635e6d3d78
8050031: [javadoc] class-use pages have duplicates and missing entries
ksrini
parents:
25874
diff
changeset
|
140 |
* @param configuration The current configuration of the doclet. |
10 | 141 |
*/ |
35426
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
26270
diff
changeset
|
142 |
public ClassTree(SortedSet<TypeElement>classesSet, Configuration configuration) { |
25454
376a52c9540c
8039028: [javadoc] refactor the usage of Util.java
ksrini
parents:
22163
diff
changeset
|
143 |
this.configuration = configuration; |
376a52c9540c
8039028: [javadoc] refactor the usage of Util.java
ksrini
parents:
22163
diff
changeset
|
144 |
this.utils = configuration.utils; |
35426
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
26270
diff
changeset
|
145 |
comparator = utils.makeClassUseComparator(); |
26270
a3635e6d3d78
8050031: [javadoc] class-use pages have duplicates and missing entries
ksrini
parents:
25874
diff
changeset
|
146 |
baseAnnotationTypes = new TreeSet<>(comparator); |
a3635e6d3d78
8050031: [javadoc] class-use pages have duplicates and missing entries
ksrini
parents:
25874
diff
changeset
|
147 |
baseEnums = new TreeSet<>(comparator); |
35426
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
26270
diff
changeset
|
148 |
baseClasses = new TreeSet<>(comparator); |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
26270
diff
changeset
|
149 |
baseInterfaces = new TreeSet<>(comparator); |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
26270
diff
changeset
|
150 |
buildTree(classesSet); |
10 | 151 |
} |
152 |
||
153 |
/** |
|
154 |
* Generate mapping for the sub-classes for every class in this run. |
|
35426
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
26270
diff
changeset
|
155 |
* Return the sub-class set for java.lang.Object which will be having |
10 | 156 |
* sub-class listing for itself and also for each sub-class itself will |
157 |
* have their own sub-class lists. |
|
158 |
* |
|
159 |
* @param classes all the classes in this run. |
|
160 |
* @param configuration the current configuration of the doclet. |
|
161 |
*/ |
|
35426
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
26270
diff
changeset
|
162 |
private void buildTree(Iterable<TypeElement> classes) { |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
26270
diff
changeset
|
163 |
for (TypeElement aClass : classes) { |
9606
e5a619cb5dd3
6492694: @deprecated tag doesn't work in package-info files.
bpatel
parents:
5520
diff
changeset
|
164 |
// In the tree page (e.g overview-tree.html) do not include |
e5a619cb5dd3
6492694: @deprecated tag doesn't work in package-info files.
bpatel
parents:
5520
diff
changeset
|
165 |
// information of classes which are deprecated or are a part of a |
e5a619cb5dd3
6492694: @deprecated tag doesn't work in package-info files.
bpatel
parents:
5520
diff
changeset
|
166 |
// deprecated package. |
10 | 167 |
if (configuration.nodeprecated && |
25454
376a52c9540c
8039028: [javadoc] refactor the usage of Util.java
ksrini
parents:
22163
diff
changeset
|
168 |
(utils.isDeprecated(aClass) || |
35426
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
26270
diff
changeset
|
169 |
utils.isDeprecated(utils.containingPackage(aClass)))) { |
10 | 170 |
continue; |
171 |
} |
|
16319
e586bfeb39c5
7112427: The doclet needs to be able to generate JavaFX documentation.
jjg
parents:
14260
diff
changeset
|
172 |
|
37009
476d8d615222
8073100: [javadoc] Provide an ability to suppress document generation for specific elements.
ksrini
parents:
35426
diff
changeset
|
173 |
if (utils.isHidden(aClass)) { |
16319
e586bfeb39c5
7112427: The doclet needs to be able to generate JavaFX documentation.
jjg
parents:
14260
diff
changeset
|
174 |
continue; |
e586bfeb39c5
7112427: The doclet needs to be able to generate JavaFX documentation.
jjg
parents:
14260
diff
changeset
|
175 |
} |
e586bfeb39c5
7112427: The doclet needs to be able to generate JavaFX documentation.
jjg
parents:
14260
diff
changeset
|
176 |
|
35426
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
26270
diff
changeset
|
177 |
if (utils.isEnum(aClass)) { |
22159
682da512ec17
8030253: Update langtools to use strings-in-switch
briangoetz
parents:
16319
diff
changeset
|
178 |
processType(aClass, configuration, baseEnums, subEnums); |
35426
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
26270
diff
changeset
|
179 |
} else if (utils.isClass(aClass)) { |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
26270
diff
changeset
|
180 |
processType(aClass, configuration, baseClasses, subClasses); |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
26270
diff
changeset
|
181 |
} else if (utils.isInterface(aClass)) { |
22159
682da512ec17
8030253: Update langtools to use strings-in-switch
briangoetz
parents:
16319
diff
changeset
|
182 |
processInterface(aClass); |
35426
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
26270
diff
changeset
|
183 |
} else if (utils.isAnnotationType(aClass)) { |
22159
682da512ec17
8030253: Update langtools to use strings-in-switch
briangoetz
parents:
16319
diff
changeset
|
184 |
processType(aClass, configuration, baseAnnotationTypes, |
10 | 185 |
subAnnotationTypes); |
186 |
} |
|
187 |
} |
|
188 |
} |
|
189 |
||
190 |
/** |
|
35426
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
26270
diff
changeset
|
191 |
* For the class passed map it to its own sub-class listing. |
10 | 192 |
* For the Class passed, get the super class, |
193 |
* if superclass is non null, (it is not "java.lang.Object") |
|
35426
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
26270
diff
changeset
|
194 |
* get the "value" from the hashmap for this key Class |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
26270
diff
changeset
|
195 |
* if entry not found create one and get that. |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
26270
diff
changeset
|
196 |
* add this Class as a sub class in the set |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
26270
diff
changeset
|
197 |
* Recurse till hits java.lang.Object Null SuperClass. |
10 | 198 |
* |
35426
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
26270
diff
changeset
|
199 |
* @param typeElement for which sub class mapping is to be generated. |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
26270
diff
changeset
|
200 |
* @param configuration the current configuration of the doclet. |
10 | 201 |
*/ |
35426
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
26270
diff
changeset
|
202 |
private void processType(TypeElement typeElement, Configuration configuration, |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
26270
diff
changeset
|
203 |
Collection<TypeElement> bases, Map<TypeElement, SortedSet<TypeElement>> subs) { |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
26270
diff
changeset
|
204 |
TypeElement superclass = utils.getFirstVisibleSuperClassAsTypeElement(typeElement); |
10 | 205 |
if (superclass != null) { |
35426
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
26270
diff
changeset
|
206 |
if (!add(subs, superclass, typeElement)) { |
10 | 207 |
return; |
208 |
} else { |
|
209 |
processType(superclass, configuration, bases, subs); |
|
210 |
} |
|
35426
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
26270
diff
changeset
|
211 |
} else { // typeElement is java.lang.Object, add it once to the set |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
26270
diff
changeset
|
212 |
if (!bases.contains(typeElement)) { |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
26270
diff
changeset
|
213 |
bases.add(typeElement); |
10 | 214 |
} |
215 |
} |
|
35426
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
26270
diff
changeset
|
216 |
Set<TypeMirror> intfacs = utils.getAllInterfaces(typeElement); |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
26270
diff
changeset
|
217 |
for (TypeMirror intfac : intfacs) { |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
26270
diff
changeset
|
218 |
add(implementingClasses, utils.asTypeElement(intfac), typeElement); |
10 | 219 |
} |
220 |
} |
|
221 |
||
222 |
/** |
|
223 |
* For the interface passed get the interfaces which it extends, and then |
|
35426
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
26270
diff
changeset
|
224 |
* put this interface in the sub-interface set of those interfaces. Do it |
10 | 225 |
* recursively. If a interface doesn't have super-interface just attach |
35426
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
26270
diff
changeset
|
226 |
* that interface in the set of all the baseInterfaces. |
10 | 227 |
* |
35426
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
26270
diff
changeset
|
228 |
* @param typeElement Interface under consideration. |
10 | 229 |
*/ |
35426
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
26270
diff
changeset
|
230 |
private void processInterface(TypeElement typeElement) { |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
26270
diff
changeset
|
231 |
List<? extends TypeMirror> intfacs = typeElement.getInterfaces(); |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
26270
diff
changeset
|
232 |
if (!intfacs.isEmpty()) { |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
26270
diff
changeset
|
233 |
for (TypeMirror intfac : intfacs) { |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
26270
diff
changeset
|
234 |
if (!add(subInterfaces, utils.asTypeElement(intfac), typeElement)) { |
10 | 235 |
return; |
236 |
} else { |
|
35426
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
26270
diff
changeset
|
237 |
processInterface(utils.asTypeElement(intfac)); // Recurse |
10 | 238 |
} |
239 |
} |
|
240 |
} else { |
|
241 |
// we need to add all the interfaces who do not have |
|
35426
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
26270
diff
changeset
|
242 |
// super-interfaces to baseInterfaces set to traverse them |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
26270
diff
changeset
|
243 |
if (!baseInterfaces.contains(typeElement)) { |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
26270
diff
changeset
|
244 |
baseInterfaces.add(typeElement); |
10 | 245 |
} |
246 |
} |
|
247 |
} |
|
248 |
||
249 |
/** |
|
35426
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
26270
diff
changeset
|
250 |
* Adjust the Class Tree. Add the class interface in to it's super classes |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
26270
diff
changeset
|
251 |
* or super interface's sub-interface set. |
10 | 252 |
* |
253 |
* @param map the entire map. |
|
254 |
* @param superclass java.lang.Object or the super-interface. |
|
35426
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
26270
diff
changeset
|
255 |
* @param typeElement sub-interface to be mapped. |
10 | 256 |
* @returns boolean true if class added, false if class already processed. |
257 |
*/ |
|
35426
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
26270
diff
changeset
|
258 |
private boolean add(Map<TypeElement, SortedSet<TypeElement>> map, TypeElement superclass, TypeElement typeElement) { |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
26270
diff
changeset
|
259 |
SortedSet<TypeElement> sset = map.computeIfAbsent(superclass, s -> new TreeSet<>(comparator)); |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
26270
diff
changeset
|
260 |
if (sset.contains(typeElement)) { |
10 | 261 |
return false; |
262 |
} else { |
|
35426
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
26270
diff
changeset
|
263 |
sset.add(typeElement); |
10 | 264 |
} |
265 |
return true; |
|
266 |
} |
|
267 |
||
268 |
/** |
|
35426
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
26270
diff
changeset
|
269 |
* From the map return the set of sub-classes or sub-interfaces. If set |
10 | 270 |
* is null create a new one and return it. |
271 |
* |
|
272 |
* @param map The entire map. |
|
35426
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
26270
diff
changeset
|
273 |
* @param typeElement class for which the sub-class set is requested. |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
26270
diff
changeset
|
274 |
* @returns a list of sub classes. |
10 | 275 |
*/ |
35426
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
26270
diff
changeset
|
276 |
private SortedSet<TypeElement> get(Map<TypeElement, SortedSet<TypeElement>> map, TypeElement typeElement) { |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
26270
diff
changeset
|
277 |
return map.computeIfAbsent(typeElement, t -> new TreeSet<>(comparator)); |
10 | 278 |
} |
279 |
||
280 |
/** |
|
35426
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
26270
diff
changeset
|
281 |
* Return the sub-class set for the class passed. |
10 | 282 |
* |
35426
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
26270
diff
changeset
|
283 |
* @param typeElement class whose sub-class set is required. |
10 | 284 |
*/ |
35426
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
26270
diff
changeset
|
285 |
public SortedSet<TypeElement> subClasses(TypeElement typeElement) { |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
26270
diff
changeset
|
286 |
return get(subClasses, typeElement); |
10 | 287 |
} |
288 |
||
289 |
/** |
|
35426
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
26270
diff
changeset
|
290 |
* Return the sub-interface set for the interface passed. |
10 | 291 |
* |
35426
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
26270
diff
changeset
|
292 |
* @param typeElement interface whose sub-interface set is required. |
10 | 293 |
*/ |
35426
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
26270
diff
changeset
|
294 |
public SortedSet<TypeElement> subInterfaces(TypeElement typeElement) { |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
26270
diff
changeset
|
295 |
return get(subInterfaces, typeElement); |
10 | 296 |
} |
297 |
||
298 |
/** |
|
35426
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
26270
diff
changeset
|
299 |
* Return the set of classes which implement the interface passed. |
10 | 300 |
* |
35426
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
26270
diff
changeset
|
301 |
* @param typeElement interface whose implementing-classes set is required. |
10 | 302 |
*/ |
35426
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
26270
diff
changeset
|
303 |
public SortedSet<TypeElement> implementingClasses(TypeElement typeElement) { |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
26270
diff
changeset
|
304 |
SortedSet<TypeElement> result = get(implementingClasses, typeElement); |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
26270
diff
changeset
|
305 |
SortedSet<TypeElement> intfcs = allSubClasses(typeElement, false); |
10 | 306 |
|
35426
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
26270
diff
changeset
|
307 |
// If class x implements a subinterface of typeElement, then it follows |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
26270
diff
changeset
|
308 |
// that class x implements typeElement. |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
26270
diff
changeset
|
309 |
Iterator<TypeElement> subInterfacesIter = intfcs.iterator(); |
26270
a3635e6d3d78
8050031: [javadoc] class-use pages have duplicates and missing entries
ksrini
parents:
25874
diff
changeset
|
310 |
while (subInterfacesIter.hasNext()) { |
35426
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
26270
diff
changeset
|
311 |
Iterator<TypeElement> implementingClassesIter |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
26270
diff
changeset
|
312 |
= implementingClasses(subInterfacesIter.next()).iterator(); |
26270
a3635e6d3d78
8050031: [javadoc] class-use pages have duplicates and missing entries
ksrini
parents:
25874
diff
changeset
|
313 |
while (implementingClassesIter.hasNext()) { |
35426
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
26270
diff
changeset
|
314 |
TypeElement c = implementingClassesIter.next(); |
26270
a3635e6d3d78
8050031: [javadoc] class-use pages have duplicates and missing entries
ksrini
parents:
25874
diff
changeset
|
315 |
if (!result.contains(c)) { |
10 | 316 |
result.add(c); |
317 |
} |
|
318 |
} |
|
319 |
} |
|
320 |
return result; |
|
321 |
} |
|
322 |
||
323 |
/** |
|
35426
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
26270
diff
changeset
|
324 |
* Return the sub-class/interface set for the class/interface passed. |
10 | 325 |
* |
35426
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
26270
diff
changeset
|
326 |
* @param typeElement class/interface whose sub-class/interface set is required. |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
26270
diff
changeset
|
327 |
* @param isEnum true if the subClasses should be forced to come from the |
10 | 328 |
* enum tree. |
329 |
*/ |
|
35426
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
26270
diff
changeset
|
330 |
public SortedSet<TypeElement> directSubClasses(TypeElement typeElement, boolean isEnum) { |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
26270
diff
changeset
|
331 |
return directSubClasses0(typeElement, isEnum); |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
26270
diff
changeset
|
332 |
} |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
26270
diff
changeset
|
333 |
|
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
26270
diff
changeset
|
334 |
private SortedSet<TypeElement> directSubClasses0(TypeElement typeElement, boolean isEnum) { |
10 | 335 |
if (isEnum) { |
35426
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
26270
diff
changeset
|
336 |
return get(subEnums, typeElement); |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
26270
diff
changeset
|
337 |
} else if (utils.isAnnotationType(typeElement)) { |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
26270
diff
changeset
|
338 |
return get(subAnnotationTypes, typeElement); |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
26270
diff
changeset
|
339 |
} else if (utils.isInterface(typeElement)) { |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
26270
diff
changeset
|
340 |
return get(subInterfaces, typeElement); |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
26270
diff
changeset
|
341 |
} else if (utils.isClass(typeElement)) { |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
26270
diff
changeset
|
342 |
return get(subClasses, typeElement); |
10 | 343 |
} else { |
35426
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
26270
diff
changeset
|
344 |
return Collections.emptySortedSet(); |
10 | 345 |
} |
346 |
} |
|
347 |
||
348 |
/** |
|
35426
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
26270
diff
changeset
|
349 |
* Return a set of all direct or indirect, sub-classes and subInterfaces |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
26270
diff
changeset
|
350 |
* of the TypeElement argument. |
10 | 351 |
* |
35426
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
26270
diff
changeset
|
352 |
* @param typeElement TypeElement whose sub-classes or sub-interfaces are requested. |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
26270
diff
changeset
|
353 |
* @param isEnum true if the subClasses should be forced to come from the |
10 | 354 |
* enum tree. |
355 |
*/ |
|
35426
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
26270
diff
changeset
|
356 |
public SortedSet<TypeElement> allSubClasses(TypeElement typeElement, boolean isEnum) { |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
26270
diff
changeset
|
357 |
// new entries added to the set are searched as well, this is |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
26270
diff
changeset
|
358 |
// really a work queue. |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
26270
diff
changeset
|
359 |
List<TypeElement> list = new ArrayList<>(directSubClasses(typeElement, isEnum)); |
10 | 360 |
for (int i = 0; i < list.size(); i++) { |
35426
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
26270
diff
changeset
|
361 |
TypeElement te = list.get(i); |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
26270
diff
changeset
|
362 |
SortedSet<TypeElement> tset = directSubClasses0(te, isEnum); |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
26270
diff
changeset
|
363 |
for (TypeElement tte : tset) { |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
26270
diff
changeset
|
364 |
if (!list.contains(tte)) { |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
26270
diff
changeset
|
365 |
list.add(tte); |
10 | 366 |
} |
367 |
} |
|
368 |
} |
|
35426
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
26270
diff
changeset
|
369 |
SortedSet<TypeElement> out = new TreeSet<>(comparator); |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
26270
diff
changeset
|
370 |
out.addAll(list); |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
26270
diff
changeset
|
371 |
return out; |
10 | 372 |
} |
373 |
||
374 |
/** |
|
35426
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
26270
diff
changeset
|
375 |
* Return a set of base classes. This will have only one element namely |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
26270
diff
changeset
|
376 |
* the TypeElement for java.lang.Object, since this is the base class for all |
10 | 377 |
* classes. |
378 |
*/ |
|
35426
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
26270
diff
changeset
|
379 |
public SortedSet<TypeElement> baseClasses() { |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
26270
diff
changeset
|
380 |
return baseClasses; |
10 | 381 |
} |
382 |
||
383 |
/** |
|
35426
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
26270
diff
changeset
|
384 |
* Return the set of base interfaces. This is the set of interfaces |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
26270
diff
changeset
|
385 |
* which do not have super-interface. |
10 | 386 |
*/ |
35426
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
26270
diff
changeset
|
387 |
public SortedSet<TypeElement> baseInterfaces() { |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
26270
diff
changeset
|
388 |
return baseInterfaces; |
10 | 389 |
} |
390 |
||
391 |
/** |
|
35426
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
26270
diff
changeset
|
392 |
* Return the set of base enums. This is the set of enums |
10 | 393 |
* which do not have super-enums. |
394 |
*/ |
|
35426
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
26270
diff
changeset
|
395 |
public SortedSet<TypeElement> baseEnums() { |
10 | 396 |
return baseEnums; |
397 |
} |
|
398 |
||
399 |
/** |
|
35426
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
26270
diff
changeset
|
400 |
* Return the set of base annotation types. This is the set |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
26270
diff
changeset
|
401 |
* of annotation types which do not have super-annotation types. |
10 | 402 |
*/ |
35426
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
26270
diff
changeset
|
403 |
public SortedSet<TypeElement> baseAnnotationTypes() { |
10 | 404 |
return baseAnnotationTypes; |
405 |
} |
|
406 |
} |