author | jjg |
Mon, 22 Aug 2016 16:32:40 -0700 | |
changeset 40587 | 1c355ea550ed |
parent 35426 | 374342e56a56 |
child 42000 | 8b7412f7eecd |
permissions | -rw-r--r-- |
10 | 1 |
/* |
35426
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
25874
diff
changeset
|
2 |
* Copyright (c) 2003, 2016, Oracle and/or its affiliates. All rights reserved. |
10 | 3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 |
* |
|
5 |
* This code is free software; you can redistribute it and/or modify it |
|
6 |
* under the terms of the GNU General Public License version 2 only, as |
|
5520 | 7 |
* published by the Free Software Foundation. Oracle designates this |
10 | 8 |
* particular file as subject to the "Classpath" exception as provided |
5520 | 9 |
* by Oracle in the LICENSE file that accompanied this code. |
10 | 10 |
* |
11 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
|
12 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
|
13 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
|
14 |
* version 2 for more details (a copy is included in the LICENSE file that |
|
15 |
* accompanied this code). |
|
16 |
* |
|
17 |
* You should have received a copy of the GNU General Public License version |
|
18 |
* 2 along with this work; if not, write to the Free Software Foundation, |
|
19 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
|
20 |
* |
|
5520 | 21 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
22 |
* or visit www.oracle.com if you need additional information or have any |
|
23 |
* questions. |
|
10 | 24 |
*/ |
25 |
||
35426
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
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; |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
25874
diff
changeset
|
34 |
import jdk.javadoc.internal.doclets.toolkit.Configuration; |
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; |
35426
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
25874
diff
changeset
|
37 |
import jdk.javadoc.internal.doclets.toolkit.util.VisibleMemberMap; |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
25874
diff
changeset
|
38 |
|
10 | 39 |
|
40 |
/** |
|
41 |
* Builds documentation for required annotation type members. |
|
42 |
* |
|
14260
727a84636f12
8000665: fix "internal API" comments on javadoc files
jjg
parents:
14258
diff
changeset
|
43 |
* <p><b>This is NOT part of any supported API. |
727a84636f12
8000665: fix "internal API" comments on javadoc files
jjg
parents:
14258
diff
changeset
|
44 |
* 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
|
45 |
* 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
|
46 |
* deletion without notice.</b> |
10 | 47 |
* |
48 |
* @author Jamie Ho |
|
7614
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5855
diff
changeset
|
49 |
* @author Bhavesh Patel (Modified) |
10 | 50 |
*/ |
51 |
public class AnnotationTypeRequiredMemberBuilder extends AbstractMemberBuilder { |
|
52 |
||
53 |
/** |
|
54 |
* The annotation type whose members are being documented. |
|
55 |
*/ |
|
35426
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
25874
diff
changeset
|
56 |
protected TypeElement typeElement; |
10 | 57 |
|
58 |
/** |
|
59 |
* The visible members for the given class. |
|
60 |
*/ |
|
61 |
protected VisibleMemberMap visibleMemberMap; |
|
62 |
||
63 |
/** |
|
64 |
* The writer to output the member documentation. |
|
65 |
*/ |
|
66 |
protected AnnotationTypeRequiredMemberWriter writer; |
|
67 |
||
68 |
/** |
|
69 |
* The list of members being documented. |
|
70 |
*/ |
|
35426
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
25874
diff
changeset
|
71 |
protected SortedSet<Element> members; |
10 | 72 |
|
73 |
/** |
|
74 |
* The index of the current member that is being documented at this point |
|
75 |
* in time. |
|
76 |
*/ |
|
35426
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
25874
diff
changeset
|
77 |
protected Element currentMember; |
10 | 78 |
|
79 |
/** |
|
80 |
* Construct a new AnnotationTypeRequiredMemberBuilder. |
|
81 |
* |
|
14542 | 82 |
* @param context the build context. |
35426
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
25874
diff
changeset
|
83 |
* @param typeElement the class whose members are being documented. |
14542 | 84 |
* @param writer the doclet specific writer. |
10 | 85 |
*/ |
14542 | 86 |
protected AnnotationTypeRequiredMemberBuilder(Context context, |
35426
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
25874
diff
changeset
|
87 |
TypeElement typeElement, |
14542 | 88 |
AnnotationTypeRequiredMemberWriter writer, |
35426
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
25874
diff
changeset
|
89 |
VisibleMemberMap.Kind memberType) { |
14542 | 90 |
super(context); |
35426
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
25874
diff
changeset
|
91 |
this.typeElement = typeElement; |
14542 | 92 |
this.writer = writer; |
35426
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
25874
diff
changeset
|
93 |
this.visibleMemberMap = new VisibleMemberMap(typeElement, memberType, configuration); |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
25874
diff
changeset
|
94 |
this.members = this.visibleMemberMap.getMembersFor(typeElement); |
10 | 95 |
} |
96 |
||
97 |
||
98 |
/** |
|
99 |
* Construct a new AnnotationTypeMemberBuilder. |
|
100 |
* |
|
14542 | 101 |
* @param context the build context. |
35426
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
25874
diff
changeset
|
102 |
* @param typeElement the class whose members are being documented. |
10 | 103 |
* @param writer the doclet specific writer. |
104 |
*/ |
|
105 |
public static AnnotationTypeRequiredMemberBuilder getInstance( |
|
35426
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
25874
diff
changeset
|
106 |
Context context, TypeElement typeElement, |
10 | 107 |
AnnotationTypeRequiredMemberWriter writer) { |
35426
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
25874
diff
changeset
|
108 |
return new AnnotationTypeRequiredMemberBuilder(context, typeElement, |
14542 | 109 |
writer, |
35426
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
25874
diff
changeset
|
110 |
VisibleMemberMap.Kind.ANNOTATION_TYPE_MEMBER_REQUIRED); |
10 | 111 |
} |
112 |
||
113 |
/** |
|
114 |
* {@inheritDoc} |
|
115 |
*/ |
|
35426
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
25874
diff
changeset
|
116 |
@Override |
10 | 117 |
public String getName() { |
118 |
return "AnnotationTypeRequiredMemberDetails"; |
|
119 |
} |
|
120 |
||
121 |
/** |
|
122 |
* Returns a list of members that will be documented for the given class. |
|
123 |
* This information can be used for doclet specific documentation |
|
124 |
* generation. |
|
125 |
* |
|
35426
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
25874
diff
changeset
|
126 |
* @param typeElement the {@link TypeElement} we want to check. |
10 | 127 |
* @return a list of members that will be documented. |
128 |
*/ |
|
35426
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
25874
diff
changeset
|
129 |
public SortedSet<Element> members(TypeElement typeElement) { |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
25874
diff
changeset
|
130 |
return visibleMemberMap.getMembersFor(typeElement); |
10 | 131 |
} |
132 |
||
133 |
/** |
|
134 |
* Returns the visible member map for the members of this class. |
|
135 |
* |
|
136 |
* @return the visible member map for the members of this class. |
|
137 |
*/ |
|
138 |
public VisibleMemberMap getVisibleMemberMap() { |
|
139 |
return visibleMemberMap; |
|
140 |
} |
|
141 |
||
142 |
/** |
|
40587 | 143 |
* Returns whether or not there are members to document. |
144 |
* @return whether or not there are members to document |
|
10 | 145 |
*/ |
35426
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
25874
diff
changeset
|
146 |
@Override |
10 | 147 |
public boolean hasMembersToDocument() { |
148 |
return members.size() > 0; |
|
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 annotation type required member documentation. |
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 node the XML element that specifies which components to document |
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5855
diff
changeset
|
155 |
* @param memberDetailsTree the content tree to which the documentation will be added |
40587 | 156 |
* @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
|
157 |
*/ |
40587 | 158 |
public void buildAnnotationTypeRequiredMember(XMLNode node, Content memberDetailsTree) |
159 |
throws DocletException { |
|
7614
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5855
diff
changeset
|
160 |
buildAnnotationTypeMember(node, memberDetailsTree); |
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5855
diff
changeset
|
161 |
} |
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5855
diff
changeset
|
162 |
|
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5855
diff
changeset
|
163 |
/** |
10 | 164 |
* Build the member documentation. |
165 |
* |
|
7614
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5855
diff
changeset
|
166 |
* @param node the XML element that specifies which components to document |
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5855
diff
changeset
|
167 |
* @param memberDetailsTree the content tree to which the documentation will be added |
10 | 168 |
*/ |
40587 | 169 |
public void buildAnnotationTypeMember(XMLNode node, Content memberDetailsTree) |
170 |
throws DocletException { |
|
10 | 171 |
if (writer == null) { |
172 |
return; |
|
173 |
} |
|
7614
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5855
diff
changeset
|
174 |
int size = members.size(); |
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5855
diff
changeset
|
175 |
if (size > 0) { |
20237
b6d89903c867
8015249: javadoc fails to document static final fields in annotation types
bpatel
parents:
16319
diff
changeset
|
176 |
writer.addAnnotationDetailsMarker(memberDetailsTree); |
35426
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
25874
diff
changeset
|
177 |
for (Element element : members) { |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
25874
diff
changeset
|
178 |
currentMember = element; |
20237
b6d89903c867
8015249: javadoc fails to document static final fields in annotation types
bpatel
parents:
16319
diff
changeset
|
179 |
Content detailsTree = writer.getMemberTreeHeader(); |
35426
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
25874
diff
changeset
|
180 |
writer.addAnnotationDetailsTreeHeader(typeElement, detailsTree); |
7614
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5855
diff
changeset
|
181 |
Content annotationDocTree = writer.getAnnotationDocTreeHeader( |
35426
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
25874
diff
changeset
|
182 |
element, detailsTree); |
7614
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5855
diff
changeset
|
183 |
buildChildren(node, annotationDocTree); |
20237
b6d89903c867
8015249: javadoc fails to document static final fields in annotation types
bpatel
parents:
16319
diff
changeset
|
184 |
detailsTree.addContent(writer.getAnnotationDoc( |
35426
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
25874
diff
changeset
|
185 |
annotationDocTree, currentMember == members.last())); |
20237
b6d89903c867
8015249: javadoc fails to document static final fields in annotation types
bpatel
parents:
16319
diff
changeset
|
186 |
memberDetailsTree.addContent(writer.getAnnotationDetails(detailsTree)); |
7614
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5855
diff
changeset
|
187 |
} |
10 | 188 |
} |
189 |
} |
|
190 |
||
191 |
/** |
|
7614
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5855
diff
changeset
|
192 |
* Build the signature. |
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5855
diff
changeset
|
193 |
* |
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5855
diff
changeset
|
194 |
* @param node the XML element that specifies which components to document |
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5855
diff
changeset
|
195 |
* @param annotationDocTree the content tree to which the documentation will be added |
10 | 196 |
*/ |
7614
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5855
diff
changeset
|
197 |
public void buildSignature(XMLNode node, Content annotationDocTree) { |
35426
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
25874
diff
changeset
|
198 |
annotationDocTree.addContent(writer.getSignature(currentMember)); |
10 | 199 |
} |
200 |
||
201 |
/** |
|
202 |
* Build the deprecation information. |
|
7614
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5855
diff
changeset
|
203 |
* |
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5855
diff
changeset
|
204 |
* @param node the XML element that specifies which components to document |
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5855
diff
changeset
|
205 |
* @param annotationDocTree the content tree to which the documentation will be added |
10 | 206 |
*/ |
7614
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5855
diff
changeset
|
207 |
public void buildDeprecationInfo(XMLNode node, Content annotationDocTree) { |
35426
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
25874
diff
changeset
|
208 |
writer.addDeprecated(currentMember, annotationDocTree); |
10 | 209 |
} |
210 |
||
211 |
/** |
|
212 |
* Build the comments for the member. Do nothing if |
|
213 |
* {@link Configuration#nocomment} is set to true. |
|
7614
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5855
diff
changeset
|
214 |
* |
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5855
diff
changeset
|
215 |
* @param node the XML element that specifies which components to document |
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5855
diff
changeset
|
216 |
* @param annotationDocTree the content tree to which the documentation will be added |
10 | 217 |
*/ |
7614
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5855
diff
changeset
|
218 |
public void buildMemberComments(XMLNode node, Content annotationDocTree) { |
35426
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
25874
diff
changeset
|
219 |
if(! configuration.nocomment) { |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
25874
diff
changeset
|
220 |
writer.addComments(currentMember, annotationDocTree); |
10 | 221 |
} |
222 |
} |
|
223 |
||
224 |
/** |
|
225 |
* Build the tag information. |
|
7614
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5855
diff
changeset
|
226 |
* |
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5855
diff
changeset
|
227 |
* @param node the XML element that specifies which components to document |
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5855
diff
changeset
|
228 |
* @param annotationDocTree the content tree to which the documentation will be added |
10 | 229 |
*/ |
7614
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5855
diff
changeset
|
230 |
public void buildTagInfo(XMLNode node, Content annotationDocTree) { |
35426
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
25874
diff
changeset
|
231 |
writer.addTags(currentMember, annotationDocTree); |
10 | 232 |
} |
233 |
||
234 |
/** |
|
235 |
* Return the annotation type required member writer for this builder. |
|
236 |
* |
|
237 |
* @return the annotation type required member constant writer for this |
|
238 |
* builder. |
|
239 |
*/ |
|
240 |
public AnnotationTypeRequiredMemberWriter getWriter() { |
|
241 |
return writer; |
|
242 |
} |
|
243 |
} |