@@ -270,10 +270,7 @@ class AnnotationExtractor {
270
270
return false ;
271
271
}
272
272
// Skip all non-Ng* Attributes.
273
- if (! cls.name.startsWith ('Ng' )) {
274
- return false ;
275
- }
276
- return true ;
273
+ return cls.name.startsWith ('Ng' );
277
274
}).toList ();
278
275
279
276
@@ -335,53 +332,52 @@ class AnnotationExtractor {
335
332
return ;
336
333
}
337
334
338
- // Default to using the first acceptable annotation- not sure if
339
- // more than one should ever occur.
340
- var sourceAnnotation = acceptableAnnotations.first;
341
-
342
- // Clone the annotation so we don't modify the one in the persistent AST.
343
- var index = type.annotations.indexOf (sourceAnnotation);
344
- var annotation = new AstCloner ().visitAnnotation (sourceAnnotation);
345
- ResolutionCopier .copyResolutionData (sourceAnnotation, annotation);
346
- type.annotations[index] = annotation;
347
-
348
- var mapArg = annotation.arguments.arguments.firstWhere ((arg) =>
349
- (arg is NamedExpression ) && (arg.name.label.name == 'map' ),
350
- orElse: () => null );
351
-
352
- // If we don't have a 'map' parameter yet, add one.
353
- if (mapArg == null ) {
354
- var map = new MapLiteral (null , null , null , [], null );
355
- var label = new Label (new SimpleIdentifier (
356
- new _GeneratedToken (TokenType .STRING , 'map' )),
357
- new _GeneratedToken (TokenType .COLON , ':' ));
358
- mapArg = new NamedExpression (label, map);
359
- annotation.arguments.arguments.add (mapArg);
360
- }
335
+ // Merge attribute annotations in all of the class annotations
336
+ acceptableAnnotations.forEach ((srcAnnotation) {
337
+ // Clone the annotation so we don't modify the one in the persistent AST.
338
+ var index = type.annotations.indexOf (srcAnnotation);
339
+ var annotation = new AstCloner ().visitAnnotation (srcAnnotation);
340
+ ResolutionCopier .copyResolutionData (srcAnnotation, annotation);
341
+ type.annotations[index] = annotation;
342
+
343
+ var mapArg = annotation.arguments.arguments.firstWhere (
344
+ (arg) => (arg is NamedExpression ) && (arg.name.label.name == 'map' ),
345
+ orElse: () => null );
346
+
347
+ // If we don't have a 'map' parameter yet, add one.
348
+ if (mapArg == null ) {
349
+ var map = new MapLiteral (null , null , null , [], null );
350
+ var label = new Label (new SimpleIdentifier (
351
+ new _GeneratedToken (TokenType .STRING , 'map' )),
352
+ new _GeneratedToken (TokenType .COLON , ':' ));
353
+ mapArg = new NamedExpression (label, map);
354
+ annotation.arguments.arguments.add (mapArg);
355
+ }
361
356
362
- var map = mapArg.expression;
363
- if (map is ! MapLiteral ) {
364
- warn ('Expected \' map\' argument of $annotation to be a map literal' ,
365
- type.type);
366
- return ;
367
- }
368
- memberAnnotations.forEach ((memberName, annotation) {
369
- var key = annotation.arguments.arguments.first;
370
- // If the key already exists then it means we have two annotations for
371
- // same member.
372
- if (map.entries.any ((entry) => entry.key.toString () == key.toString ())) {
373
- warn ('Directive $annotation already contains an entry for $key ' ,
374
- type.type);
357
+ var map = mapArg.expression;
358
+ if (map is ! MapLiteral ) {
359
+ warn ('Expected \' map\' argument of $annotation to be a map literal' ,
360
+ type.type);
375
361
return ;
376
362
}
363
+ memberAnnotations.forEach ((memberName, annotation) {
364
+ var key = annotation.arguments.arguments.first;
365
+ // If the key already exists then it means we have two annotations for
366
+ // same member.
367
+ if (map.entries.any ((entry) => entry.key.toString () == key.toString ())) {
368
+ warn ('Directive $annotation already contains an entry for $key ' ,
369
+ type.type);
370
+ return ;
371
+ }
377
372
378
- var typeName = annotation.element.enclosingElement.name;
379
- var value = '${_annotationToMapping [typeName ]}$memberName ' ;
380
- var entry = new MapLiteralEntry (
381
- key,
382
- new _GeneratedToken (TokenType .COLON , ':' ),
383
- new SimpleStringLiteral (stringToken (value), value));
384
- map.entries.add (entry);
373
+ var typeName = annotation.element.enclosingElement.name;
374
+ var value = '${_annotationToMapping [typeName ]}$memberName ' ;
375
+ var entry = new MapLiteralEntry (
376
+ key,
377
+ new _GeneratedToken (TokenType .COLON , ':' ),
378
+ new SimpleStringLiteral (stringToken (value), value));
379
+ map.entries.add (entry);
380
+ });
385
381
});
386
382
}
387
383
@@ -430,5 +426,5 @@ class _AnnotationVisitor extends GeneralizingAstVisitor {
430
426
}
431
427
432
428
bool get hasAnnotations =>
433
- ! classAnnotations.isEmpty || ! memberAnnotations.isEmpty ;
429
+ classAnnotations.isNotEmpty || memberAnnotations.isNotEmpty ;
434
430
}
0 commit comments