@@ -33,7 +33,8 @@ public class Parser {
33
33
private final static Logger LOGGER = Logger .getLogger (Parser .class .getName ());
34
34
35
35
/**
36
- * A map where each key is a package name and each value is an object containing a package's JavaDoc.
36
+ * A map where each key is a package name and each value is an object containing a package's
37
+ * JavaDoc.
37
38
*/
38
39
protected Map <String , Package > packages = new TreeMap <>();
39
40
@@ -60,13 +61,14 @@ public Set<TypeElement> getClasses(final DocletEnvironment env) {
60
61
return ElementFilter .typesIn (elements );
61
62
}
62
63
63
- private String getJavaDoc (final Element element ){
64
+ private String getJavaDoc (final Element element ) {
64
65
final var docCommentTree = docTrees .getDocCommentTree (element );
65
66
return docCommentTree == null ? "" : docCommentTree .getFullBody ().toString ();
66
67
}
67
68
68
69
/**
69
70
* {@return the tags inside a JavaDoc comment}
71
+ *
70
72
* @param element the Java element to get its JavaDoc tags
71
73
*/
72
74
public List <? extends DocTree > getTags (final Element element ) {
@@ -86,7 +88,8 @@ public Root parseRootDoc() {
86
88
final Package packageNode = getPackage (rootNode , classDoc );
87
89
88
90
switch (classDoc .getKind ()) {
89
- case ANNOTATION_TYPE -> packageNode .getAnnotation ().add (parseAnnotationTypeDoc (classDoc ));
91
+ case ANNOTATION_TYPE ->
92
+ packageNode .getAnnotation ().add (parseAnnotationTypeDoc (classDoc ));
90
93
case ENUM -> packageNode .getEnum ().add (parseEnum (classDoc ));
91
94
case INTERFACE -> packageNode .getInterface ().add (parseInterface (classDoc ));
92
95
default -> packageNode .getClazz ().add (parseClass (classDoc ));
@@ -98,6 +101,7 @@ public Root parseRootDoc() {
98
101
99
102
/**
100
103
* {@return the package node for the given class element}
104
+ *
101
105
* @param rootNode
102
106
* @param classElement class to get its package
103
107
*/
@@ -144,7 +148,7 @@ protected Annotation parseAnnotationTypeDoc(final TypeElement annotationTypeDoc)
144
148
}
145
149
146
150
// TODO: What does isIncluded() mean?
147
- //annotationNode.setIncluded(annotationTypeDoc.isIncluded());
151
+ // annotationNode.setIncluded(annotationTypeDoc.isIncluded());
148
152
149
153
annotationNode .setScope (parseScope (annotationTypeDoc ));
150
154
@@ -154,7 +158,8 @@ protected Annotation parseAnnotationTypeDoc(final TypeElement annotationTypeDoc)
154
158
}
155
159
156
160
for (final AnnotationMirror annotationDesc : annotationTypeDoc .getAnnotationMirrors ()) {
157
- final var annotationInstance = parseAnnotationDesc (annotationDesc , annotationTypeDoc .getQualifiedName ());
161
+ final var annotationInstance =
162
+ parseAnnotationDesc (annotationDesc , annotationTypeDoc .getQualifiedName ());
158
163
annotationNode .getAnnotation ().add (annotationInstance );
159
164
}
160
165
@@ -171,7 +176,8 @@ protected Annotation parseAnnotationTypeDoc(final TypeElement annotationTypeDoc)
171
176
* @param annotationTypeElementDoc A AnnotationTypeElementDoc instance
172
177
* @return the annotation element node
173
178
*/
174
- protected AnnotationElement parseAnnotationTypeElementDoc (final ExecutableElement annotationTypeElementDoc ) {
179
+ protected AnnotationElement parseAnnotationTypeElementDoc (
180
+ final ExecutableElement annotationTypeElementDoc ) {
175
181
final AnnotationElement annotationElementNode = objectFactory .createAnnotationElement ();
176
182
annotationElementNode .setName (annotationTypeElementDoc .getSimpleName ().toString ());
177
183
annotationElementNode .setQualified (annotationTypeElementDoc .getSimpleName ().toString ());
@@ -192,20 +198,24 @@ protected AnnotationElement parseAnnotationTypeElementDoc(final ExecutableElemen
192
198
* @param programElement the name of a program element to parse
193
199
* @return representation of annotations
194
200
*/
195
- protected AnnotationInstance parseAnnotationDesc (final AnnotationMirror annotationDesc , final Name programElement ) {
201
+ protected AnnotationInstance parseAnnotationDesc (final AnnotationMirror annotationDesc ,
202
+ final Name programElement ) {
196
203
final AnnotationInstance annotationInstanceNode = objectFactory .createAnnotationInstance ();
197
204
198
205
try {
199
206
final var annotTypeInfo = annotationDesc .getAnnotationType ();
200
207
annotationInstanceNode .setName (annotTypeInfo .asElement ().getSimpleName ().toString ());
201
- annotationInstanceNode .setQualified (annotTypeInfo .asElement ().getSimpleName ().toString ());
208
+ annotationInstanceNode
209
+ .setQualified (annotTypeInfo .asElement ().getSimpleName ().toString ());
202
210
} catch (ClassCastException castException ) {
203
- LOGGER .severe ("Unable to obtain type data about an annotation found on: " + programElement );
211
+ LOGGER .severe (
212
+ "Unable to obtain type data about an annotation found on: " + programElement );
204
213
LOGGER .severe ("Add to the classpath the class/jar that defines this annotation." );
205
214
}
206
215
207
216
for (final var elementValuesPair : annotationDesc .getElementValues ().entrySet ()) {
208
- final AnnotationArgument annotationArgumentNode = objectFactory .createAnnotationArgument ();
217
+ final AnnotationArgument annotationArgumentNode =
218
+ objectFactory .createAnnotationArgument ();
209
219
annotationArgumentNode .setName (elementValuesPair .getKey ().getSimpleName ().toString ());
210
220
211
221
final TypeMirror annotationArgumentType = elementValuesPair .getKey ().asType ();
@@ -218,15 +228,20 @@ protected AnnotationInstance parseAnnotationDesc(final AnnotationMirror annotati
218
228
case AnnotationValue [] annotationValues -> {
219
229
for (final AnnotationValue annotationValue : annotationValues ) {
220
230
if (annotationValue .getValue () instanceof AnnotationMirror annoDesc ) {
221
- annotationArgumentNode .getAnnotation ().add (parseAnnotationDesc (annoDesc , programElement ));
231
+ annotationArgumentNode .getAnnotation ()
232
+ .add (parseAnnotationDesc (annoDesc , programElement ));
222
233
} else {
223
- annotationArgumentNode .getValue ().add (annotationValue .getValue ().toString ());
234
+ annotationArgumentNode .getValue ()
235
+ .add (annotationValue .getValue ().toString ());
224
236
}
225
237
}
226
238
}
227
- case VariableElement fieldDoc -> annotationArgumentNode .getValue ().add (fieldDoc .getSimpleName ().toString ());
228
- case TypeElement classDoc -> annotationArgumentNode .getValue ().add (classDoc .getQualifiedName ().toString ());
229
- case null -> {}
239
+ case VariableElement fieldDoc ->
240
+ annotationArgumentNode .getValue ().add (fieldDoc .getSimpleName ().toString ());
241
+ case TypeElement classDoc ->
242
+ annotationArgumentNode .getValue ().add (classDoc .getQualifiedName ().toString ());
243
+ case null -> {
244
+ }
230
245
default -> annotationArgumentNode .getValue ().add (objValue .toString ());
231
246
}
232
247
@@ -246,7 +261,7 @@ protected Enum parseEnum(final TypeElement classDoc) {
246
261
}
247
262
248
263
// TODO: What does isIncluded() mean?
249
- //enumNode.setIncluded(classDoc.isIncluded());
264
+ // enumNode.setIncluded(classDoc.isIncluded());
250
265
251
266
enumNode .setScope (parseScope (classDoc ));
252
267
@@ -264,7 +279,8 @@ protected Enum parseEnum(final TypeElement classDoc) {
264
279
}
265
280
266
281
for (final AnnotationMirror annotationDesc : classDoc .getAnnotationMirrors ()) {
267
- enumNode .getAnnotation ().add (parseAnnotationDesc (annotationDesc , classDoc .getQualifiedName ()));
282
+ enumNode .getAnnotation ()
283
+ .add (parseAnnotationDesc (annotationDesc , classDoc .getQualifiedName ()));
268
284
}
269
285
270
286
for (final DocTree tag : getTags (classDoc )) {
@@ -289,7 +305,8 @@ protected EnumConstant parseEnumConstant(final VariableElement fieldDoc) {
289
305
}
290
306
291
307
for (final AnnotationMirror annotationDesc : fieldDoc .getAnnotationMirrors ()) {
292
- enumConstant .getAnnotation ().add (parseAnnotationDesc (annotationDesc , fieldDoc .getSimpleName ()));
308
+ enumConstant .getAnnotation ()
309
+ .add (parseAnnotationDesc (annotationDesc , fieldDoc .getSimpleName ()));
293
310
}
294
311
295
312
for (final DocTree tag : getTags (fieldDoc )) {
@@ -309,7 +326,7 @@ protected Interface parseInterface(final TypeElement classDoc) {
309
326
}
310
327
311
328
// TODO: What does isIncluded() mean?
312
- //interfaceNode.setIncluded(classDoc.isIncluded());
329
+ // interfaceNode.setIncluded(classDoc.isIncluded());
313
330
314
331
interfaceNode .setScope (parseScope (classDoc ));
315
332
@@ -355,7 +372,7 @@ protected Class parseClass(final TypeElement classDoc) {
355
372
classNode .setExternalizable (typeUtils .isExternalizable (classDoc ));
356
373
357
374
// TODO: What does isIncluded() mean?
358
- //classNode.setIncluded(classDoc.isIncluded());
375
+ // classNode.setIncluded(classDoc.isIncluded());
359
376
360
377
classNode .setSerializable (typeUtils .isSerializable (classDoc ));
361
378
classNode .setScope (parseScope (classDoc ));
@@ -378,7 +395,8 @@ protected Class parseClass(final TypeElement classDoc) {
378
395
}
379
396
380
397
for (final AnnotationMirror annotationDesc : classDoc .getAnnotationMirrors ()) {
381
- final var annotationInstance = parseAnnotationDesc (annotationDesc , classDoc .getQualifiedName ());
398
+ final var annotationInstance =
399
+ parseAnnotationDesc (annotationDesc , classDoc .getQualifiedName ());
382
400
classNode .getAnnotation ().add (annotationInstance );
383
401
}
384
402
@@ -409,7 +427,7 @@ protected Constructor parseConstructor(final ExecutableElement constructorDoc) {
409
427
constructorNode .setScope (parseScope (constructorDoc ));
410
428
411
429
// TODO: What does isIncluded() mean?
412
- //constructorNode.setIncluded(constructorDoc.isIncluded());
430
+ // constructorNode.setIncluded(constructorDoc.isIncluded());
413
431
414
432
constructorNode .setFinal (hasModifier (constructorDoc , Modifier .FINAL ));
415
433
constructorNode .setNative (hasModifier (constructorDoc , Modifier .NATIVE ));
@@ -427,7 +445,8 @@ protected Constructor parseConstructor(final ExecutableElement constructorDoc) {
427
445
}
428
446
429
447
for (final AnnotationMirror annotationDesc : constructorDoc .getAnnotationMirrors ()) {
430
- final var annotationInstance = parseAnnotationDesc (annotationDesc , constructorDoc .getSimpleName ());
448
+ final var annotationInstance =
449
+ parseAnnotationDesc (annotationDesc , constructorDoc .getSimpleName ());
431
450
constructorNode .getAnnotation ().add (annotationInstance );
432
451
}
433
452
@@ -451,7 +470,7 @@ protected Method parseMethod(final ExecutableElement methodDoc) {
451
470
methodNode .setAbstract (hasModifier (methodDoc , Modifier .ABSTRACT ));
452
471
453
472
// TODO: What does isIncluded() mean?
454
- //methodNode.setIncluded(methodDoc.isIncluded());
473
+ // methodNode.setIncluded(methodDoc.isIncluded());
455
474
456
475
methodNode .setFinal (hasModifier (methodDoc , Modifier .FINAL ));
457
476
methodNode .setNative (hasModifier (methodDoc , Modifier .NATIVE ));
@@ -470,7 +489,8 @@ protected Method parseMethod(final ExecutableElement methodDoc) {
470
489
}
471
490
472
491
for (final AnnotationMirror annotationDesc : methodDoc .getAnnotationMirrors ()) {
473
- final var annotationInstance = parseAnnotationDesc (annotationDesc , methodDoc .getSimpleName ());
492
+ final var annotationInstance =
493
+ parseAnnotationDesc (annotationDesc , methodDoc .getSimpleName ());
474
494
methodNode .getAnnotation ().add (annotationInstance );
475
495
}
476
496
@@ -487,7 +507,8 @@ protected MethodParameter parseMethodParameter(final VariableElement parameter)
487
507
parameterMethodNode .setType (parseTypeInfo (parameter .asType ()));
488
508
489
509
for (final AnnotationMirror annotationDesc : parameter .getAnnotationMirrors ()) {
490
- final var annotationInstance = parseAnnotationDesc (annotationDesc , parameter .getSimpleName ());
510
+ final var annotationInstance =
511
+ parseAnnotationDesc (annotationDesc , parameter .getSimpleName ());
491
512
parameterMethodNode .getAnnotation ().add (annotationInstance );
492
513
}
493
514
@@ -511,7 +532,8 @@ protected Field parseField(final VariableElement fieldDoc) {
511
532
fieldNode .setConstant (requireNonNullElse (fieldDoc .getConstantValue (), "" ).toString ());
512
533
513
534
for (final AnnotationMirror annotationDesc : fieldDoc .getAnnotationMirrors ()) {
514
- fieldNode .getAnnotation ().add (parseAnnotationDesc (annotationDesc , fieldDoc .getSimpleName ()));
535
+ fieldNode .getAnnotation ()
536
+ .add (parseAnnotationDesc (annotationDesc , fieldDoc .getSimpleName ()));
515
537
}
516
538
517
539
for (final DocTree tag : getTags (fieldDoc )) {
@@ -587,6 +609,7 @@ protected TagInfo parseTag(final DocTree tagDoc) {
587
609
588
610
/**
589
611
* {@return string representation of the element scope}
612
+ *
590
613
* @param doc the element to get its scope
591
614
*/
592
615
protected String parseScope (final Element doc ) {
0 commit comments