@@ -363,94 +363,94 @@ function _iterateDocTypes(node, cb) {
363
363
var res ;
364
364
365
365
switch ( true ) {
366
- case node instanceof TypeBuilder . TypeUnion :
367
- // optional: boolean,
368
- // nullable: boolean,
369
- // variable: boolean,
370
- // nonNullable: boolean,
371
- // all: boolean,
372
- // unknown: boolean,
373
- // types: Array.<TypeName|GenericType|FunctionType|RecordType>
374
- res = node . types . map ( function ( subnode ) {
375
- if ( node . collectionNode ) {
376
- subnode . parentElement = node . collectionNode ;
366
+ case node instanceof TypeBuilder . TypeUnion :
367
+ // optional: boolean,
368
+ // nullable: boolean,
369
+ // variable: boolean,
370
+ // nonNullable: boolean,
371
+ // all: boolean,
372
+ // unknown: boolean,
373
+ // types: Array.<TypeName|GenericType|FunctionType|RecordType>
374
+ res = node . types . map ( function ( subnode ) {
375
+ if ( node . collectionNode ) {
376
+ subnode . parentElement = node . collectionNode ;
377
+ }
378
+ return _iterateDocTypes ( subnode , cb ) ;
379
+ } ) || [ ] ;
380
+ if ( node . nullable ) {
381
+ var subnode = { typeName : 'null' , collectionNode : node } ;
382
+ res . concat ( cb ( subnode ) ) ;
377
383
}
378
- return _iterateDocTypes ( subnode , cb ) ;
379
- } ) || [ ] ;
380
- if ( node . nullable ) {
381
- var subnode = { typeName : 'null' , collectionNode : node } ;
382
- res . concat ( cb ( subnode ) ) ;
383
- }
384
- break ;
385
-
386
- case node instanceof TypeBuilder . TypeName :
387
- // name: string
388
- node . typeName = node . name ;
389
- res = cb ( node ) ;
390
- break ;
391
-
392
- case node instanceof TypeBuilder . GenericType :
393
- // genericTypeName: string,
394
- // parameterTypeUnions: Array.<TypeUnion>
395
- node . typeName = node . genericTypeName . type ;
396
- res = cb ( node ) || [ ] ;
397
- if ( node . parameterTypeUnions ) {
398
- // node.parameterTypeUnions.collectionNode = node;
384
+ break ;
385
+
386
+ case node instanceof TypeBuilder . TypeName :
387
+ // name: string
388
+ node . typeName = node . name ;
389
+ res = cb ( node ) ;
390
+ break ;
391
+
392
+ case node instanceof TypeBuilder . GenericType :
393
+ // genericTypeName: string,
394
+ // parameterTypeUnions: Array.<TypeUnion>
395
+ node . typeName = node . genericTypeName . type ;
396
+ res = cb ( node ) || [ ] ;
397
+ if ( node . parameterTypeUnions ) {
398
+ // node.parameterTypeUnions.collectionNode = node;
399
+ res . concat ( node . parameterTypeUnions . map ( function ( subnode ) {
400
+ subnode . parentElement = node ;
401
+ _iterateDocTypes ( subnode , cb ) ;
402
+ } ) ) ;
403
+ }
404
+ break ;
405
+
406
+ case node instanceof TypeBuilder . FunctionType :
407
+ // parameterTypeUnions: Array.<TypeUnion>,
408
+ // returnTypeUnion: TypeUnion|null,
409
+ // isConstructor: boolean,
410
+ // contextTypeUnion: TypeUnion|null
411
+ node . typeName = 'Function' ;
412
+ res = cb ( node ) || [ ] ;
399
413
res . concat ( node . parameterTypeUnions . map ( function ( subnode ) {
400
414
subnode . parentElement = node ;
401
415
_iterateDocTypes ( subnode , cb ) ;
402
416
} ) ) ;
403
- }
404
- break ;
405
-
406
- case node instanceof TypeBuilder . FunctionType :
407
- // parameterTypeUnions: Array.<TypeUnion>,
408
- // returnTypeUnion: TypeUnion|null,
409
- // isConstructor: boolean,
410
- // contextTypeUnion: TypeUnion|null
411
- node . typeName = 'Function' ;
412
- res = cb ( node ) || [ ] ;
413
- res . concat ( node . parameterTypeUnions . map ( function ( subnode ) {
414
- subnode . parentElement = node ;
415
- _iterateDocTypes ( subnode , cb ) ;
416
- } ) ) ;
417
- if ( node . returnTypeUnion ) {
418
- node . returnTypeUnion . collectionNode = node ;
419
- res . concat ( _iterateDocTypes ( node . returnTypeUnion , cb ) ) ;
420
- }
421
- if ( node . contextTypeUnion ) {
422
- node . contextTypeUnion . collectionNode = node ;
423
- res . concat ( _iterateDocTypes ( node . contextTypeUnion , cb ) ) ;
424
- }
425
- break ;
426
-
427
- case node instanceof TypeBuilder . RecordType :
428
- // entries: Array.<RecordEntry>
429
- node . typeName = 'Object' ;
430
- res = cb ( node ) || [ ] ;
431
- if ( node . entries ) {
432
- res . concat ( node . entries . map ( function ( subnode ) {
433
- subnode . parentElement = node ;
434
- _iterateDocTypes ( subnode , cb ) ;
435
- } ) ) ;
436
- }
437
- break ;
438
-
439
- case node instanceof TypeBuilder . RecordType . Entry :
440
- // name: string,
441
- // typeUnion: TypeUnion
442
- node . typeUnion . collectionNode = node ;
443
- res = _iterateDocTypes ( node . typeUnion , cb ) ;
444
- break ;
445
-
446
- case node instanceof TypeBuilder . ModuleName :
447
- node . typeName = node . name ;
448
- node . module = true ;
449
- res = cb ( node ) ;
450
- break ;
451
-
452
- default :
453
- throw new Error ( 'DocType: Unsupported doc node' ) ;
417
+ if ( node . returnTypeUnion ) {
418
+ node . returnTypeUnion . collectionNode = node ;
419
+ res . concat ( _iterateDocTypes ( node . returnTypeUnion , cb ) ) ;
420
+ }
421
+ if ( node . contextTypeUnion ) {
422
+ node . contextTypeUnion . collectionNode = node ;
423
+ res . concat ( _iterateDocTypes ( node . contextTypeUnion , cb ) ) ;
424
+ }
425
+ break ;
426
+
427
+ case node instanceof TypeBuilder . RecordType :
428
+ // entries: Array.<RecordEntry>
429
+ node . typeName = 'Object' ;
430
+ res = cb ( node ) || [ ] ;
431
+ if ( node . entries ) {
432
+ res . concat ( node . entries . map ( function ( subnode ) {
433
+ subnode . parentElement = node ;
434
+ _iterateDocTypes ( subnode , cb ) ;
435
+ } ) ) ;
436
+ }
437
+ break ;
438
+
439
+ case node instanceof TypeBuilder . RecordType . Entry :
440
+ // name: string,
441
+ // typeUnion: TypeUnion
442
+ node . typeUnion . collectionNode = node ;
443
+ res = _iterateDocTypes ( node . typeUnion , cb ) ;
444
+ break ;
445
+
446
+ case node instanceof TypeBuilder . ModuleName :
447
+ node . typeName = node . name ;
448
+ node . module = true ;
449
+ res = cb ( node ) ;
450
+ break ;
451
+
452
+ default :
453
+ throw new Error ( 'DocType: Unsupported doc node' ) ;
454
454
}
455
455
456
456
return res ;
0 commit comments