@@ -325,53 +325,52 @@ class AnnotationExtractor {
325
325
return ;
326
326
}
327
327
328
- // Default to using the first acceptable annotation- not sure if
329
- // more than one should ever occur.
330
- var sourceAnnotation = acceptableAnnotations.first;
331
-
332
- // Clone the annotation so we don't modify the one in the persistent AST.
333
- var index = type.annotations.indexOf (sourceAnnotation);
334
- var annotation = new AstCloner ().visitAnnotation (sourceAnnotation);
335
- ResolutionCopier .copyResolutionData (sourceAnnotation, annotation);
336
- type.annotations[index] = annotation;
337
-
338
- var mapArg = annotation.arguments.arguments.firstWhere (
339
- (arg) => (arg is NamedExpression ) && (arg.name.label.name == 'map' ),
340
- orElse: () => null );
341
-
342
- // If we don't have a 'map' parameter yet, add one.
343
- if (mapArg == null ) {
344
- var map = new MapLiteral (null , null , null , [], null );
345
- var label = new Label (new SimpleIdentifier (
346
- new _GeneratedToken (TokenType .STRING , 'map' )),
347
- new _GeneratedToken (TokenType .COLON , ':' ));
348
- mapArg = new NamedExpression (label, map);
349
- annotation.arguments.arguments.add (mapArg);
350
- }
328
+ // Merge attribute annotations in all of the class annotations
329
+ acceptableAnnotations.forEach ((srcAnnotation) {
330
+ // Clone the annotation so we don't modify the one in the persistent AST.
331
+ var index = type.annotations.indexOf (srcAnnotation);
332
+ var annotation = new AstCloner ().visitAnnotation (srcAnnotation);
333
+ ResolutionCopier .copyResolutionData (srcAnnotation, annotation);
334
+ type.annotations[index] = annotation;
335
+
336
+ var mapArg = annotation.arguments.arguments.firstWhere (
337
+ (arg) => (arg is NamedExpression ) && (arg.name.label.name == 'map' ),
338
+ orElse: () => null );
339
+
340
+ // If we don't have a 'map' parameter yet, add one.
341
+ if (mapArg == null ) {
342
+ var map = new MapLiteral (null , null , null , [], null );
343
+ var label = new Label (new SimpleIdentifier (
344
+ new _GeneratedToken (TokenType .STRING , 'map' )),
345
+ new _GeneratedToken (TokenType .COLON , ':' ));
346
+ mapArg = new NamedExpression (label, map);
347
+ annotation.arguments.arguments.add (mapArg);
348
+ }
351
349
352
- var map = mapArg.expression;
353
- if (map is ! MapLiteral ) {
354
- warn ('Expected \' map\' argument of $annotation to be a map literal' ,
355
- type.type);
356
- return ;
357
- }
358
- memberAnnotations.forEach ((memberName, annotation) {
359
- var key = annotation.arguments.arguments.first;
360
- // If the key already exists then it means we have two annotations for
361
- // same member.
362
- if (map.entries.any ((entry) => entry.key.toString () == key.toString ())) {
363
- warn ('Directive $annotation already contains an entry for $key ' ,
364
- type.type);
350
+ var map = mapArg.expression;
351
+ if (map is ! MapLiteral ) {
352
+ warn ('Expected \' map\' argument of $annotation to be a map literal' ,
353
+ type.type);
365
354
return ;
366
355
}
356
+ memberAnnotations.forEach ((memberName, annotation) {
357
+ var key = annotation.arguments.arguments.first;
358
+ // If the key already exists then it means we have two annotations for
359
+ // same member.
360
+ if (map.entries.any ((entry) => entry.key.toString () == key.toString ())) {
361
+ warn ('Directive $annotation already contains an entry for $key ' ,
362
+ type.type);
363
+ return ;
364
+ }
367
365
368
- var typeName = annotation.element.enclosingElement.name;
369
- var value = '${_annotationToMapping [typeName ]}$memberName ' ;
370
- var entry = new MapLiteralEntry (
371
- key,
372
- new _GeneratedToken (TokenType .COLON , ':' ),
373
- new SimpleStringLiteral (stringToken (value), value));
374
- map.entries.add (entry);
366
+ var typeName = annotation.element.enclosingElement.name;
367
+ var value = '${_annotationToMapping [typeName ]}$memberName ' ;
368
+ var entry = new MapLiteralEntry (
369
+ key,
370
+ new _GeneratedToken (TokenType .COLON , ':' ),
371
+ new SimpleStringLiteral (stringToken (value), value));
372
+ map.entries.add (entry);
373
+ });
375
374
});
376
375
}
377
376
0 commit comments