author | hannesw |
Wed, 27 Nov 2019 13:08:16 +0100 | |
changeset 59294 | 48b88b9c11eb |
parent 49879 | 601277b1d582 |
permissions | -rw-r--r-- |
10 | 1 |
/* |
49879
601277b1d582
8025091: VisibleMemberMap.java possible performance improvements
ksrini
parents:
47216
diff
changeset
|
2 |
* Copyright (c) 2003, 2018, 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:
29957
diff
changeset
|
26 |
package jdk.javadoc.internal.doclets.toolkit.builders; |
10 | 27 |
|
7614
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5855
diff
changeset
|
28 |
import java.util.*; |
14258 | 29 |
|
35426
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
29957
diff
changeset
|
30 |
import javax.lang.model.element.Element; |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
29957
diff
changeset
|
31 |
import javax.lang.model.element.PackageElement; |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
29957
diff
changeset
|
32 |
import javax.lang.model.element.TypeElement; |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
29957
diff
changeset
|
33 |
import javax.lang.model.element.VariableElement; |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
29957
diff
changeset
|
34 |
|
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
29957
diff
changeset
|
35 |
import jdk.javadoc.internal.doclets.toolkit.ConstantsSummaryWriter; |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
29957
diff
changeset
|
36 |
import jdk.javadoc.internal.doclets.toolkit.Content; |
40587 | 37 |
import jdk.javadoc.internal.doclets.toolkit.DocletException; |
49879
601277b1d582
8025091: VisibleMemberMap.java possible performance improvements
ksrini
parents:
47216
diff
changeset
|
38 |
import jdk.javadoc.internal.doclets.toolkit.util.VisibleMemberTable; |
35426
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
29957
diff
changeset
|
39 |
|
49879
601277b1d582
8025091: VisibleMemberMap.java possible performance improvements
ksrini
parents:
47216
diff
changeset
|
40 |
import static jdk.javadoc.internal.doclets.toolkit.util.VisibleMemberTable.Kind.*; |
10 | 41 |
|
42 |
/** |
|
43 |
* Builds the Constants Summary Page. |
|
44 |
* |
|
14260
727a84636f12
8000665: fix "internal API" comments on javadoc files
jjg
parents:
14259
diff
changeset
|
45 |
* <p><b>This is NOT part of any supported API. |
727a84636f12
8000665: fix "internal API" comments on javadoc files
jjg
parents:
14259
diff
changeset
|
46 |
* 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:
14259
diff
changeset
|
47 |
* This code and its internal interfaces are subject to change or |
727a84636f12
8000665: fix "internal API" comments on javadoc files
jjg
parents:
14259
diff
changeset
|
48 |
* deletion without notice.</b> |
10 | 49 |
* |
50 |
* @author Jamie Ho |
|
7614
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5855
diff
changeset
|
51 |
* @author Bhavesh Patel (Modified) |
10 | 52 |
*/ |
53 |
public class ConstantsSummaryBuilder extends AbstractBuilder { |
|
54 |
||
55 |
/** |
|
56 |
* The maximum number of package directories shown in the constant |
|
57 |
* value index. |
|
58 |
*/ |
|
59 |
public static final int MAX_CONSTANT_VALUE_INDEX_LENGTH = 2; |
|
60 |
||
61 |
/** |
|
62 |
* The writer used to write the results. |
|
63 |
*/ |
|
14542 | 64 |
protected final ConstantsSummaryWriter writer; |
10 | 65 |
|
66 |
/** |
|
35426
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
29957
diff
changeset
|
67 |
* The set of TypeElements that have constant fields. |
10 | 68 |
*/ |
35426
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
29957
diff
changeset
|
69 |
protected final Set<TypeElement> typeElementsWithConstFields; |
10 | 70 |
|
71 |
/** |
|
72 |
* The set of printed package headers. |
|
73 |
*/ |
|
35426
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
29957
diff
changeset
|
74 |
protected final Set<PackageElement> printedPackageHeaders; |
10 | 75 |
|
76 |
/** |
|
77 |
* The current package being documented. |
|
78 |
*/ |
|
35426
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
29957
diff
changeset
|
79 |
private PackageElement currentPackage; |
10 | 80 |
|
81 |
/** |
|
82 |
* The current class being documented. |
|
83 |
*/ |
|
35426
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
29957
diff
changeset
|
84 |
private TypeElement currentClass; |
10 | 85 |
|
86 |
/** |
|
29957
7740f9657f56
8072945: Javadoc should generate valid and compliant HTML5 output
bpatel
parents:
25874
diff
changeset
|
87 |
* True if first package is listed. |
7740f9657f56
8072945: Javadoc should generate valid and compliant HTML5 output
bpatel
parents:
25874
diff
changeset
|
88 |
*/ |
7740f9657f56
8072945: Javadoc should generate valid and compliant HTML5 output
bpatel
parents:
25874
diff
changeset
|
89 |
private boolean first = true; |
7740f9657f56
8072945: Javadoc should generate valid and compliant HTML5 output
bpatel
parents:
25874
diff
changeset
|
90 |
|
7740f9657f56
8072945: Javadoc should generate valid and compliant HTML5 output
bpatel
parents:
25874
diff
changeset
|
91 |
/** |
10 | 92 |
* Construct a new ConstantsSummaryBuilder. |
93 |
* |
|
14542 | 94 |
* @param context the build context. |
95 |
* @param writer the writer for the summary. |
|
10 | 96 |
*/ |
14542 | 97 |
private ConstantsSummaryBuilder(Context context, |
98 |
ConstantsSummaryWriter writer) { |
|
99 |
super(context); |
|
100 |
this.writer = writer; |
|
35426
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
29957
diff
changeset
|
101 |
this.typeElementsWithConstFields = new HashSet<>(); |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
29957
diff
changeset
|
102 |
this.printedPackageHeaders = new TreeSet<>(utils.makePackageComparator()); |
10 | 103 |
} |
104 |
||
105 |
/** |
|
106 |
* Construct a ConstantsSummaryBuilder. |
|
107 |
* |
|
14542 | 108 |
* @param context the build context. |
10 | 109 |
* @param writer the writer for the summary. |
40587 | 110 |
* @return the new ConstantsSummaryBuilder |
10 | 111 |
*/ |
14542 | 112 |
public static ConstantsSummaryBuilder getInstance(Context context, |
113 |
ConstantsSummaryWriter writer) { |
|
114 |
return new ConstantsSummaryBuilder(context, writer); |
|
10 | 115 |
} |
116 |
||
117 |
/** |
|
118 |
* {@inheritDoc} |
|
40587 | 119 |
* @throws DocletException if there is a problem while building the documentation |
10 | 120 |
*/ |
35426
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
29957
diff
changeset
|
121 |
@Override |
40587 | 122 |
public void build() throws DocletException { |
10 | 123 |
if (writer == null) { |
124 |
//Doclet does not support this output. |
|
125 |
return; |
|
126 |
} |
|
59294
48b88b9c11eb
8223378: CSS solution for navbar problem with <a> elements is not ideal
hannesw
parents:
49879
diff
changeset
|
127 |
buildConstantSummary(); |
10 | 128 |
} |
129 |
||
130 |
/** |
|
131 |
* Build the constant summary. |
|
132 |
* |
|
40587 | 133 |
* @throws DocletException if there is a problem while building the documentation |
10 | 134 |
*/ |
59294
48b88b9c11eb
8223378: CSS solution for navbar problem with <a> elements is not ideal
hannesw
parents:
49879
diff
changeset
|
135 |
protected void buildConstantSummary() throws DocletException { |
48b88b9c11eb
8223378: CSS solution for navbar problem with <a> elements is not ideal
hannesw
parents:
49879
diff
changeset
|
136 |
Content contentTree = writer.getHeader(); |
45599 | 137 |
|
59294
48b88b9c11eb
8223378: CSS solution for navbar problem with <a> elements is not ideal
hannesw
parents:
49879
diff
changeset
|
138 |
buildContents(); |
48b88b9c11eb
8223378: CSS solution for navbar problem with <a> elements is not ideal
hannesw
parents:
49879
diff
changeset
|
139 |
buildConstantSummaries(); |
45599 | 140 |
|
59294
48b88b9c11eb
8223378: CSS solution for navbar problem with <a> elements is not ideal
hannesw
parents:
49879
diff
changeset
|
141 |
writer.addFooter(); |
7614
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5855
diff
changeset
|
142 |
writer.printDocument(contentTree); |
10 | 143 |
} |
144 |
||
145 |
/** |
|
7614
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5855
diff
changeset
|
146 |
* Build the list of packages. |
10 | 147 |
*/ |
59294
48b88b9c11eb
8223378: CSS solution for navbar problem with <a> elements is not ideal
hannesw
parents:
49879
diff
changeset
|
148 |
protected void buildContents() { |
7614
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5855
diff
changeset
|
149 |
Content contentListTree = writer.getContentsHeader(); |
35426
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
29957
diff
changeset
|
150 |
printedPackageHeaders.clear(); |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
29957
diff
changeset
|
151 |
for (PackageElement pkg : configuration.packages) { |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
29957
diff
changeset
|
152 |
if (hasConstantField(pkg) && !hasPrintedPackageIndex(pkg)) { |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
29957
diff
changeset
|
153 |
writer.addLinkToPackageContent(pkg, printedPackageHeaders, contentListTree); |
10 | 154 |
} |
155 |
} |
|
59294
48b88b9c11eb
8223378: CSS solution for navbar problem with <a> elements is not ideal
hannesw
parents:
49879
diff
changeset
|
156 |
writer.addContentsList(contentListTree); |
10 | 157 |
} |
158 |
||
159 |
/** |
|
160 |
* Build the summary for each documented package. |
|
161 |
* |
|
40587 | 162 |
* @throws DocletException if there is a problem while building the documentation |
10 | 163 |
*/ |
59294
48b88b9c11eb
8223378: CSS solution for navbar problem with <a> elements is not ideal
hannesw
parents:
49879
diff
changeset
|
164 |
protected void buildConstantSummaries() throws DocletException { |
35426
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
29957
diff
changeset
|
165 |
printedPackageHeaders.clear(); |
7614
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5855
diff
changeset
|
166 |
Content summariesTree = writer.getConstantSummaries(); |
35426
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
29957
diff
changeset
|
167 |
for (PackageElement aPackage : configuration.packages) { |
22159
682da512ec17
8030253: Update langtools to use strings-in-switch
briangoetz
parents:
16319
diff
changeset
|
168 |
if (hasConstantField(aPackage)) { |
682da512ec17
8030253: Update langtools to use strings-in-switch
briangoetz
parents:
16319
diff
changeset
|
169 |
currentPackage = aPackage; |
10 | 170 |
//Build the documentation for the current package. |
45599 | 171 |
|
172 |
buildPackageHeader(summariesTree); |
|
173 |
buildClassConstantSummary(summariesTree); |
|
174 |
||
29957
7740f9657f56
8072945: Javadoc should generate valid and compliant HTML5 output
bpatel
parents:
25874
diff
changeset
|
175 |
first = false; |
10 | 176 |
} |
177 |
} |
|
59294
48b88b9c11eb
8223378: CSS solution for navbar problem with <a> elements is not ideal
hannesw
parents:
49879
diff
changeset
|
178 |
writer.addConstantSummaries(summariesTree); |
10 | 179 |
} |
180 |
||
181 |
/** |
|
7614
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5855
diff
changeset
|
182 |
* Build the header for the given package. |
10 | 183 |
* |
7614
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5855
diff
changeset
|
184 |
* @param summariesTree the tree to which the package header will be added |
10 | 185 |
*/ |
45599 | 186 |
protected void buildPackageHeader(Content summariesTree) { |
36526 | 187 |
PackageElement abbrevPkg = configuration.workArounds.getAbbreviatedPackageElement(currentPackage); |
188 |
if (!printedPackageHeaders.contains(abbrevPkg)) { |
|
35426
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
29957
diff
changeset
|
189 |
writer.addPackageName(currentPackage, summariesTree, first); |
36526 | 190 |
printedPackageHeaders.add(abbrevPkg); |
7614
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5855
diff
changeset
|
191 |
} |
10 | 192 |
} |
193 |
||
194 |
/** |
|
195 |
* Build the summary for the current class. |
|
196 |
* |
|
7614
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5855
diff
changeset
|
197 |
* @param summariesTree the tree to which the class constant summary will be added |
40587 | 198 |
* @throws DocletException if there is a problem while building the documentation |
199 |
* |
|
10 | 200 |
*/ |
45599 | 201 |
protected void buildClassConstantSummary(Content summariesTree) |
40587 | 202 |
throws DocletException { |
35426
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
29957
diff
changeset
|
203 |
SortedSet<TypeElement> classes = !currentPackage.isUnnamed() |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
29957
diff
changeset
|
204 |
? utils.getAllClasses(currentPackage) |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
29957
diff
changeset
|
205 |
: configuration.typeElementCatalog.allUnnamedClasses(); |
7614
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5855
diff
changeset
|
206 |
Content classConstantTree = writer.getClassConstantHeader(); |
35426
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
29957
diff
changeset
|
207 |
for (TypeElement te : classes) { |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
29957
diff
changeset
|
208 |
if (!typeElementsWithConstFields.contains(te) || |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
29957
diff
changeset
|
209 |
!utils.isIncluded(te)) { |
10 | 210 |
continue; |
211 |
} |
|
35426
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
29957
diff
changeset
|
212 |
currentClass = te; |
10 | 213 |
//Build the documentation for the current class. |
45599 | 214 |
|
215 |
buildConstantMembers(classConstantTree); |
|
216 |
||
10 | 217 |
} |
29957
7740f9657f56
8072945: Javadoc should generate valid and compliant HTML5 output
bpatel
parents:
25874
diff
changeset
|
218 |
writer.addClassConstant(summariesTree, classConstantTree); |
10 | 219 |
} |
220 |
||
221 |
/** |
|
7614
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5855
diff
changeset
|
222 |
* Build the summary of constant members in the class. |
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5855
diff
changeset
|
223 |
* |
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5855
diff
changeset
|
224 |
* @param classConstantTree the tree to which the constant members table |
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5855
diff
changeset
|
225 |
* will be added |
10 | 226 |
*/ |
45599 | 227 |
protected void buildConstantMembers(Content classConstantTree) { |
228 |
new ConstantFieldBuilder(currentClass).buildMembersSummary(classConstantTree); |
|
10 | 229 |
} |
230 |
||
231 |
/** |
|
232 |
* Return true if the given package has constant fields to document. |
|
233 |
* |
|
234 |
* @param pkg the package being checked. |
|
235 |
* @return true if the given package has constant fields to document. |
|
236 |
*/ |
|
35426
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
29957
diff
changeset
|
237 |
private boolean hasConstantField(PackageElement pkg) { |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
29957
diff
changeset
|
238 |
SortedSet<TypeElement> classes = !pkg.isUnnamed() |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
29957
diff
changeset
|
239 |
? utils.getAllClasses(pkg) |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
29957
diff
changeset
|
240 |
: configuration.typeElementCatalog.allUnnamedClasses(); |
10 | 241 |
boolean found = false; |
35426
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
29957
diff
changeset
|
242 |
for (TypeElement te : classes) { |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
29957
diff
changeset
|
243 |
if (utils.isIncluded(te) && hasConstantField(te)) { |
10 | 244 |
found = true; |
245 |
} |
|
246 |
} |
|
247 |
return found; |
|
248 |
} |
|
249 |
||
250 |
/** |
|
251 |
* Return true if the given class has constant fields to document. |
|
252 |
* |
|
35426
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
29957
diff
changeset
|
253 |
* @param typeElement the class being checked. |
10 | 254 |
* @return true if the given package has constant fields to document. |
255 |
*/ |
|
35426
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
29957
diff
changeset
|
256 |
private boolean hasConstantField (TypeElement typeElement) { |
49879
601277b1d582
8025091: VisibleMemberMap.java possible performance improvements
ksrini
parents:
47216
diff
changeset
|
257 |
VisibleMemberTable vmt = configuration.getVisibleMemberTable(typeElement); |
601277b1d582
8025091: VisibleMemberMap.java possible performance improvements
ksrini
parents:
47216
diff
changeset
|
258 |
List<? extends Element> fields = vmt.getVisibleMembers(FIELDS); |
35426
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
29957
diff
changeset
|
259 |
for (Element f : fields) { |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
29957
diff
changeset
|
260 |
VariableElement field = (VariableElement)f; |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
29957
diff
changeset
|
261 |
if (field.getConstantValue() != null) { |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
29957
diff
changeset
|
262 |
typeElementsWithConstFields.add(typeElement); |
10 | 263 |
return true; |
264 |
} |
|
265 |
} |
|
266 |
return false; |
|
267 |
} |
|
268 |
||
269 |
/** |
|
270 |
* Return true if the given package name has been printed. Also |
|
271 |
* return true if the root of this package has been printed. |
|
272 |
* |
|
49879
601277b1d582
8025091: VisibleMemberMap.java possible performance improvements
ksrini
parents:
47216
diff
changeset
|
273 |
* @param pkg the name of the package to check. |
10 | 274 |
*/ |
35426
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
29957
diff
changeset
|
275 |
private boolean hasPrintedPackageIndex(PackageElement pkg) { |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
29957
diff
changeset
|
276 |
for (PackageElement printedPkg : printedPackageHeaders) { |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
29957
diff
changeset
|
277 |
if (utils.getPackageName(pkg).startsWith(utils.parsePackageName(printedPkg))) { |
10 | 278 |
return true; |
279 |
} |
|
280 |
} |
|
281 |
return false; |
|
282 |
} |
|
283 |
||
284 |
/** |
|
285 |
* Print the table of constants. |
|
286 |
* |
|
287 |
* @author Jamie Ho |
|
288 |
*/ |
|
289 |
private class ConstantFieldBuilder { |
|
290 |
||
291 |
/** |
|
35426
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
29957
diff
changeset
|
292 |
* The typeElement that we are examining constants for. |
10 | 293 |
*/ |
35426
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
29957
diff
changeset
|
294 |
protected TypeElement typeElement; |
10 | 295 |
|
296 |
/** |
|
297 |
* Construct a ConstantFieldSubWriter. |
|
35426
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
29957
diff
changeset
|
298 |
* @param typeElement the typeElement that we are examining constants for. |
10 | 299 |
*/ |
35426
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
29957
diff
changeset
|
300 |
public ConstantFieldBuilder(TypeElement typeElement) { |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
29957
diff
changeset
|
301 |
this.typeElement = typeElement; |
10 | 302 |
} |
303 |
||
304 |
/** |
|
305 |
* Builds the table of constants for a given class. |
|
7614
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5855
diff
changeset
|
306 |
* |
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5855
diff
changeset
|
307 |
* @param classConstantTree the tree to which the class constants table |
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5855
diff
changeset
|
308 |
* will be added |
10 | 309 |
*/ |
45599 | 310 |
protected void buildMembersSummary(Content classConstantTree) { |
35426
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
29957
diff
changeset
|
311 |
SortedSet<VariableElement> members = members(); |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
29957
diff
changeset
|
312 |
if (!members.isEmpty()) { |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
29957
diff
changeset
|
313 |
writer.addConstantMembers(typeElement, members, classConstantTree); |
10 | 314 |
} |
315 |
} |
|
316 |
||
317 |
/** |
|
42000
8b7412f7eecd
8167967: javadoc should identify the ordinal value of enum constants
ksrini
parents:
40587
diff
changeset
|
318 |
* Returns a set of visible constant fields for the given type. |
8b7412f7eecd
8167967: javadoc should identify the ordinal value of enum constants
ksrini
parents:
40587
diff
changeset
|
319 |
* @return the set of visible constant fields for the given type. |
10 | 320 |
*/ |
35426
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
29957
diff
changeset
|
321 |
protected SortedSet<VariableElement> members() { |
49879
601277b1d582
8025091: VisibleMemberMap.java possible performance improvements
ksrini
parents:
47216
diff
changeset
|
322 |
VisibleMemberTable vmt = configuration.getVisibleMemberTable(typeElement); |
601277b1d582
8025091: VisibleMemberMap.java possible performance improvements
ksrini
parents:
47216
diff
changeset
|
323 |
List<Element> members = new ArrayList<>(); |
601277b1d582
8025091: VisibleMemberMap.java possible performance improvements
ksrini
parents:
47216
diff
changeset
|
324 |
members.addAll(vmt.getVisibleMembers(FIELDS)); |
601277b1d582
8025091: VisibleMemberMap.java possible performance improvements
ksrini
parents:
47216
diff
changeset
|
325 |
members.addAll(vmt.getVisibleMembers(ENUM_CONSTANTS)); |
42000
8b7412f7eecd
8167967: javadoc should identify the ordinal value of enum constants
ksrini
parents:
40587
diff
changeset
|
326 |
SortedSet<VariableElement> includes = |
35426
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
29957
diff
changeset
|
327 |
new TreeSet<>(utils.makeGeneralPurposeComparator()); |
42000
8b7412f7eecd
8167967: javadoc should identify the ordinal value of enum constants
ksrini
parents:
40587
diff
changeset
|
328 |
for (Element element : members) { |
35426
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
29957
diff
changeset
|
329 |
VariableElement member = (VariableElement)element; |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
29957
diff
changeset
|
330 |
if (member.getConstantValue() != null) { |
42000
8b7412f7eecd
8167967: javadoc should identify the ordinal value of enum constants
ksrini
parents:
40587
diff
changeset
|
331 |
includes.add(member); |
10 | 332 |
} |
333 |
} |
|
42000
8b7412f7eecd
8167967: javadoc should identify the ordinal value of enum constants
ksrini
parents:
40587
diff
changeset
|
334 |
return includes; |
10 | 335 |
} |
336 |
} |
|
337 |
} |