@@ -49,8 +49,11 @@ export class NamespaceDefinition extends AbstractNode {
49
49
this . annotations = annotations || [ ] ;
50
50
}
51
51
52
- directive ( name : string ) : Annotation | undefined {
53
- return getAnnotation ( name , this . annotations ) ;
52
+ annotation (
53
+ name : string ,
54
+ callback ?: ( annotation : Annotation ) => void
55
+ ) : Annotation | undefined {
56
+ return getAnnotation ( name , this . annotations , callback ) ;
54
57
}
55
58
56
59
public accept ( context : Context , visitor : Visitor ) : void {
@@ -82,8 +85,11 @@ export class ImportDefinition extends AbstractNode {
82
85
this . annotations = annotations || [ ] ;
83
86
}
84
87
85
- directive ( name : string ) : Annotation | undefined {
86
- return getAnnotation ( name , this . annotations ) ;
88
+ annotation (
89
+ name : string ,
90
+ callback ?: ( annotation : Annotation ) => void
91
+ ) : Annotation | undefined {
92
+ return getAnnotation ( name , this . annotations , callback ) ;
87
93
}
88
94
89
95
public accept ( context : Context , visitor : Visitor ) : void {
@@ -115,8 +121,11 @@ export class TypeDefinition extends AbstractNode {
115
121
this . fields = fields ;
116
122
}
117
123
118
- annotation ( name : string ) : Annotation | undefined {
119
- return getAnnotation ( name , this . annotations ) ;
124
+ annotation (
125
+ name : string ,
126
+ callback ?: ( annotation : Annotation ) => void
127
+ ) : Annotation | undefined {
128
+ return getAnnotation ( name , this . annotations , callback ) ;
120
129
}
121
130
122
131
public accept ( context : Context , visitor : Visitor ) : void {
@@ -183,8 +192,11 @@ export class OperationDefinition extends AbstractNode {
183
192
return mp ;
184
193
}
185
194
186
- annotaton ( name : string ) : Annotation | undefined {
187
- return getAnnotation ( name , this . annotations ) ;
195
+ annotation (
196
+ name : string ,
197
+ callback ?: ( annotation : Annotation ) => void
198
+ ) : Annotation | undefined {
199
+ return getAnnotation ( name , this . annotations , callback ) ;
188
200
}
189
201
190
202
public accept ( context : Context , visitor : Visitor ) : void {
@@ -230,8 +242,11 @@ export abstract class ValuedDefinition extends AbstractNode {
230
242
this . annotations = annotations ;
231
243
}
232
244
233
- directive ( name : string ) : Annotation | undefined {
234
- return getAnnotation ( name , this . annotations ) ;
245
+ annotation (
246
+ name : string ,
247
+ callback ?: ( annotation : Annotation ) => void
248
+ ) : Annotation | undefined {
249
+ return getAnnotation ( name , this . annotations , callback ) ;
235
250
}
236
251
}
237
252
@@ -300,8 +315,11 @@ export class InterfaceDefinition extends AbstractNode implements Definition {
300
315
this . annotations = annotations || [ ] ;
301
316
}
302
317
303
- directive ( name : string ) : Annotation | undefined {
304
- return getAnnotation ( name , this . annotations ) ;
318
+ annotation (
319
+ name : string ,
320
+ callback ?: ( annotation : Annotation ) => void
321
+ ) : Annotation | undefined {
322
+ return getAnnotation ( name , this . annotations , callback ) ;
305
323
}
306
324
307
325
public accept ( context : Context , visitor : Visitor ) : void {
@@ -340,8 +358,11 @@ export class RoleDefinition extends AbstractNode implements Definition {
340
358
this . annotations = annotations || [ ] ;
341
359
}
342
360
343
- directive ( name : string ) : Annotation | undefined {
344
- return getAnnotation ( name , this . annotations ) ;
361
+ annotation (
362
+ name : string ,
363
+ callback ?: ( annotation : Annotation ) => void
364
+ ) : Annotation | undefined {
365
+ return getAnnotation ( name , this . annotations , callback ) ;
345
366
}
346
367
347
368
public accept ( context : Context , visitor : Visitor ) : void {
@@ -380,8 +401,11 @@ export class UnionDefinition extends AbstractNode implements Definition {
380
401
this . types = types ;
381
402
}
382
403
383
- directive ( name : string ) : Annotation | undefined {
384
- return getAnnotation ( name , this . annotations ) ;
404
+ annotation (
405
+ name : string ,
406
+ callback ?: ( annotation : Annotation ) => void
407
+ ) : Annotation | undefined {
408
+ return getAnnotation ( name , this . annotations , callback ) ;
385
409
}
386
410
387
411
public accept ( context : Context , visitor : Visitor ) : void {
@@ -410,8 +434,11 @@ export class EnumDefinition extends AbstractNode implements Definition {
410
434
this . values = values ;
411
435
}
412
436
413
- directive ( name : string ) : Annotation | undefined {
414
- return getAnnotation ( name , this . annotations ) ;
437
+ annotation (
438
+ name : string ,
439
+ callback ?: ( annotation : Annotation ) => void
440
+ ) : Annotation | undefined {
441
+ return getAnnotation ( name , this . annotations , callback ) ;
415
442
}
416
443
417
444
public accept ( context : Context , visitor : Visitor ) : void {
@@ -452,8 +479,11 @@ export class EnumValueDefinition extends AbstractNode implements Definition {
452
479
this . annotations = annotations ;
453
480
}
454
481
455
- directive ( name : string ) : Annotation | undefined {
456
- return getAnnotation ( name , this . annotations ) ;
482
+ annotation (
483
+ name : string ,
484
+ callback ?: ( annotation : Annotation ) => void
485
+ ) : Annotation | undefined {
486
+ return getAnnotation ( name , this . annotations , callback ) ;
457
487
}
458
488
459
489
public accept ( context : Context , visitor : Visitor ) : void {
@@ -533,13 +563,17 @@ function visitAnnotations(
533
563
534
564
function getAnnotation (
535
565
name : string ,
536
- annotations ?: Annotation [ ]
566
+ annotations ?: Annotation [ ] ,
567
+ callback ?: ( annotation : Annotation ) => void
537
568
) : Annotation | undefined {
538
569
if ( annotations == undefined ) {
539
570
return undefined ;
540
571
}
541
572
for ( let a of annotations ! ) {
542
573
if ( a . name . value === name ) {
574
+ if ( callback != undefined ) {
575
+ callback ( a ) ;
576
+ }
543
577
return a ;
544
578
}
545
579
}
0 commit comments