@@ -169,27 +169,18 @@ fn dump_json_library (library : &Library) -> (json::Value) {
169
169
"examples" : if let Some ( examples) = library. examples ( ) { dump_json_examples ( examples) } else { json:: Value :: Null } ,
170
170
171
171
"categories" : json:: Map :: from_iter ( vec_map! ( library. categories ( ) , category, ( category. identifier_clone ( ) , dump_json_category ( category) ) ) ) ,
172
- "categories_public" : json:: Map :: from_iter ( vec_map! ( library. categories_public ( ) , ( alias, category) ,
173
- ( StdString :: from ( alias) , json! ( {
174
- "library" : json:: Value :: String ( category. library ( ) . identifier_clone ( ) ) ,
175
- "category" : json:: Value :: String ( category. identifier_clone ( ) ) ,
176
- } ) ) ) ) ,
172
+ "categories_public" : json:: Map :: from_iter ( vec_map! ( library. categories_public ( ) , ( alias, entity) ,
173
+ ( StdString :: from ( alias) , dump_json_identifier_perhaps_for_library_entity ( Some ( entity) ) ) ) ) ,
177
174
178
175
"exports" : json:: Map :: from_iter ( vec_map! ( library. exports ( ) , export, ( export. identifier_clone ( ) , dump_json_export ( export) ) ) ) ,
179
176
180
177
"definitions" : json:: Map :: from_iter ( vec_map! ( library. definitions ( ) , definition, ( definition. identifier_clone ( ) , dump_json_definition ( definition) ) ) ) ,
181
- "definitions_public" : json:: Map :: from_iter ( vec_map! ( library. definitions_public ( ) , ( alias, definition) ,
182
- ( StdString :: from ( alias) , json! ( {
183
- "library" : json:: Value :: String ( definition. library ( ) . identifier_clone ( ) ) ,
184
- "definition" : json:: Value :: String ( definition. identifier_clone ( ) ) ,
185
- } ) ) ) ) ,
178
+ "definitions_public" : json:: Map :: from_iter ( vec_map! ( library. definitions_public ( ) , ( alias, entity) ,
179
+ ( StdString :: from ( alias) , dump_json_identifier_perhaps_for_library_entity ( Some ( entity) ) ) ) ) ,
186
180
187
181
"types" : json:: Map :: from_iter ( vec_map! ( library. value_kinds ( ) , value_kind, ( value_kind. identifier_clone ( ) , dump_json_value_kind ( value_kind) ) ) ) ,
188
- "types_public" : json:: Map :: from_iter ( vec_map! ( library. value_kinds_public ( ) , ( alias, value_kind) ,
189
- ( StdString :: from ( alias) , json! ( {
190
- "library" : json:: Value :: String ( value_kind. library ( ) . identifier_clone ( ) ) ,
191
- "type" : json:: Value :: String ( value_kind. identifier_clone ( ) ) ,
192
- } ) ) ) ) ,
182
+ "types_public" : json:: Map :: from_iter ( vec_map! ( library. value_kinds_public ( ) , ( alias, entity) ,
183
+ ( StdString :: from ( alias) , dump_json_identifier_perhaps_for_library_entity ( Some ( entity) ) ) ) ) ,
193
184
194
185
"title" : if let Some ( title) = library. title ( ) { json:: Value :: String ( StdString :: from ( title) ) } else { json:: Value :: Null } ,
195
186
"description" : if let Some ( description) = library. description ( ) { dump_json_description ( description) } else { json:: Value :: Null } ,
@@ -207,19 +198,19 @@ fn dump_json_category (category : &Category) -> (json::Value) {
207
198
208
199
"identifier" : category. identifier_clone ( ) ,
209
200
210
- "super_categories" : dump_json_identifiers_perhaps_for_entities ( category. parents ( ) ) ,
211
- "super_categories_recursive" : dump_json_identifiers_perhaps_for_entities ( category. parents_recursive ( ) ) ,
212
- "sub_categories" : dump_json_identifiers_perhaps_for_entities ( category. children ( ) ) ,
213
- "sub_categories_recursive" : dump_json_identifiers_perhaps_for_entities ( category. children_recursive ( ) ) ,
201
+ "super_categories" : dump_json_identifiers_perhaps_for_library_entities ( category. parents ( ) ) ,
202
+ "super_categories_recursive" : dump_json_identifiers_perhaps_for_library_entities ( category. parents_recursive ( ) ) ,
203
+ "sub_categories" : dump_json_identifiers_perhaps_for_library_entities ( category. children ( ) ) ,
204
+ "sub_categories_recursive" : dump_json_identifiers_perhaps_for_library_entities ( category. children_recursive ( ) ) ,
214
205
215
- "exports" : dump_json_identifiers_perhaps_for_entities ( category. exports ( ) ) ,
216
- "exports_recursive" : dump_json_identifiers_perhaps_for_entities ( category. exports_recursive ( ) ) ,
206
+ "exports" : dump_json_identifiers_perhaps_for_library_entities ( category. exports ( ) ) ,
207
+ "exports_recursive" : dump_json_identifiers_perhaps_for_library_entities ( category. exports_recursive ( ) ) ,
217
208
218
- "types" : dump_json_identifiers_perhaps_for_entities ( category. value_kinds ( ) ) ,
219
- "types_recursive" : dump_json_identifiers_perhaps_for_entities ( category. value_kinds_recursive ( ) ) ,
209
+ "types" : dump_json_identifiers_perhaps_for_library_entities ( category. value_kinds ( ) ) ,
210
+ "types_recursive" : dump_json_identifiers_perhaps_for_library_entities ( category. value_kinds_recursive ( ) ) ,
220
211
221
- "definitions" : dump_json_identifiers_perhaps_for_entities ( category. definitions ( ) ) ,
222
- "definitions_recursive" : dump_json_identifiers_perhaps_for_entities ( category. definitions_recursive ( ) ) ,
212
+ "definitions" : dump_json_identifiers_perhaps_for_library_entities ( category. definitions ( ) ) ,
213
+ "definitions_recursive" : dump_json_identifiers_perhaps_for_library_entities ( category. definitions_recursive ( ) ) ,
223
214
224
215
"description" : if let Some ( description) = category. description ( ) { dump_json_description ( description) } else { json:: Value :: Null } ,
225
216
"links" : if let Some ( links) = category. links ( ) { dump_json_links ( links) } else { json:: Value :: Null } ,
@@ -235,19 +226,19 @@ fn dump_json_export (export : &Export) -> (json::Value) {
235
226
"identifier" : export. identifier_clone ( ) ,
236
227
"features" : if let Some ( features) = export. features ( ) { dump_json_features ( features) } else { json:: Value :: Null } ,
237
228
238
- "super_exports" : dump_json_identifiers_perhaps_for_entities ( export. parents ( ) ) ,
239
- "super_exports_recursive" : dump_json_identifiers_perhaps_for_entities ( export. parents_recursive ( ) ) ,
240
- "sub_exports" : dump_json_identifiers_perhaps_for_entities ( export. children ( ) ) ,
241
- "sub_exports_recursive" : dump_json_identifiers_perhaps_for_entities ( export. children_recursive ( ) ) ,
229
+ "super_exports" : dump_json_identifiers_perhaps_for_library_entities ( export. parents ( ) ) ,
230
+ "super_exports_recursive" : dump_json_identifiers_perhaps_for_library_entities ( export. parents_recursive ( ) ) ,
231
+ "sub_exports" : dump_json_identifiers_perhaps_for_library_entities ( export. children ( ) ) ,
232
+ "sub_exports_recursive" : dump_json_identifiers_perhaps_for_library_entities ( export. children_recursive ( ) ) ,
242
233
243
- "categories" : dump_json_identifiers_perhaps_for_entities ( export. categories ( ) ) ,
244
- "categories_recursive" : dump_json_identifiers_perhaps_for_entities ( export. categories_recursive ( ) ) ,
234
+ "categories" : dump_json_identifiers_perhaps_for_library_entities ( export. categories ( ) ) ,
235
+ "categories_recursive" : dump_json_identifiers_perhaps_for_library_entities ( export. categories_recursive ( ) ) ,
245
236
246
237
"description" : if let Some ( description) = export. description ( ) { dump_json_description ( description) } else { json:: Value :: Null } ,
247
238
"links" : if let Some ( links) = export. links ( ) { dump_json_links ( links) } else { json:: Value :: Null } ,
248
239
249
- "definitions" : dump_json_identifiers_perhaps_for_entities ( export. definitions ( ) ) ,
250
- "definitions_recursive" : dump_json_identifiers_perhaps_for_entities ( export. definitions_recursive ( ) ) ,
240
+ "definitions" : dump_json_identifiers_perhaps_for_library_entities ( export. definitions ( ) ) ,
241
+ "definitions_recursive" : dump_json_identifiers_perhaps_for_library_entities ( export. definitions_recursive ( ) ) ,
251
242
252
243
"descriptor" : dump_json_value ( & export. descriptor_format ( ) ) ,
253
244
@@ -264,34 +255,34 @@ fn dump_json_value_kind (value_kind : &ValueKind) -> (json::Value) {
264
255
"features" : if let Some ( features) = value_kind. features ( ) { dump_json_features ( features) } else { json:: Value :: Null } ,
265
256
"examples" : if let Some ( examples) = value_kind. examples ( ) { dump_json_examples ( examples) } else { json:: Value :: Null } ,
266
257
267
- "super_types" : dump_json_identifiers_perhaps_for_entities ( value_kind. parents ( ) ) ,
268
- "super_types_recursive" : dump_json_identifiers_perhaps_for_entities ( value_kind. parents_recursive ( ) ) ,
269
- "sub_types" : dump_json_identifiers_perhaps_for_entities ( value_kind. children ( ) ) ,
270
- "sub_types_recursive" : dump_json_identifiers_perhaps_for_entities ( value_kind. children_recursive ( ) ) ,
258
+ "super_types" : dump_json_identifiers_perhaps_for_library_entities ( value_kind. parents ( ) ) ,
259
+ "super_types_recursive" : dump_json_identifiers_perhaps_for_library_entities ( value_kind. parents_recursive ( ) ) ,
260
+ "sub_types" : dump_json_identifiers_perhaps_for_library_entities ( value_kind. children ( ) ) ,
261
+ "sub_types_recursive" : dump_json_identifiers_perhaps_for_library_entities ( value_kind. children_recursive ( ) ) ,
271
262
272
- "categories" : dump_json_identifiers_perhaps_for_entities ( value_kind. categories ( ) ) ,
273
- "categories_recursive" : dump_json_identifiers_perhaps_for_entities ( value_kind. categories_recursive ( ) ) ,
263
+ "categories" : dump_json_identifiers_perhaps_for_library_entities ( value_kind. categories ( ) ) ,
264
+ "categories_recursive" : dump_json_identifiers_perhaps_for_library_entities ( value_kind. categories_recursive ( ) ) ,
274
265
275
266
// FIXME: Conditional compilation does not work in this position!
276
267
// #[ cfg ( feature = "vonuvoli_documentation_variances" ) ]
277
- // "covariant_types" : dump_json_identifiers_perhaps_for_entities (value_kind.covariants ()),
268
+ // "covariant_types" : dump_json_identifiers_perhaps_for_library_entities (value_kind.covariants ()),
278
269
// #[ cfg ( feature = "vonuvoli_documentation_variances" ) ]
279
- // "covariant_types_recursive" : dump_json_identifiers_perhaps_for_entities (value_kind.covariants_recursive ()),
270
+ // "covariant_types_recursive" : dump_json_identifiers_perhaps_for_library_entities (value_kind.covariants_recursive ()),
280
271
// #[ cfg ( feature = "vonuvoli_documentation_variances" ) ]
281
- // "contravariant_types" : dump_json_identifiers_perhaps_for_entities (value_kind.contravariants ()),
272
+ // "contravariant_types" : dump_json_identifiers_perhaps_for_library_entities (value_kind.contravariants ()),
282
273
// #[ cfg ( feature = "vonuvoli_documentation_variances" ) ]
283
- // "contravariant_types_recursive" : dump_json_identifiers_perhaps_for_entities (value_kind.contravariants_recursive ()),
274
+ // "contravariant_types_recursive" : dump_json_identifiers_perhaps_for_library_entities (value_kind.contravariants_recursive ()),
284
275
285
- "definitions_input" : dump_json_identifiers_perhaps_for_entities ( value_kind. definitions_input ( ) ) ,
286
- "definitions_input_recursive" : dump_json_identifiers_perhaps_for_entities ( value_kind. definitions_input_recursive ( ) ) ,
276
+ "definitions_input" : dump_json_identifiers_perhaps_for_library_entities ( value_kind. definitions_input ( ) ) ,
277
+ "definitions_input_recursive" : dump_json_identifiers_perhaps_for_library_entities ( value_kind. definitions_input_recursive ( ) ) ,
287
278
// FIXME: Conditional compilation does not work in this position!
288
279
// #[ cfg ( feature = "vonuvoli_documentation_variances" ) ]
289
- // "definitions_input_contravariant" : dump_json_identifiers_perhaps_for_entities (value_kind.definitions_input_contravariant_recursive ()),
290
- "definitions_output" : dump_json_identifiers_perhaps_for_entities ( value_kind. definitions_output ( ) ) ,
291
- "definitions_output_recursive" : dump_json_identifiers_perhaps_for_entities ( value_kind. definitions_output_recursive ( ) ) ,
280
+ // "definitions_input_contravariant" : dump_json_identifiers_perhaps_for_library_entities (value_kind.definitions_input_contravariant_recursive ()),
281
+ "definitions_output" : dump_json_identifiers_perhaps_for_library_entities ( value_kind. definitions_output ( ) ) ,
282
+ "definitions_output_recursive" : dump_json_identifiers_perhaps_for_library_entities ( value_kind. definitions_output_recursive ( ) ) ,
292
283
// FIXME: Conditional compilation does not work in this position!
293
284
// #[ cfg ( feature = "vonuvoli_documentation_variances" ) ]
294
- // "definitions_output_covariant" : dump_json_identifiers_perhaps_for_entities (value_kind.definitions_output_covariant_recursive ()),
285
+ // "definitions_output_covariant" : dump_json_identifiers_perhaps_for_library_entities (value_kind.definitions_output_covariant_recursive ()),
295
286
296
287
"description" : if let Some ( description) = value_kind. description ( ) { dump_json_description ( description) } else { json:: Value :: Null } ,
297
288
"links" : if let Some ( links) = value_kind. links ( ) { dump_json_links ( links) } else { json:: Value :: Null } ,
@@ -311,11 +302,11 @@ fn dump_json_definition (definition : &Definition) -> (json::Value) {
311
302
"features" : if let Some ( features) = definition. features ( ) { dump_json_features ( features) } else { json:: Value :: Null } ,
312
303
"examples" : if let Some ( examples) = definition. examples ( ) { dump_json_examples ( examples) } else { json:: Value :: Null } ,
313
304
314
- "categories" : dump_json_identifiers_perhaps_for_entities ( definition. categories ( ) ) ,
315
- "categories_recursive" : dump_json_identifiers_perhaps_for_entities ( definition. categories_recursive ( ) ) ,
305
+ "categories" : dump_json_identifiers_perhaps_for_library_entities ( definition. categories ( ) ) ,
306
+ "categories_recursive" : dump_json_identifiers_perhaps_for_library_entities ( definition. categories_recursive ( ) ) ,
316
307
317
- "exports" : dump_json_identifiers_perhaps_for_entities ( definition. exports ( ) ) ,
318
- "exports_recursive" : dump_json_identifiers_perhaps_for_entities ( definition. exports_recursive ( ) ) ,
308
+ "exports" : dump_json_identifiers_perhaps_for_library_entities ( definition. exports ( ) ) ,
309
+ "exports_recursive" : dump_json_identifiers_perhaps_for_library_entities ( definition. exports_recursive ( ) ) ,
319
310
320
311
"kind" : json:: Value :: String ( StdString :: from ( definition. kind ( ) . identifier ( ) ) ) ,
321
312
@@ -325,7 +316,7 @@ fn dump_json_definition (definition : &Definition) -> (json::Value) {
325
316
"procedure_signature" : if let Some ( procedure_signature) = definition. procedure_signature ( ) { dump_json_procedure_signature ( procedure_signature) } else { json:: Value :: Null } ,
326
317
"syntax_signature" : if let Some ( syntax_signature) = definition. syntax_signature ( ) { dump_json_syntax_signature ( syntax_signature) } else { json:: Value :: Null } ,
327
318
328
- "referenced_types" : dump_json_identifiers_perhaps_for_entities ( definition. referenced_value_kinds ( ) ) ,
319
+ "referenced_types" : dump_json_identifiers_perhaps_for_library_entities ( definition. referenced_value_kinds ( ) ) ,
329
320
330
321
} )
331
322
}
@@ -402,7 +393,7 @@ fn dump_json_syntax_signature_keyword (keyword : &SyntaxSignatureKeyword) -> (js
402
393
json ! ( {
403
394
"kind" : "value" ,
404
395
"identifier" : identifier,
405
- "type" : dump_json_identifier_perhaps_for_entity ( kind. as_ref ( ) . map ( ops:: Deref :: deref) ) ,
396
+ "type" : dump_json_identifier_perhaps_for_library_entity ( kind. as_ref ( ) . map ( ops:: Deref :: deref) ) ,
406
397
} ) ,
407
398
SyntaxSignatureKeyword :: Pattern { patterns, .. } =>
408
399
json ! ( {
@@ -558,6 +549,18 @@ fn dump_json_appendix (library : &Appendix) -> (json::Value) {
558
549
}
559
550
560
551
552
+ #[ cfg_attr ( feature = "vonuvoli_inline" , inline ) ]
553
+ fn dump_json_identifier_perhaps_for_library_entity ( entity : Option < & impl LibraryEntity > ) -> ( json:: Value ) {
554
+ if let Some ( entity) = entity {
555
+ return json ! ( {
556
+ "library" : json:: Value :: String ( entity. library ( ) . identifier_clone ( ) ) ,
557
+ "identifier" : json:: Value :: String ( entity. identifier_clone ( ) ) ,
558
+ } ) ;
559
+ } else {
560
+ return json:: Value :: Null ;
561
+ }
562
+ }
563
+
561
564
#[ cfg_attr ( feature = "vonuvoli_inline" , inline ) ]
562
565
fn dump_json_identifier_perhaps_for_entity ( entity : Option < & impl Entity > ) -> ( json:: Value ) {
563
566
return dump_json_identifier_perhaps ( entity. map ( Entity :: identifier) ) ;
@@ -572,6 +575,17 @@ fn dump_json_identifier_perhaps (identifier : Option<&str>) -> (json::Value) {
572
575
}
573
576
}
574
577
578
+
579
+ #[ cfg_attr ( feature = "vonuvoli_inline" , inline ) ]
580
+ fn dump_json_identifiers_perhaps_for_library_entities < ' a , E : LibraryEntity + ' a > ( entities : impl iter:: Iterator < Item = & ' a E > ) -> ( json:: Value ) {
581
+ let identifiers = vec_map ! ( entities, entity, dump_json_identifier_perhaps_for_library_entity ( Some ( entity) ) ) ;
582
+ if identifiers. is_empty ( ) {
583
+ return json:: Value :: Null ;
584
+ } else {
585
+ return json:: Value :: Array ( identifiers) ;
586
+ }
587
+ }
588
+
575
589
#[ cfg_attr ( feature = "vonuvoli_inline" , inline ) ]
576
590
fn dump_json_identifiers_perhaps_for_entities < ' a , E : Entity + ' a > ( entities : impl iter:: Iterator < Item = & ' a E > ) -> ( json:: Value ) {
577
591
return dump_json_identifiers_perhaps ( entities. map ( Entity :: identifier) ) ;
0 commit comments