@@ -342,53 +342,52 @@ class AnnotationExtractor {
342
342
return ;
343
343
}
344
344
345
- // Default to using the first acceptable annotation- not sure if
346
- // more than one should ever occur.
347
- var sourceAnnotation = acceptableAnnotations.first;
348
-
349
- // Clone the annotation so we don't modify the one in the persistent AST.
350
- var index = type.annotations.indexOf (sourceAnnotation);
351
- var annotation = new AstCloner ().visitAnnotation (sourceAnnotation);
352
- ResolutionCopier .copyResolutionData (sourceAnnotation, annotation);
353
- type.annotations[index] = annotation;
354
-
355
- var mapArg = annotation.arguments.arguments.firstWhere ((arg) =>
356
- (arg is NamedExpression ) && (arg.name.label.name == 'map' ),
357
- orElse: () => null );
358
-
359
- // If we don't have a 'map' parameter yet, add one.
360
- if (mapArg == null ) {
361
- var map = new MapLiteral (null , null , null , [], null );
362
- var label = new Label (new SimpleIdentifier (
363
- new _GeneratedToken (TokenType .STRING , 'map' )),
364
- new _GeneratedToken (TokenType .COLON , ':' ));
365
- mapArg = new NamedExpression (label, map);
366
- annotation.arguments.arguments.add (mapArg);
367
- }
345
+ // Merge attribute annotations in all of the class annotations
346
+ acceptableAnnotations.forEach ((srcAnnotation) {
347
+ // Clone the annotation so we don't modify the one in the persistent AST.
348
+ var index = type.annotations.indexOf (srcAnnotation);
349
+ var annotation = new AstCloner ().visitAnnotation (srcAnnotation);
350
+ ResolutionCopier .copyResolutionData (srcAnnotation, annotation);
351
+ type.annotations[index] = annotation;
352
+
353
+ var mapArg = annotation.arguments.arguments.firstWhere (
354
+ (arg) => (arg is NamedExpression ) && (arg.name.label.name == 'map' ),
355
+ orElse: () => null );
356
+
357
+ // If we don't have a 'map' parameter yet, add one.
358
+ if (mapArg == null ) {
359
+ var map = new MapLiteral (null , null , null , [], null );
360
+ var label = new Label (new SimpleIdentifier (
361
+ new _GeneratedToken (TokenType .STRING , 'map' )),
362
+ new _GeneratedToken (TokenType .COLON , ':' ));
363
+ mapArg = new NamedExpression (label, map);
364
+ annotation.arguments.arguments.add (mapArg);
365
+ }
368
366
369
- var map = mapArg.expression;
370
- if (map is ! MapLiteral ) {
371
- warn ('Expected \' map\' argument of $annotation to be a map literal' ,
372
- type.type);
373
- return ;
374
- }
375
- memberAnnotations.forEach ((memberName, annotation) {
376
- var key = annotation.arguments.arguments.first;
377
- // If the key already exists then it means we have two annotations for
378
- // same member.
379
- if (map.entries.any ((entry) => entry.key.toString () == key.toString ())) {
380
- warn ('Directive $annotation already contains an entry for $key ' ,
381
- type.type);
367
+ var map = mapArg.expression;
368
+ if (map is ! MapLiteral ) {
369
+ warn ('Expected \' map\' argument of $annotation to be a map literal' ,
370
+ type.type);
382
371
return ;
383
372
}
373
+ memberAnnotations.forEach ((memberName, annotation) {
374
+ var key = annotation.arguments.arguments.first;
375
+ // If the key already exists then it means we have two annotations for
376
+ // same member.
377
+ if (map.entries.any ((entry) => entry.key.toString () == key.toString ())) {
378
+ warn ('Directive $annotation already contains an entry for $key ' ,
379
+ type.type);
380
+ return ;
381
+ }
384
382
385
- var typeName = annotation.element.enclosingElement.name;
386
- var value = '${_annotationToMapping [typeName ]}$memberName ' ;
387
- var entry = new MapLiteralEntry (
388
- key,
389
- new _GeneratedToken (TokenType .COLON , ':' ),
390
- new SimpleStringLiteral (stringToken (value), value));
391
- map.entries.add (entry);
383
+ var typeName = annotation.element.enclosingElement.name;
384
+ var value = '${_annotationToMapping [typeName ]}$memberName ' ;
385
+ var entry = new MapLiteralEntry (
386
+ key,
387
+ new _GeneratedToken (TokenType .COLON , ':' ),
388
+ new SimpleStringLiteral (stringToken (value), value));
389
+ map.entries.add (entry);
390
+ });
392
391
});
393
392
}
394
393
@@ -439,5 +438,5 @@ class _AnnotationVisitor extends GeneralizingAstVisitor {
439
438
}
440
439
441
440
bool get hasAnnotations =>
442
- ! classAnnotations.isEmpty || ! memberAnnotations.isEmpty ;
441
+ classAnnotations.isNotEmpty || memberAnnotations.isNotEmpty ;
443
442
}
0 commit comments