@@ -83,7 +83,21 @@ serializeLocation(const Location &Loc,
83
83
return LocationObj;
84
84
}
85
85
86
- static json::Value serializeComment (const CommentInfo &I) {
86
+ static void insertComment (Object &Description, json::Value &Comment,
87
+ std::string Key) {
88
+ auto *CommentArray = Description.getArray (Key);
89
+ if (!CommentArray) {
90
+ auto CommentsArray = json::Array ();
91
+ CommentsArray.push_back (Comment);
92
+ Description[Key] = std::move (CommentsArray);
93
+ Description[" Has" + Key] = true ;
94
+ } else {
95
+ CommentArray->push_back (Comment);
96
+ Description[Key] = std::move (*CommentArray);
97
+ }
98
+ }
99
+
100
+ static Object serializeComment (const CommentInfo &I, Object &Description) {
87
101
// taken from PR #142273
88
102
Object Obj = Object ();
89
103
@@ -94,7 +108,7 @@ static json::Value serializeComment(const CommentInfo &I) {
94
108
auto &CARef = *ChildArr.getAsArray ();
95
109
CARef.reserve (I.Children .size ());
96
110
for (const auto &C : I.Children )
97
- CARef.emplace_back (serializeComment (*C));
111
+ CARef.emplace_back (serializeComment (*C, Description ));
98
112
99
113
switch (I.Kind ) {
100
114
case CommentKind::CK_TextComment: {
@@ -106,6 +120,8 @@ static json::Value serializeComment(const CommentInfo &I) {
106
120
Child.insert ({" Command" , I.Name });
107
121
Child.insert ({" Children" , ChildArr});
108
122
Obj.insert ({commentKindToString (I.Kind ), ChildVal});
123
+ if (I.Name == " brief" )
124
+ insertComment (Description, ChildVal, " BriefComments" );
109
125
return Obj;
110
126
}
111
127
@@ -137,7 +153,10 @@ static json::Value serializeComment(const CommentInfo &I) {
137
153
if (!I.CloseName .empty ())
138
154
Child.insert ({" CloseName" , I.CloseName });
139
155
Child.insert ({" Children" , ChildArr});
140
- Obj.insert ({commentKindToString (I.Kind ), ChildVal});
156
+ if (I.CloseName == " endcode" )
157
+ insertComment (Description, ChildVal, " CodeComments" );
158
+ else if (I.CloseName == " endverbatim" )
159
+ insertComment (Description, ChildVal, " VerbatimComments" );
141
160
return Obj;
142
161
}
143
162
@@ -210,12 +229,17 @@ serializeCommonAttributes(const Info &I, json::Object &Obj,
210
229
}
211
230
212
231
if (!I.Description .empty ()) {
213
- json::Value DescArray = json::Array ();
214
- auto &DescArrayRef = *DescArray.getAsArray ();
215
- DescArrayRef.reserve (I.Description .size ());
216
- for (const auto &Comment : I.Description )
217
- DescArrayRef.push_back (serializeComment (Comment));
218
- Obj[" Description" ] = DescArray;
232
+ Object Description = Object ();
233
+ // Skip straight to the FullComment's children
234
+ auto &Comments = I.Description .at (0 ).Children ;
235
+ for (const auto &CommentInfo : Comments) {
236
+ json::Value Comment = serializeComment (*CommentInfo, Description);
237
+ // Paragraph comments might not be children
238
+ if (auto *ParagraphComment =
239
+ Comment.getAsObject ()->get (" ParagraphComment" ))
240
+ insertComment (Description, *ParagraphComment, " ParagraphComments" );
241
+ }
242
+ Obj[" Description" ] = std::move (Description);
219
243
}
220
244
221
245
// Namespaces aren't SymbolInfos, so they dont have a DefLoc
0 commit comments