author | ksrini |
Tue, 24 Apr 2018 11:54:03 -0700 | |
changeset 49879 | 601277b1d582 |
parent 47216 | 71c04702a3d5 |
child 54060 | 53a95878619f |
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:
25874
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:
25874
diff
changeset
|
30 |
import javax.lang.model.element.Element; |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
25874
diff
changeset
|
31 |
import javax.lang.model.element.TypeElement; |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
25874
diff
changeset
|
32 |
|
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
25874
diff
changeset
|
33 |
import jdk.javadoc.internal.doclets.toolkit.AnnotationTypeRequiredMemberWriter; |
45417 | 34 |
import jdk.javadoc.internal.doclets.toolkit.BaseConfiguration; |
35426
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
25874
diff
changeset
|
35 |
import jdk.javadoc.internal.doclets.toolkit.Content; |
40587 | 36 |
import jdk.javadoc.internal.doclets.toolkit.DocletException; |
49879
601277b1d582
8025091: VisibleMemberMap.java possible performance improvements
ksrini
parents:
47216
diff
changeset
|
37 |
import jdk.javadoc.internal.doclets.toolkit.util.VisibleMemberTable; |
35426
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
25874
diff
changeset
|
38 |
|
49879
601277b1d582
8025091: VisibleMemberMap.java possible performance improvements
ksrini
parents:
47216
diff
changeset
|
39 |
import static jdk.javadoc.internal.doclets.toolkit.util.VisibleMemberTable.Kind.*; |
10 | 40 |
|
41 |
/** |
|
42 |
* Builds documentation for required annotation type members. |
|
43 |
* |
|
14260
727a84636f12
8000665: fix "internal API" comments on javadoc files
jjg
parents:
14258
diff
changeset
|
44 |
* <p><b>This is NOT part of any supported API. |
727a84636f12
8000665: fix "internal API" comments on javadoc files
jjg
parents:
14258
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:
14258
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:
14258
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 AnnotationTypeRequiredMemberBuilder extends AbstractMemberBuilder { |
|
53 |
||
54 |
||
55 |
/** |
|
56 |
* The writer to output the member documentation. |
|
57 |
*/ |
|
58 |
protected AnnotationTypeRequiredMemberWriter writer; |
|
59 |
||
60 |
/** |
|
61 |
* The list of members being documented. |
|
62 |
*/ |
|
49879
601277b1d582
8025091: VisibleMemberMap.java possible performance improvements
ksrini
parents:
47216
diff
changeset
|
63 |
protected List<? extends Element> members; |
10 | 64 |
|
65 |
/** |
|
66 |
* The index of the current member that is being documented at this point |
|
67 |
* in time. |
|
68 |
*/ |
|
35426
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
25874
diff
changeset
|
69 |
protected Element currentMember; |
10 | 70 |
|
71 |
/** |
|
72 |
* Construct a new AnnotationTypeRequiredMemberBuilder. |
|
73 |
* |
|
14542 | 74 |
* @param context the build context. |
35426
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
25874
diff
changeset
|
75 |
* @param typeElement the class whose members are being documented. |
14542 | 76 |
* @param writer the doclet specific writer. |
42000
8b7412f7eecd
8167967: javadoc should identify the ordinal value of enum constants
ksrini
parents:
40587
diff
changeset
|
77 |
* @param memberType the kind of member this builder processes. |
10 | 78 |
*/ |
14542 | 79 |
protected AnnotationTypeRequiredMemberBuilder(Context context, |
35426
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
25874
diff
changeset
|
80 |
TypeElement typeElement, |
14542 | 81 |
AnnotationTypeRequiredMemberWriter writer, |
49879
601277b1d582
8025091: VisibleMemberMap.java possible performance improvements
ksrini
parents:
47216
diff
changeset
|
82 |
VisibleMemberTable.Kind memberType) { |
601277b1d582
8025091: VisibleMemberMap.java possible performance improvements
ksrini
parents:
47216
diff
changeset
|
83 |
super(context, typeElement); |
14542 | 84 |
this.writer = writer; |
49879
601277b1d582
8025091: VisibleMemberMap.java possible performance improvements
ksrini
parents:
47216
diff
changeset
|
85 |
this.members = getVisibleMembers(memberType); |
10 | 86 |
} |
87 |
||
88 |
||
89 |
/** |
|
90 |
* Construct a new AnnotationTypeMemberBuilder. |
|
91 |
* |
|
14542 | 92 |
* @param context the build context. |
35426
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
25874
diff
changeset
|
93 |
* @param typeElement the class whose members are being documented. |
10 | 94 |
* @param writer the doclet specific writer. |
42000
8b7412f7eecd
8167967: javadoc should identify the ordinal value of enum constants
ksrini
parents:
40587
diff
changeset
|
95 |
* @return an instance of this object |
10 | 96 |
*/ |
97 |
public static AnnotationTypeRequiredMemberBuilder getInstance( |
|
35426
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
25874
diff
changeset
|
98 |
Context context, TypeElement typeElement, |
10 | 99 |
AnnotationTypeRequiredMemberWriter writer) { |
35426
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
25874
diff
changeset
|
100 |
return new AnnotationTypeRequiredMemberBuilder(context, typeElement, |
49879
601277b1d582
8025091: VisibleMemberMap.java possible performance improvements
ksrini
parents:
47216
diff
changeset
|
101 |
writer, ANNOTATION_TYPE_MEMBER_REQUIRED); |
10 | 102 |
} |
103 |
||
104 |
/** |
|
40587 | 105 |
* Returns whether or not there are members to document. |
106 |
* @return whether or not there are members to document |
|
10 | 107 |
*/ |
35426
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
25874
diff
changeset
|
108 |
@Override |
10 | 109 |
public boolean hasMembersToDocument() { |
42000
8b7412f7eecd
8167967: javadoc should identify the ordinal value of enum constants
ksrini
parents:
40587
diff
changeset
|
110 |
return !members.isEmpty(); |
10 | 111 |
} |
112 |
||
113 |
/** |
|
45599 | 114 |
* {@inheritDoc} |
115 |
*/ |
|
116 |
@Override |
|
117 |
public void build(Content contentTree) throws DocletException { |
|
118 |
buildAnnotationTypeRequiredMember(contentTree); |
|
119 |
} |
|
120 |
||
121 |
/** |
|
7614
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5855
diff
changeset
|
122 |
* Build the annotation type required member documentation. |
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5855
diff
changeset
|
123 |
* |
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5855
diff
changeset
|
124 |
* @param memberDetailsTree the content tree to which the documentation will be added |
40587 | 125 |
* @throws DocletException if there is a problem while building the documentation |
7614
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5855
diff
changeset
|
126 |
*/ |
45599 | 127 |
protected void buildAnnotationTypeRequiredMember(Content memberDetailsTree) |
40587 | 128 |
throws DocletException { |
45599 | 129 |
buildAnnotationTypeMember(memberDetailsTree); |
7614
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5855
diff
changeset
|
130 |
} |
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5855
diff
changeset
|
131 |
|
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5855
diff
changeset
|
132 |
/** |
10 | 133 |
* Build the member documentation. |
134 |
* |
|
7614
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5855
diff
changeset
|
135 |
* @param memberDetailsTree the content tree to which the documentation will be added |
42000
8b7412f7eecd
8167967: javadoc should identify the ordinal value of enum constants
ksrini
parents:
40587
diff
changeset
|
136 |
* @throws DocletException if an error occurs |
10 | 137 |
*/ |
45599 | 138 |
protected void buildAnnotationTypeMember(Content memberDetailsTree) |
40587 | 139 |
throws DocletException { |
10 | 140 |
if (writer == null) { |
141 |
return; |
|
142 |
} |
|
42000
8b7412f7eecd
8167967: javadoc should identify the ordinal value of enum constants
ksrini
parents:
40587
diff
changeset
|
143 |
if (hasMembersToDocument()) { |
20237
b6d89903c867
8015249: javadoc fails to document static final fields in annotation types
bpatel
parents:
16319
diff
changeset
|
144 |
writer.addAnnotationDetailsMarker(memberDetailsTree); |
42000
8b7412f7eecd
8167967: javadoc should identify the ordinal value of enum constants
ksrini
parents:
40587
diff
changeset
|
145 |
Element lastMember = members.get((members.size() - 1)); |
8b7412f7eecd
8167967: javadoc should identify the ordinal value of enum constants
ksrini
parents:
40587
diff
changeset
|
146 |
for (Element member : members) { |
8b7412f7eecd
8167967: javadoc should identify the ordinal value of enum constants
ksrini
parents:
40587
diff
changeset
|
147 |
currentMember = member; |
20237
b6d89903c867
8015249: javadoc fails to document static final fields in annotation types
bpatel
parents:
16319
diff
changeset
|
148 |
Content detailsTree = writer.getMemberTreeHeader(); |
35426
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
25874
diff
changeset
|
149 |
writer.addAnnotationDetailsTreeHeader(typeElement, detailsTree); |
7614
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5855
diff
changeset
|
150 |
Content annotationDocTree = writer.getAnnotationDocTreeHeader( |
42000
8b7412f7eecd
8167967: javadoc should identify the ordinal value of enum constants
ksrini
parents:
40587
diff
changeset
|
151 |
currentMember, detailsTree); |
45599 | 152 |
|
153 |
buildAnnotationTypeMemberChildren(annotationDocTree); |
|
154 |
||
20237
b6d89903c867
8015249: javadoc fails to document static final fields in annotation types
bpatel
parents:
16319
diff
changeset
|
155 |
detailsTree.addContent(writer.getAnnotationDoc( |
42000
8b7412f7eecd
8167967: javadoc should identify the ordinal value of enum constants
ksrini
parents:
40587
diff
changeset
|
156 |
annotationDocTree, currentMember == lastMember)); |
20237
b6d89903c867
8015249: javadoc fails to document static final fields in annotation types
bpatel
parents:
16319
diff
changeset
|
157 |
memberDetailsTree.addContent(writer.getAnnotationDetails(detailsTree)); |
7614
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5855
diff
changeset
|
158 |
} |
10 | 159 |
} |
160 |
} |
|
161 |
||
45599 | 162 |
protected void buildAnnotationTypeMemberChildren(Content annotationDocTree) { |
163 |
buildSignature(annotationDocTree); |
|
164 |
buildDeprecationInfo(annotationDocTree); |
|
165 |
buildMemberComments(annotationDocTree); |
|
166 |
buildTagInfo(annotationDocTree); |
|
167 |
} |
|
168 |
||
10 | 169 |
/** |
7614
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5855
diff
changeset
|
170 |
* Build the signature. |
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5855
diff
changeset
|
171 |
* |
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5855
diff
changeset
|
172 |
* @param annotationDocTree the content tree to which the documentation will be added |
10 | 173 |
*/ |
45599 | 174 |
protected void buildSignature(Content annotationDocTree) { |
35426
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
25874
diff
changeset
|
175 |
annotationDocTree.addContent(writer.getSignature(currentMember)); |
10 | 176 |
} |
177 |
||
178 |
/** |
|
179 |
* Build the deprecation information. |
|
7614
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5855
diff
changeset
|
180 |
* |
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5855
diff
changeset
|
181 |
* @param annotationDocTree the content tree to which the documentation will be added |
10 | 182 |
*/ |
45599 | 183 |
protected void buildDeprecationInfo(Content annotationDocTree) { |
35426
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
25874
diff
changeset
|
184 |
writer.addDeprecated(currentMember, annotationDocTree); |
10 | 185 |
} |
186 |
||
187 |
/** |
|
188 |
* Build the comments for the member. Do nothing if |
|
45417 | 189 |
* {@link BaseConfiguration#nocomment} is set to true. |
7614
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5855
diff
changeset
|
190 |
* |
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5855
diff
changeset
|
191 |
* @param annotationDocTree the content tree to which the documentation will be added |
10 | 192 |
*/ |
45599 | 193 |
protected void buildMemberComments(Content annotationDocTree) { |
194 |
if (!configuration.nocomment) { |
|
35426
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
25874
diff
changeset
|
195 |
writer.addComments(currentMember, annotationDocTree); |
10 | 196 |
} |
197 |
} |
|
198 |
||
199 |
/** |
|
200 |
* Build the tag information. |
|
7614
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5855
diff
changeset
|
201 |
* |
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5855
diff
changeset
|
202 |
* @param annotationDocTree the content tree to which the documentation will be added |
10 | 203 |
*/ |
45599 | 204 |
protected void buildTagInfo(Content annotationDocTree) { |
35426
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
25874
diff
changeset
|
205 |
writer.addTags(currentMember, annotationDocTree); |
10 | 206 |
} |
207 |
||
208 |
/** |
|
209 |
* Return the annotation type required member writer for this builder. |
|
210 |
* |
|
211 |
* @return the annotation type required member constant writer for this |
|
212 |
* builder. |
|
213 |
*/ |
|
214 |
public AnnotationTypeRequiredMemberWriter getWriter() { |
|
215 |
return writer; |
|
216 |
} |
|
217 |
} |