@@ -238,7 +238,7 @@ Library generateLibrary(dart2js.Dart2JsLibraryMirror library) {
238
238
var result = new Library (library.qualifiedName, _commentToHtml (library),
239
239
_variables (library.variables),
240
240
_methods (library.functions),
241
- _classes (library.classes), _isPrivate (library));
241
+ _classes (library.classes), _isHidden (library));
242
242
logger.fine ('Generated library for ${result .name }' );
243
243
return result;
244
244
}
@@ -269,13 +269,14 @@ bool _isLibraryPrivate(LibraryMirror mirror) {
269
269
/**
270
270
* A declaration is private if itself is private, or the owner is private.
271
271
*/
272
- bool _isPrivate (DeclarationMirror mirror) {
272
+ // Issue(12202) - A declaration is public even if it's owner is private.
273
+ bool _isHidden (DeclarationMirror mirror) {
273
274
if (mirror is LibraryMirror ) {
274
275
return _isLibraryPrivate (mirror);
275
276
} else if (mirror.owner is LibraryMirror ) {
276
277
return (mirror.isPrivate || _isLibraryPrivate (mirror.owner));
277
278
} else {
278
- return (mirror.isPrivate || _isPrivate (mirror.owner));
279
+ return (mirror.isPrivate || _isHidden (mirror.owner));
279
280
}
280
281
}
281
282
@@ -287,9 +288,19 @@ bool _isVisible(Indexable item) {
287
288
* Returns a list of meta annotations assocated with a mirror.
288
289
*/
289
290
List <String > _annotations (DeclarationMirror mirror) {
290
- var annotations = mirror.metadata.where ((e) =>
291
+ var annotationMirrors = mirror.metadata.where ((e) =>
291
292
e is dart2js.Dart2JsConstructedConstantMirror );
292
- return annotations.map ((e) => e.type.qualifiedName).toList ();
293
+ var annotations = [];
294
+ annotationMirrors.forEach ((annotation) {
295
+ var parameterList = annotation.type.variables.values
296
+ .where ((e) => e.isFinal)
297
+ .map ((e) => annotation.getField (e.simpleName).reflectee)
298
+ .where ((e) => e != null )
299
+ .toList ();
300
+ annotations.add (new Annotation (annotation.type.qualifiedName,
301
+ parameterList));
302
+ });
303
+ return annotations;
293
304
}
294
305
295
306
/**
@@ -342,11 +353,11 @@ Map<String, Variable> _variables(Map<String, VariableMirror> mirrorMap) {
342
353
// a filter. Issue(#9590).
343
354
mirrorMap.forEach ((String mirrorName, VariableMirror mirror) {
344
355
_currentMember = mirror;
345
- if (_includePrivate || ! _isPrivate (mirror)) {
356
+ if (_includePrivate || ! _isHidden (mirror)) {
346
357
entityMap[mirror.qualifiedName] = new Variable (mirrorName, mirror.isFinal,
347
358
mirror.isStatic, mirror.isConst, _type (mirror.type),
348
359
_commentToHtml (mirror), _annotations (mirror), mirror.qualifiedName,
349
- _isPrivate (mirror), mirror.owner.qualifiedName);
360
+ _isHidden (mirror), mirror.owner.qualifiedName);
350
361
data[mirrorName] = entityMap[mirror.qualifiedName];
351
362
}
352
363
});
@@ -359,7 +370,7 @@ Map<String, Variable> _variables(Map<String, VariableMirror> mirrorMap) {
359
370
MethodGroup _methods (Map <String , MethodMirror > mirrorMap) {
360
371
var group = new MethodGroup ();
361
372
mirrorMap.forEach ((String mirrorName, MethodMirror mirror) {
362
- if (_includePrivate || ! _isPrivate (mirror)) {
373
+ if (_includePrivate || ! _isHidden (mirror)) {
363
374
group.addMethod (mirror);
364
375
}
365
376
});
@@ -380,7 +391,7 @@ Class _class(ClassMirror mirror) {
380
391
clazz = new Class (mirror.simpleName, superclass, _commentToHtml (mirror),
381
392
interfaces.toList (), _variables (mirror.variables),
382
393
_methods (mirror.methods), _annotations (mirror), _generics (mirror),
383
- mirror.qualifiedName, _isPrivate (mirror), mirror.owner.qualifiedName);
394
+ mirror.qualifiedName, _isHidden (mirror), mirror.owner.qualifiedName);
384
395
entityMap[mirror.qualifiedName] = clazz;
385
396
}
386
397
return clazz;
@@ -646,14 +657,14 @@ class Class extends Indexable {
646
657
'qualifiedname' : qualifiedName,
647
658
'comment' : comment,
648
659
'superclass' : validSuperclass (),
649
- 'implements' : new List . from ( interfaces.where (_isVisible)
650
- .map ((e) => e.qualifiedName)),
651
- 'subclass' : new List . from ( subclasses) ,
660
+ 'implements' : interfaces.where (_isVisible)
661
+ .map ((e) => e.qualifiedName). toList ( ),
662
+ 'subclass' : subclasses,
652
663
'variables' : recurseMap (variables),
653
664
'inheritedvariables' : recurseMap (inheritedVariables),
654
665
'methods' : methods.toMap (),
655
666
'inheritedmethods' : inheritedMethods.toMap (),
656
- 'annotations' : new List . from (annotations ),
667
+ 'annotations' : annotations. map ((a) => a. toMap ()). toList ( ),
657
668
'generics' : recurseMap (generics)
658
669
};
659
670
}
@@ -689,7 +700,7 @@ class ClassGroup {
689
700
entityMap[mirror.qualifiedName] = new Typedef (mirror.simpleName,
690
701
mirror.value.returnType.qualifiedName, _commentToHtml (mirror),
691
702
_generics (mirror), _parameters (mirror.value.parameters),
692
- _annotations (mirror), mirror.qualifiedName, _isPrivate (mirror),
703
+ _annotations (mirror), mirror.qualifiedName, _isHidden (mirror),
693
704
mirror.owner.qualifiedName);
694
705
typedefs[mirror.simpleName] = entityMap[mirror.qualifiedName];
695
706
}
@@ -712,13 +723,13 @@ class ClassGroup {
712
723
}
713
724
714
725
Map toMap () => {
715
- 'abstract' : new List . from ( abstractClasses.values
716
- . where (_isVisible). map ((e) => e.qualifiedName)),
717
- 'class' : new List . from ( regularClasses.values
718
- . where (_isVisible). map ((e) => e.qualifiedName)),
726
+ 'abstract' : abstractClasses.values. where (_isVisible)
727
+ . map ((e) => e.qualifiedName). toList ( ),
728
+ 'class' : regularClasses.values. where (_isVisible)
729
+ . map ((e) => e.qualifiedName). toList ( ),
719
730
'typedef' : recurseMap (typedefs),
720
- 'error' : new List . from ( errors.values
721
- . where (_isVisible). map ((e) => e.qualifiedName))
731
+ 'error' : errors.values. where (_isVisible)
732
+ . map ((e) => e.qualifiedName). toList ( )
722
733
};
723
734
}
724
735
@@ -744,7 +755,7 @@ class Typedef extends Indexable {
744
755
'comment' : comment,
745
756
'return' : returnType,
746
757
'parameters' : recurseMap (parameters),
747
- 'annotations' : new List . from (annotations ),
758
+ 'annotations' : annotations. map ((a) => a. toMap ()). toList ( ),
748
759
'generics' : recurseMap (generics)
749
760
};
750
761
}
@@ -775,7 +786,7 @@ class Variable extends Indexable {
775
786
'static' : isStatic.toString (),
776
787
'constant' : isConst.toString (),
777
788
'type' : new List .filled (1 , type.toMap ()),
778
- 'annotations' : new List . from (annotations )
789
+ 'annotations' : annotations. map ((a) => a. toMap ()). toList ( )
779
790
};
780
791
}
781
792
@@ -825,7 +836,7 @@ class Method extends Indexable {
825
836
'constant' : isConst.toString (),
826
837
'return' : new List .filled (1 , returnType.toMap ()),
827
838
'parameters' : recurseMap (parameters),
828
- 'annotations' : new List . from (annotations )
839
+ 'annotations' : annotations. map ((a) => a. toMap ()). toList ( )
829
840
};
830
841
}
831
842
@@ -844,7 +855,7 @@ class MethodGroup {
844
855
var method = new Method (mirror.simpleName, mirror.isStatic,
845
856
mirror.isAbstract, mirror.isConstConstructor, _type (mirror.returnType),
846
857
_commentToHtml (mirror), _parameters (mirror.parameters),
847
- _annotations (mirror), mirror.qualifiedName, _isPrivate (mirror),
858
+ _annotations (mirror), mirror.qualifiedName, _isHidden (mirror),
848
859
mirror.owner.qualifiedName);
849
860
entityMap[mirror.qualifiedName] = method;
850
861
_currentMember = mirror;
@@ -928,7 +939,7 @@ class Parameter {
928
939
'default' : hasDefaultValue.toString (),
929
940
'type' : new List .filled (1 , type.toMap ()),
930
941
'value' : defaultValue,
931
- 'annotations' : new List . from (annotations )
942
+ 'annotations' : annotations. map ((a) => a. toMap ()). toList ( )
932
943
};
933
944
}
934
945
@@ -985,6 +996,21 @@ class Type {
985
996
986
997
Map toMap () => {
987
998
'outer' : outer,
988
- 'inner' : new List .from (inner.map ((e) => e.toMap ()))
999
+ 'inner' : inner.map ((e) => e.toMap ()).toList ()
1000
+ };
1001
+ }
1002
+
1003
+ /**
1004
+ * Holds the name of the annotation, and its parameters.
1005
+ */
1006
+ class Annotation {
1007
+ String qualifiedName;
1008
+ List <String > parameters;
1009
+
1010
+ Annotation (this .qualifiedName, this .parameters);
1011
+
1012
+ Map toMap () => {
1013
+ 'name' : qualifiedName,
1014
+ 'parameters' : parameters
989
1015
};
990
1016
}
0 commit comments