author | ksrini |
Mon, 05 Jun 2017 13:45:34 -0700 | |
changeset 45417 | f7479ee8de69 |
parent 40587 | 1c355ea550ed |
child 45599 | 8bc3a019f948 |
permissions | -rw-r--r-- |
10 | 1 |
/* |
45417 | 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:
25874
diff
changeset
|
26 |
package jdk.javadoc.internal.doclets.toolkit.builders; |
10 | 27 |
|
14542 | 28 |
import java.util.HashSet; |
29 |
import java.util.Set; |
|
30 |
||
36526 | 31 |
import javax.lang.model.element.ModuleElement; |
35426
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
25874
diff
changeset
|
32 |
import javax.lang.model.element.PackageElement; |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
25874
diff
changeset
|
33 |
import javax.lang.model.element.TypeElement; |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
25874
diff
changeset
|
34 |
import javax.lang.model.type.TypeMirror; |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
25874
diff
changeset
|
35 |
|
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
25874
diff
changeset
|
36 |
import jdk.javadoc.internal.doclets.toolkit.AnnotationTypeWriter; |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
25874
diff
changeset
|
37 |
import jdk.javadoc.internal.doclets.toolkit.ClassWriter; |
45417 | 38 |
import jdk.javadoc.internal.doclets.toolkit.BaseConfiguration; |
35426
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
25874
diff
changeset
|
39 |
import jdk.javadoc.internal.doclets.toolkit.PropertyWriter; |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
25874
diff
changeset
|
40 |
import jdk.javadoc.internal.doclets.toolkit.WriterFactory; |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
25874
diff
changeset
|
41 |
import jdk.javadoc.internal.doclets.toolkit.util.ClassTree; |
10 | 42 |
|
43 |
/** |
|
44 |
* The factory for constructing builders. |
|
45 |
* |
|
14260
727a84636f12
8000665: fix "internal API" comments on javadoc files
jjg
parents:
14258
diff
changeset
|
46 |
* <p><b>This is NOT part of any supported API. |
727a84636f12
8000665: fix "internal API" comments on javadoc files
jjg
parents:
14258
diff
changeset
|
47 |
* 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
|
48 |
* 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
|
49 |
* deletion without notice.</b> |
10 | 50 |
* |
51 |
* @author Jamie Ho |
|
52 |
*/ |
|
53 |
||
54 |
public class BuilderFactory { |
|
55 |
||
56 |
/** |
|
57 |
* The current configuration of the doclet. |
|
58 |
*/ |
|
45417 | 59 |
private final BaseConfiguration configuration; |
10 | 60 |
|
61 |
/** |
|
62 |
* The factory to retrieve the required writers from. |
|
63 |
*/ |
|
14542 | 64 |
private final WriterFactory writerFactory; |
65 |
||
66 |
private final AbstractBuilder.Context context; |
|
10 | 67 |
|
68 |
/** |
|
69 |
* Construct a builder factory using the given configuration. |
|
70 |
* @param configuration the configuration for the current doclet |
|
71 |
* being executed. |
|
72 |
*/ |
|
45417 | 73 |
public BuilderFactory (BaseConfiguration configuration) { |
10 | 74 |
this.configuration = configuration; |
75 |
this.writerFactory = configuration.getWriterFactory(); |
|
14542 | 76 |
|
35426
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
25874
diff
changeset
|
77 |
Set<PackageElement> containingPackagesSeen = new HashSet<>(); |
14542 | 78 |
context = new AbstractBuilder.Context(configuration, containingPackagesSeen, |
79 |
LayoutParser.getInstance(configuration)); |
|
10 | 80 |
} |
81 |
||
82 |
/** |
|
83 |
* Return the builder that builds the constant summary. |
|
84 |
* @return the builder that builds the constant summary. |
|
85 |
*/ |
|
40587 | 86 |
public AbstractBuilder getConstantsSummaryBuilder() { |
14542 | 87 |
return ConstantsSummaryBuilder.getInstance(context, |
10 | 88 |
writerFactory.getConstantsSummaryWriter()); |
89 |
} |
|
90 |
||
91 |
/** |
|
92 |
* Return the builder that builds the package summary. |
|
93 |
* |
|
94 |
* @param pkg the package being documented. |
|
95 |
* @param prevPkg the previous package being documented. |
|
96 |
* @param nextPkg the next package being documented. |
|
97 |
* @return the builder that builds the constant summary. |
|
98 |
*/ |
|
35426
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
25874
diff
changeset
|
99 |
public AbstractBuilder getPackageSummaryBuilder(PackageElement pkg, PackageElement prevPkg, |
40587 | 100 |
PackageElement nextPkg) { |
14542 | 101 |
return PackageSummaryBuilder.getInstance(context, pkg, |
10 | 102 |
writerFactory.getPackageSummaryWriter(pkg, prevPkg, nextPkg)); |
103 |
} |
|
104 |
||
105 |
/** |
|
36526 | 106 |
* Return the builder that builds the module summary. |
107 |
* |
|
108 |
* @param mdle the module being documented. |
|
109 |
* @param prevModule the previous module being documented. |
|
110 |
* @param nextModule the next module being documented. |
|
111 |
* @return the builder that builds the module summary. |
|
112 |
*/ |
|
113 |
public AbstractBuilder getModuleSummaryBuilder(ModuleElement mdle, ModuleElement prevModule, |
|
40587 | 114 |
ModuleElement nextModule) { |
36526 | 115 |
return ModuleSummaryBuilder.getInstance(context, mdle, |
116 |
writerFactory.getModuleSummaryWriter(mdle, prevModule, nextModule)); |
|
117 |
} |
|
118 |
||
119 |
/** |
|
10 | 120 |
* Return the builder for the class. |
121 |
* |
|
35426
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
25874
diff
changeset
|
122 |
* @param typeElement the class being documented. |
10 | 123 |
* @param prevClass the previous class that was documented. |
124 |
* @param nextClass the next class being documented. |
|
125 |
* @param classTree the class tree. |
|
126 |
* @return the writer for the class. Return null if this |
|
127 |
* writer is not supported by the doclet. |
|
128 |
*/ |
|
35426
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
25874
diff
changeset
|
129 |
public AbstractBuilder getClassBuilder(TypeElement typeElement, |
40587 | 130 |
TypeElement prevClass, TypeElement nextClass, ClassTree classTree) { |
35426
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
25874
diff
changeset
|
131 |
return ClassBuilder.getInstance(context, typeElement, |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
25874
diff
changeset
|
132 |
writerFactory.getClassWriter(typeElement, prevClass, nextClass, classTree)); |
10 | 133 |
} |
134 |
||
135 |
/** |
|
136 |
* Return the builder for the annotation type. |
|
137 |
* |
|
138 |
* @param annotationType the annotation type being documented. |
|
139 |
* @param prevType the previous type that was documented. |
|
140 |
* @param nextType the next type being documented. |
|
141 |
* @return the writer for the annotation type. Return null if this |
|
142 |
* writer is not supported by the doclet. |
|
143 |
*/ |
|
144 |
public AbstractBuilder getAnnotationTypeBuilder( |
|
40587 | 145 |
TypeElement annotationType, TypeMirror prevType, TypeMirror nextType) { |
14542 | 146 |
return AnnotationTypeBuilder.getInstance(context, annotationType, |
147 |
writerFactory.getAnnotationTypeWriter(annotationType, prevType, nextType)); |
|
10 | 148 |
} |
149 |
||
150 |
/** |
|
151 |
* Return an instance of the method builder for the given class. |
|
152 |
* |
|
153 |
* @return an instance of the method builder for the given class. |
|
154 |
*/ |
|
40587 | 155 |
public AbstractBuilder getMethodBuilder(ClassWriter classWriter) { |
35426
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
25874
diff
changeset
|
156 |
return MethodBuilder.getInstance(context, classWriter.getTypeElement(), |
10 | 157 |
writerFactory.getMethodWriter(classWriter)); |
158 |
} |
|
159 |
||
160 |
/** |
|
20237
b6d89903c867
8015249: javadoc fails to document static final fields in annotation types
bpatel
parents:
16319
diff
changeset
|
161 |
* Return an instance of the annotation type fields builder for the given |
b6d89903c867
8015249: javadoc fails to document static final fields in annotation types
bpatel
parents:
16319
diff
changeset
|
162 |
* class. |
b6d89903c867
8015249: javadoc fails to document static final fields in annotation types
bpatel
parents:
16319
diff
changeset
|
163 |
* |
b6d89903c867
8015249: javadoc fails to document static final fields in annotation types
bpatel
parents:
16319
diff
changeset
|
164 |
* @return an instance of the annotation type field builder for the given |
b6d89903c867
8015249: javadoc fails to document static final fields in annotation types
bpatel
parents:
16319
diff
changeset
|
165 |
* annotation type. |
b6d89903c867
8015249: javadoc fails to document static final fields in annotation types
bpatel
parents:
16319
diff
changeset
|
166 |
*/ |
b6d89903c867
8015249: javadoc fails to document static final fields in annotation types
bpatel
parents:
16319
diff
changeset
|
167 |
public AbstractBuilder getAnnotationTypeFieldsBuilder( |
40587 | 168 |
AnnotationTypeWriter annotationTypeWriter) { |
20237
b6d89903c867
8015249: javadoc fails to document static final fields in annotation types
bpatel
parents:
16319
diff
changeset
|
169 |
return AnnotationTypeFieldBuilder.getInstance(context, |
35426
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
25874
diff
changeset
|
170 |
annotationTypeWriter.getAnnotationTypeElement(), |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
25874
diff
changeset
|
171 |
writerFactory.getAnnotationTypeFieldWriter(annotationTypeWriter)); |
20237
b6d89903c867
8015249: javadoc fails to document static final fields in annotation types
bpatel
parents:
16319
diff
changeset
|
172 |
} |
b6d89903c867
8015249: javadoc fails to document static final fields in annotation types
bpatel
parents:
16319
diff
changeset
|
173 |
|
b6d89903c867
8015249: javadoc fails to document static final fields in annotation types
bpatel
parents:
16319
diff
changeset
|
174 |
/** |
10 | 175 |
* Return an instance of the annotation type member builder for the given |
176 |
* class. |
|
177 |
* |
|
20237
b6d89903c867
8015249: javadoc fails to document static final fields in annotation types
bpatel
parents:
16319
diff
changeset
|
178 |
* @return an instance of the annotation type member builder for the given |
10 | 179 |
* annotation type. |
180 |
*/ |
|
181 |
public AbstractBuilder getAnnotationTypeOptionalMemberBuilder( |
|
40587 | 182 |
AnnotationTypeWriter annotationTypeWriter) { |
14542 | 183 |
return AnnotationTypeOptionalMemberBuilder.getInstance(context, |
35426
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
25874
diff
changeset
|
184 |
annotationTypeWriter.getAnnotationTypeElement(), |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
25874
diff
changeset
|
185 |
writerFactory.getAnnotationTypeOptionalMemberWriter(annotationTypeWriter)); |
10 | 186 |
} |
187 |
||
188 |
/** |
|
189 |
* Return an instance of the annotation type member builder for the given |
|
190 |
* class. |
|
191 |
* |
|
20237
b6d89903c867
8015249: javadoc fails to document static final fields in annotation types
bpatel
parents:
16319
diff
changeset
|
192 |
* @return an instance of the annotation type member builder for the given |
10 | 193 |
* annotation type. |
194 |
*/ |
|
195 |
public AbstractBuilder getAnnotationTypeRequiredMemberBuilder( |
|
40587 | 196 |
AnnotationTypeWriter annotationTypeWriter) { |
14542 | 197 |
return AnnotationTypeRequiredMemberBuilder.getInstance(context, |
35426
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
25874
diff
changeset
|
198 |
annotationTypeWriter.getAnnotationTypeElement(), |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
25874
diff
changeset
|
199 |
writerFactory.getAnnotationTypeRequiredMemberWriter(annotationTypeWriter)); |
10 | 200 |
} |
201 |
||
202 |
/** |
|
203 |
* Return an instance of the enum constants builder for the given class. |
|
204 |
* |
|
205 |
* @return an instance of the enum constants builder for the given class. |
|
206 |
*/ |
|
40587 | 207 |
public AbstractBuilder getEnumConstantsBuilder(ClassWriter classWriter) { |
35426
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
25874
diff
changeset
|
208 |
return EnumConstantBuilder.getInstance(context, classWriter.getTypeElement(), |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
25874
diff
changeset
|
209 |
writerFactory.getEnumConstantWriter(classWriter)); |
10 | 210 |
} |
211 |
||
212 |
/** |
|
213 |
* Return an instance of the field builder for the given class. |
|
214 |
* |
|
215 |
* @return an instance of the field builder for the given class. |
|
216 |
*/ |
|
40587 | 217 |
public AbstractBuilder getFieldBuilder(ClassWriter classWriter) { |
35426
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
25874
diff
changeset
|
218 |
return FieldBuilder.getInstance(context, classWriter.getTypeElement(), |
10 | 219 |
writerFactory.getFieldWriter(classWriter)); |
220 |
} |
|
221 |
||
222 |
/** |
|
16319
e586bfeb39c5
7112427: The doclet needs to be able to generate JavaFX documentation.
jjg
parents:
15723
diff
changeset
|
223 |
* Return an instance of the property builder for the given class. |
e586bfeb39c5
7112427: The doclet needs to be able to generate JavaFX documentation.
jjg
parents:
15723
diff
changeset
|
224 |
* |
e586bfeb39c5
7112427: The doclet needs to be able to generate JavaFX documentation.
jjg
parents:
15723
diff
changeset
|
225 |
* @return an instance of the field builder for the given class. |
e586bfeb39c5
7112427: The doclet needs to be able to generate JavaFX documentation.
jjg
parents:
15723
diff
changeset
|
226 |
*/ |
40587 | 227 |
public AbstractBuilder getPropertyBuilder(ClassWriter classWriter) { |
16319
e586bfeb39c5
7112427: The doclet needs to be able to generate JavaFX documentation.
jjg
parents:
15723
diff
changeset
|
228 |
final PropertyWriter propertyWriter = |
e586bfeb39c5
7112427: The doclet needs to be able to generate JavaFX documentation.
jjg
parents:
15723
diff
changeset
|
229 |
writerFactory.getPropertyWriter(classWriter); |
e586bfeb39c5
7112427: The doclet needs to be able to generate JavaFX documentation.
jjg
parents:
15723
diff
changeset
|
230 |
return PropertyBuilder.getInstance(context, |
35426
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
25874
diff
changeset
|
231 |
classWriter.getTypeElement(), |
16319
e586bfeb39c5
7112427: The doclet needs to be able to generate JavaFX documentation.
jjg
parents:
15723
diff
changeset
|
232 |
propertyWriter); |
e586bfeb39c5
7112427: The doclet needs to be able to generate JavaFX documentation.
jjg
parents:
15723
diff
changeset
|
233 |
} |
e586bfeb39c5
7112427: The doclet needs to be able to generate JavaFX documentation.
jjg
parents:
15723
diff
changeset
|
234 |
|
e586bfeb39c5
7112427: The doclet needs to be able to generate JavaFX documentation.
jjg
parents:
15723
diff
changeset
|
235 |
/** |
10 | 236 |
* Return an instance of the constructor builder for the given class. |
237 |
* |
|
238 |
* @return an instance of the constructor builder for the given class. |
|
239 |
*/ |
|
40587 | 240 |
public AbstractBuilder getConstructorBuilder(ClassWriter classWriter) { |
35426
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
25874
diff
changeset
|
241 |
return ConstructorBuilder.getInstance(context, classWriter.getTypeElement(), |
14542 | 242 |
writerFactory.getConstructorWriter(classWriter)); |
10 | 243 |
} |
244 |
||
245 |
/** |
|
246 |
* Return an instance of the member summary builder for the given class. |
|
247 |
* |
|
248 |
* @return an instance of the member summary builder for the given class. |
|
249 |
*/ |
|
40587 | 250 |
public AbstractBuilder getMemberSummaryBuilder(ClassWriter classWriter) { |
14542 | 251 |
return MemberSummaryBuilder.getInstance(classWriter, context); |
10 | 252 |
} |
253 |
||
254 |
/** |
|
255 |
* Return an instance of the member summary builder for the given annotation |
|
256 |
* type. |
|
257 |
* |
|
258 |
* @return an instance of the member summary builder for the given |
|
259 |
* annotation type. |
|
260 |
*/ |
|
40587 | 261 |
public AbstractBuilder getMemberSummaryBuilder(AnnotationTypeWriter annotationTypeWriter) { |
14542 | 262 |
return MemberSummaryBuilder.getInstance(annotationTypeWriter, context); |
10 | 263 |
} |
264 |
||
265 |
/** |
|
266 |
* Return the builder that builds the serialized form. |
|
267 |
* |
|
268 |
* @return the builder that builds the serialized form. |
|
269 |
*/ |
|
40587 | 270 |
public AbstractBuilder getSerializedFormBuilder() { |
14542 | 271 |
return SerializedFormBuilder.getInstance(context); |
10 | 272 |
} |
273 |
} |