@@ -129,6 +129,24 @@ private void addEmptyLinesAndCommentsBetweenNodes(ASTNode a, ASTNode b) throws C
129
129
}
130
130
}
131
131
132
+ public void addJavaDoc (Node node , Javadoc javadoc ) throws ConversionException
133
+ {
134
+ if (javadoc == null ) return ;
135
+
136
+ String [] commentLines = source .substring (javadoc .getStartPosition (),
137
+ javadoc .getStartPosition ()+javadoc .getLength ()).split ("\\ r?\\ n" );
138
+
139
+ Node commentNode = new Node (node , "CommentNode" , "comment" );
140
+ node .add (commentNode );
141
+ for (String line : commentLines )
142
+ {
143
+ Node lineNode = new Node (commentNode , "Text" , commentNode .child ("lines" ).numChildren ());
144
+ commentNode .child ("lines" ).add (lineNode );
145
+
146
+ lineNode .setStringValue (line );
147
+ }
148
+ }
149
+
132
150
public void visit (CompilationUnit node ) throws ConversionException
133
151
{
134
152
PackageDeclaration pd = node .getPackage ();
@@ -148,7 +166,7 @@ public void visit(AbstractTypeDeclaration type, boolean topLevel) throws Convers
148
166
containers .push (cl );
149
167
150
168
setBodyModifiersAndAnnotations (type );
151
- //TODO: Handle JavaDoc
169
+ addJavaDoc ( cl , type . getJavadoc ());
152
170
153
171
if (topLevel )
154
172
{
@@ -294,6 +312,7 @@ public void visit(MethodDeclaration node, int name) throws ConversionException
294
312
me .child ("mthKind" ).setLongValue (node .isConstructor () ? 1 : 0 );
295
313
296
314
setBodyModifiersAndAnnotations (node );
315
+ addJavaDoc (me , node .getJavadoc ());
297
316
processTypeParameters (node .typeParameters ());
298
317
processParameters (node .parameters ());
299
318
@@ -328,6 +347,7 @@ public void visit(FieldDeclaration node, int name) throws ConversionException
328
347
containers .push (field );
329
348
330
349
setBodyModifiersAndAnnotations (node );
350
+ addJavaDoc (field , node .getJavadoc ());
331
351
Node type = typeExpression (node .getType (), "typeExpression" );
332
352
field .setChild ("typeExpression" , addExtraDimensions (type , vdf .getExtraDimensions ()));
333
353
@@ -344,6 +364,7 @@ public void visit(AnnotationTypeMemberDeclaration node, int name) throws Convers
344
364
containers .push (field );
345
365
346
366
setBodyModifiersAndAnnotations (node );
367
+ addJavaDoc (field , node .getJavadoc ());
347
368
field .setChild ("typeExpression" , typeExpression (node .getType (), "typeExpression" ));
348
369
349
370
if (node .getDefault () != null )
0 commit comments