author | ksrini |
Tue, 24 Apr 2018 11:54:03 -0700 | |
changeset 49879 | 601277b1d582 |
parent 47216 | 71c04702a3d5 |
child 59294 | 48b88b9c11eb |
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 |
/** |
|
7614
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5855
diff
changeset
|
87 |
* The content tree for the constant summary documentation. |
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5855
diff
changeset
|
88 |
*/ |
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5855
diff
changeset
|
89 |
private Content contentTree; |
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5855
diff
changeset
|
90 |
|
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5855
diff
changeset
|
91 |
/** |
29957
7740f9657f56
8072945: Javadoc should generate valid and compliant HTML5 output
bpatel
parents:
25874
diff
changeset
|
92 |
* True if first package is listed. |
7740f9657f56
8072945: Javadoc should generate valid and compliant HTML5 output
bpatel
parents:
25874
diff
changeset
|
93 |
*/ |
7740f9657f56
8072945: Javadoc should generate valid and compliant HTML5 output
bpatel
parents:
25874
diff
changeset
|
94 |
private boolean first = true; |
7740f9657f56
8072945: Javadoc should generate valid and compliant HTML5 output
bpatel
parents:
25874
diff
changeset
|
95 |
|
7740f9657f56
8072945: Javadoc should generate valid and compliant HTML5 output
bpatel
parents:
25874
diff
changeset
|
96 |
/** |
10 | 97 |
* Construct a new ConstantsSummaryBuilder. |
98 |
* |
|
14542 | 99 |
* @param context the build context. |
100 |
* @param writer the writer for the summary. |
|
10 | 101 |
*/ |
14542 | 102 |
private ConstantsSummaryBuilder(Context context, |
103 |
ConstantsSummaryWriter writer) { |
|
104 |
super(context); |
|
105 |
this.writer = writer; |
|
35426
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
29957
diff
changeset
|
106 |
this.typeElementsWithConstFields = new HashSet<>(); |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
29957
diff
changeset
|
107 |
this.printedPackageHeaders = new TreeSet<>(utils.makePackageComparator()); |
10 | 108 |
} |
109 |
||
110 |
/** |
|
111 |
* Construct a ConstantsSummaryBuilder. |
|
112 |
* |
|
14542 | 113 |
* @param context the build context. |
10 | 114 |
* @param writer the writer for the summary. |
40587 | 115 |
* @return the new ConstantsSummaryBuilder |
10 | 116 |
*/ |
14542 | 117 |
public static ConstantsSummaryBuilder getInstance(Context context, |
118 |
ConstantsSummaryWriter writer) { |
|
119 |
return new ConstantsSummaryBuilder(context, writer); |
|
10 | 120 |
} |
121 |
||
122 |
/** |
|
123 |
* {@inheritDoc} |
|
40587 | 124 |
* @throws DocletException if there is a problem while building the documentation |
10 | 125 |
*/ |
35426
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
29957
diff
changeset
|
126 |
@Override |
40587 | 127 |
public void build() throws DocletException { |
10 | 128 |
if (writer == null) { |
129 |
//Doclet does not support this output. |
|
130 |
return; |
|
131 |
} |
|
45599 | 132 |
buildConstantSummary(contentTree); |
10 | 133 |
} |
134 |
||
135 |
/** |
|
136 |
* Build the constant summary. |
|
137 |
* |
|
7614
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5855
diff
changeset
|
138 |
* @param contentTree the content tree to which the documentation will be added |
40587 | 139 |
* @throws DocletException if there is a problem while building the documentation |
10 | 140 |
*/ |
45599 | 141 |
protected void buildConstantSummary(Content contentTree) throws DocletException { |
7614
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5855
diff
changeset
|
142 |
contentTree = writer.getHeader(); |
45599 | 143 |
|
144 |
buildContents(contentTree); |
|
145 |
buildConstantSummaries(contentTree); |
|
146 |
||
7614
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5855
diff
changeset
|
147 |
writer.addFooter(contentTree); |
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5855
diff
changeset
|
148 |
writer.printDocument(contentTree); |
10 | 149 |
} |
150 |
||
151 |
/** |
|
7614
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5855
diff
changeset
|
152 |
* Build the list of packages. |
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5855
diff
changeset
|
153 |
* |
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5855
diff
changeset
|
154 |
* @param contentTree the content tree to which the content list will be added |
10 | 155 |
*/ |
45599 | 156 |
protected void buildContents(Content contentTree) { |
7614
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5855
diff
changeset
|
157 |
Content contentListTree = writer.getContentsHeader(); |
35426
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
29957
diff
changeset
|
158 |
printedPackageHeaders.clear(); |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
29957
diff
changeset
|
159 |
for (PackageElement pkg : configuration.packages) { |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
29957
diff
changeset
|
160 |
if (hasConstantField(pkg) && !hasPrintedPackageIndex(pkg)) { |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
29957
diff
changeset
|
161 |
writer.addLinkToPackageContent(pkg, printedPackageHeaders, contentListTree); |
10 | 162 |
} |
163 |
} |
|
29957
7740f9657f56
8072945: Javadoc should generate valid and compliant HTML5 output
bpatel
parents:
25874
diff
changeset
|
164 |
writer.addContentsList(contentTree, contentListTree); |
10 | 165 |
} |
166 |
||
167 |
/** |
|
168 |
* Build the summary for each documented package. |
|
169 |
* |
|
7614
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5855
diff
changeset
|
170 |
* @param contentTree the tree to which the summaries will be added |
40587 | 171 |
* @throws DocletException if there is a problem while building the documentation |
10 | 172 |
*/ |
45599 | 173 |
protected void buildConstantSummaries(Content contentTree) throws DocletException { |
35426
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
29957
diff
changeset
|
174 |
printedPackageHeaders.clear(); |
7614
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5855
diff
changeset
|
175 |
Content summariesTree = writer.getConstantSummaries(); |
35426
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
29957
diff
changeset
|
176 |
for (PackageElement aPackage : configuration.packages) { |
22159
682da512ec17
8030253: Update langtools to use strings-in-switch
briangoetz
parents:
16319
diff
changeset
|
177 |
if (hasConstantField(aPackage)) { |
682da512ec17
8030253: Update langtools to use strings-in-switch
briangoetz
parents:
16319
diff
changeset
|
178 |
currentPackage = aPackage; |
10 | 179 |
//Build the documentation for the current package. |
45599 | 180 |
|
181 |
buildPackageHeader(summariesTree); |
|
182 |
buildClassConstantSummary(summariesTree); |
|
183 |
||
29957
7740f9657f56
8072945: Javadoc should generate valid and compliant HTML5 output
bpatel
parents:
25874
diff
changeset
|
184 |
first = false; |
10 | 185 |
} |
186 |
} |
|
29957
7740f9657f56
8072945: Javadoc should generate valid and compliant HTML5 output
bpatel
parents:
25874
diff
changeset
|
187 |
writer.addConstantSummaries(contentTree, summariesTree); |
10 | 188 |
} |
189 |
||
190 |
/** |
|
7614
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5855
diff
changeset
|
191 |
* Build the header for the given package. |
10 | 192 |
* |
7614
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5855
diff
changeset
|
193 |
* @param summariesTree the tree to which the package header will be added |
10 | 194 |
*/ |
45599 | 195 |
protected void buildPackageHeader(Content summariesTree) { |
36526 | 196 |
PackageElement abbrevPkg = configuration.workArounds.getAbbreviatedPackageElement(currentPackage); |
197 |
if (!printedPackageHeaders.contains(abbrevPkg)) { |
|
35426
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
29957
diff
changeset
|
198 |
writer.addPackageName(currentPackage, summariesTree, first); |
36526 | 199 |
printedPackageHeaders.add(abbrevPkg); |
7614
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5855
diff
changeset
|
200 |
} |
10 | 201 |
} |
202 |
||
203 |
/** |
|
204 |
* Build the summary for the current class. |
|
205 |
* |
|
7614
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5855
diff
changeset
|
206 |
* @param summariesTree the tree to which the class constant summary will be added |
40587 | 207 |
* @throws DocletException if there is a problem while building the documentation |
208 |
* |
|
10 | 209 |
*/ |
45599 | 210 |
protected void buildClassConstantSummary(Content summariesTree) |
40587 | 211 |
throws DocletException { |
35426
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
29957
diff
changeset
|
212 |
SortedSet<TypeElement> classes = !currentPackage.isUnnamed() |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
29957
diff
changeset
|
213 |
? utils.getAllClasses(currentPackage) |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
29957
diff
changeset
|
214 |
: configuration.typeElementCatalog.allUnnamedClasses(); |
7614
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5855
diff
changeset
|
215 |
Content classConstantTree = writer.getClassConstantHeader(); |
35426
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
29957
diff
changeset
|
216 |
for (TypeElement te : classes) { |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
29957
diff
changeset
|
217 |
if (!typeElementsWithConstFields.contains(te) || |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
29957
diff
changeset
|
218 |
!utils.isIncluded(te)) { |
10 | 219 |
continue; |
220 |
} |
|
35426
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
29957
diff
changeset
|
221 |
currentClass = te; |
10 | 222 |
//Build the documentation for the current class. |
45599 | 223 |
|
224 |
buildConstantMembers(classConstantTree); |
|
225 |
||
10 | 226 |
} |
29957
7740f9657f56
8072945: Javadoc should generate valid and compliant HTML5 output
bpatel
parents:
25874
diff
changeset
|
227 |
writer.addClassConstant(summariesTree, classConstantTree); |
10 | 228 |
} |
229 |
||
230 |
/** |
|
7614
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5855
diff
changeset
|
231 |
* 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
|
232 |
* |
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5855
diff
changeset
|
233 |
* @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
|
234 |
* will be added |
10 | 235 |
*/ |
45599 | 236 |
protected void buildConstantMembers(Content classConstantTree) { |
237 |
new ConstantFieldBuilder(currentClass).buildMembersSummary(classConstantTree); |
|
10 | 238 |
} |
239 |
||
240 |
/** |
|
241 |
* Return true if the given package has constant fields to document. |
|
242 |
* |
|
243 |
* @param pkg the package being checked. |
|
244 |
* @return true if the given package has constant fields to document. |
|
245 |
*/ |
|
35426
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
29957
diff
changeset
|
246 |
private boolean hasConstantField(PackageElement pkg) { |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
29957
diff
changeset
|
247 |
SortedSet<TypeElement> classes = !pkg.isUnnamed() |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
29957
diff
changeset
|
248 |
? utils.getAllClasses(pkg) |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
29957
diff
changeset
|
249 |
: configuration.typeElementCatalog.allUnnamedClasses(); |
10 | 250 |
boolean found = false; |
35426
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
29957
diff
changeset
|
251 |
for (TypeElement te : classes) { |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
29957
diff
changeset
|
252 |
if (utils.isIncluded(te) && hasConstantField(te)) { |
10 | 253 |
found = true; |
254 |
} |
|
255 |
} |
|
256 |
return found; |
|
257 |
} |
|
258 |
||
259 |
/** |
|
260 |
* Return true if the given class has constant fields to document. |
|
261 |
* |
|
35426
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
29957
diff
changeset
|
262 |
* @param typeElement the class being checked. |
10 | 263 |
* @return true if the given package has constant fields to document. |
264 |
*/ |
|
35426
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
29957
diff
changeset
|
265 |
private boolean hasConstantField (TypeElement typeElement) { |
49879
601277b1d582
8025091: VisibleMemberMap.java possible performance improvements
ksrini
parents:
47216
diff
changeset
|
266 |
VisibleMemberTable vmt = configuration.getVisibleMemberTable(typeElement); |
601277b1d582
8025091: VisibleMemberMap.java possible performance improvements
ksrini
parents:
47216
diff
changeset
|
267 |
List<? extends Element> fields = vmt.getVisibleMembers(FIELDS); |
35426
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
29957
diff
changeset
|
268 |
for (Element f : fields) { |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
29957
diff
changeset
|
269 |
VariableElement field = (VariableElement)f; |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
29957
diff
changeset
|
270 |
if (field.getConstantValue() != null) { |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
29957
diff
changeset
|
271 |
typeElementsWithConstFields.add(typeElement); |
10 | 272 |
return true; |
273 |
} |
|
274 |
} |
|
275 |
return false; |
|
276 |
} |
|
277 |
||
278 |
/** |
|
279 |
* Return true if the given package name has been printed. Also |
|
280 |
* return true if the root of this package has been printed. |
|
281 |
* |
|
49879
601277b1d582
8025091: VisibleMemberMap.java possible performance improvements
ksrini
parents:
47216
diff
changeset
|
282 |
* @param pkg the name of the package to check. |
10 | 283 |
*/ |
35426
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
29957
diff
changeset
|
284 |
private boolean hasPrintedPackageIndex(PackageElement pkg) { |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
29957
diff
changeset
|
285 |
for (PackageElement printedPkg : printedPackageHeaders) { |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
29957
diff
changeset
|
286 |
if (utils.getPackageName(pkg).startsWith(utils.parsePackageName(printedPkg))) { |
10 | 287 |
return true; |
288 |
} |
|
289 |
} |
|
290 |
return false; |
|
291 |
} |
|
292 |
||
293 |
/** |
|
294 |
* Print the table of constants. |
|
295 |
* |
|
296 |
* @author Jamie Ho |
|
297 |
*/ |
|
298 |
private class ConstantFieldBuilder { |
|
299 |
||
300 |
/** |
|
35426
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
29957
diff
changeset
|
301 |
* The typeElement that we are examining constants for. |
10 | 302 |
*/ |
35426
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
29957
diff
changeset
|
303 |
protected TypeElement typeElement; |
10 | 304 |
|
305 |
/** |
|
306 |
* Construct a ConstantFieldSubWriter. |
|
35426
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
29957
diff
changeset
|
307 |
* @param typeElement the typeElement that we are examining constants for. |
10 | 308 |
*/ |
35426
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
29957
diff
changeset
|
309 |
public ConstantFieldBuilder(TypeElement typeElement) { |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
29957
diff
changeset
|
310 |
this.typeElement = typeElement; |
10 | 311 |
} |
312 |
||
313 |
/** |
|
314 |
* 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
|
315 |
* |
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5855
diff
changeset
|
316 |
* @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
|
317 |
* will be added |
10 | 318 |
*/ |
45599 | 319 |
protected void buildMembersSummary(Content classConstantTree) { |
35426
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
29957
diff
changeset
|
320 |
SortedSet<VariableElement> members = members(); |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
29957
diff
changeset
|
321 |
if (!members.isEmpty()) { |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
29957
diff
changeset
|
322 |
writer.addConstantMembers(typeElement, members, classConstantTree); |
10 | 323 |
} |
324 |
} |
|
325 |
||
326 |
/** |
|
42000
8b7412f7eecd
8167967: javadoc should identify the ordinal value of enum constants
ksrini
parents:
40587
diff
changeset
|
327 |
* 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
|
328 |
* @return the set of visible constant fields for the given type. |
10 | 329 |
*/ |
35426
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
29957
diff
changeset
|
330 |
protected SortedSet<VariableElement> members() { |
49879
601277b1d582
8025091: VisibleMemberMap.java possible performance improvements
ksrini
parents:
47216
diff
changeset
|
331 |
VisibleMemberTable vmt = configuration.getVisibleMemberTable(typeElement); |
601277b1d582
8025091: VisibleMemberMap.java possible performance improvements
ksrini
parents:
47216
diff
changeset
|
332 |
List<Element> members = new ArrayList<>(); |
601277b1d582
8025091: VisibleMemberMap.java possible performance improvements
ksrini
parents:
47216
diff
changeset
|
333 |
members.addAll(vmt.getVisibleMembers(FIELDS)); |
601277b1d582
8025091: VisibleMemberMap.java possible performance improvements
ksrini
parents:
47216
diff
changeset
|
334 |
members.addAll(vmt.getVisibleMembers(ENUM_CONSTANTS)); |
42000
8b7412f7eecd
8167967: javadoc should identify the ordinal value of enum constants
ksrini
parents:
40587
diff
changeset
|
335 |
SortedSet<VariableElement> includes = |
35426
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
29957
diff
changeset
|
336 |
new TreeSet<>(utils.makeGeneralPurposeComparator()); |
42000
8b7412f7eecd
8167967: javadoc should identify the ordinal value of enum constants
ksrini
parents:
40587
diff
changeset
|
337 |
for (Element element : members) { |
35426
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
29957
diff
changeset
|
338 |
VariableElement member = (VariableElement)element; |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
29957
diff
changeset
|
339 |
if (member.getConstantValue() != null) { |
42000
8b7412f7eecd
8167967: javadoc should identify the ordinal value of enum constants
ksrini
parents:
40587
diff
changeset
|
340 |
includes.add(member); |
10 | 341 |
} |
342 |
} |
|
42000
8b7412f7eecd
8167967: javadoc should identify the ordinal value of enum constants
ksrini
parents:
40587
diff
changeset
|
343 |
return includes; |
10 | 344 |
} |
345 |
} |
|
346 |
} |