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