@@ -374,7 +374,7 @@ class InheritableAccessor extends Accessor with Inheritable {
374
374
Class parentClass =
375
375
new ModelElement .fromElement (t.element, packageGraph);
376
376
List <Field > possibleFields = [];
377
- possibleFields.addAll (parentClass.allInstanceProperties );
377
+ possibleFields.addAll (parentClass.allInstanceFields );
378
378
possibleFields.addAll (parentClass.staticProperties);
379
379
String fieldName = accessor.name.replaceFirst ('=' , '' );
380
380
Field foundField = possibleFields.firstWhere (
@@ -417,7 +417,7 @@ class Accessor extends ModelElement implements EnclosedElement {
417
417
// enclosingCombo always gets set at accessor creation time, somehow, to
418
418
// avoid this.
419
419
// TODO(jcollins-g): This also doesn't work for private accessors sometimes.
420
- (enclosingElement as Class ).allFields ;
420
+ (enclosingElement as Class ).allInstanceFields ;
421
421
}
422
422
assert (_enclosingCombo != null );
423
423
}
@@ -598,19 +598,14 @@ class Class extends ModelElement
598
598
List <Method > _allMethods;
599
599
List <Operator > _operators;
600
600
List <Operator > _inheritedOperators;
601
- List <Operator > _allOperators;
602
- final Set <Operator > _genPageOperators = new Set ();
603
601
List <Method > _inheritedMethods;
604
602
List <Method > _staticMethods;
605
603
List <Method > _instanceMethods;
606
- List <Method > _allInstanceMethods;
607
- final Set <Method > _genPageMethods = new Set ();
608
604
List <Field > _fields;
609
605
List <Field > _staticFields;
610
606
List <Field > _constants;
611
607
List <Field > _instanceFields;
612
608
List <Field > _inheritedProperties;
613
- List <Field > _allInstanceProperties;
614
609
615
610
Class (ClassElement element, Library library, PackageGraph packageGraph)
616
611
: super (element, library, packageGraph, null ) {
@@ -632,66 +627,25 @@ class Class extends ModelElement
632
627
.toList (growable: false );
633
628
}
634
629
635
- List <Method > get allInstanceMethods {
636
- if (_allInstanceMethods != null ) return _allInstanceMethods;
637
- _allInstanceMethods = []
638
- ..addAll ([]
639
- ..addAll (instanceMethods)
640
- ..sort (byName))
641
- ..addAll ([]
642
- ..addAll (inheritedMethods)
643
- ..sort (byName));
644
- return _allInstanceMethods;
645
- }
630
+ Iterable <Method > get allInstanceMethods => quiverIterables.concat ([instanceMethods, inheritedMethods]);
646
631
647
632
Iterable <Method > get allPublicInstanceMethods =>
648
633
filterNonPublic (allInstanceMethods);
649
634
650
635
bool get allPublicInstanceMethodsInherited =>
651
636
instanceMethods.every ((f) => f.isInherited);
652
637
653
- List <Field > get allInstanceProperties {
654
- if (_allInstanceProperties != null ) return _allInstanceProperties;
638
+ Iterable <Field > get allInstanceFields => quiverIterables.concat ([instanceProperties, inheritedProperties]);
655
639
656
- // TODO best way to make this a fixed length list?
657
- _allInstanceProperties = []
658
- ..addAll ([]
659
- ..addAll (instanceProperties)
660
- ..sort (byName))
661
- ..addAll ([]
662
- ..addAll (inheritedProperties)
663
- ..sort (byName));
664
- return _allInstanceProperties;
665
- }
666
-
667
- Iterable <Accessor > get allAccessors {
668
- return []
669
- ..addAll (allInstanceProperties.expand ((f) {
670
- List <Accessor > getterSetters = [];
671
- if (f.hasGetter) getterSetters.add (f.getter);
672
- if (f.hasSetter) getterSetters.add (f.setter);
673
- return getterSetters;
674
- }))
675
- ..addAll (constants.map <Accessor >((c) => c.getter));
676
- }
640
+ Iterable <Accessor > get allAccessors => quiverIterables.concat ([allInstanceFields.expand ((f) => f.allAccessors), constants.map ((c) => c.getter)]);
677
641
678
642
Iterable <Field > get allPublicInstanceProperties =>
679
- filterNonPublic (allInstanceProperties );
643
+ filterNonPublic (allInstanceFields );
680
644
681
645
bool get allPublicInstancePropertiesInherited =>
682
646
allPublicInstanceProperties.every ((f) => f.isInherited);
683
647
684
- List <Operator > get allOperators {
685
- if (_allOperators != null ) return _allOperators;
686
- _allOperators = []
687
- ..addAll ([]
688
- ..addAll (operators)
689
- ..sort (byName))
690
- ..addAll ([]
691
- ..addAll (inheritedOperators)
692
- ..sort (byName));
693
- return _allOperators;
694
- }
648
+ Iterable <Operator > get allOperators => quiverIterables.concat ([operators, inheritedOperators]);
695
649
696
650
Iterable <Operator > get allPublicOperators => filterNonPublic (allOperators);
697
651
@@ -700,7 +654,7 @@ class Class extends ModelElement
700
654
701
655
List <Field > get constants {
702
656
if (_constants != null ) return _constants;
703
- _constants = allFields .where ((f) => f.isConst).toList (growable: false )
657
+ _constants = _allFields .where ((f) => f.isConst).toList (growable: false )
704
658
..sort (byName);
705
659
706
660
return _constants;
@@ -760,7 +714,7 @@ class Class extends ModelElement
760
714
_allModelElements = new List .from (
761
715
quiverIterables.concat ([
762
716
allInstanceMethods,
763
- allInstanceProperties ,
717
+ allInstanceFields ,
764
718
allAccessors,
765
719
allOperators,
766
720
constants,
@@ -861,7 +815,7 @@ class Class extends ModelElement
861
815
862
816
List <Method > get inheritedMethods {
863
817
if (_inheritedMethods == null ) {
864
- _inheritedMethods = new List <Method >() ;
818
+ _inheritedMethods = < Method > [] ;
865
819
Set <String > methodNames = _methods.map ((m) => m.element.name).toSet ();
866
820
867
821
Set <ExecutableElement > inheritedMethodElements =
@@ -876,7 +830,6 @@ class Class extends ModelElement
876
830
Method m = new ModelElement .from (e, library, packageGraph,
877
831
enclosingClass: this );
878
832
_inheritedMethods.add (m);
879
- _genPageMethods.add (m);
880
833
}
881
834
_inheritedMethods.sort (byName);
882
835
}
@@ -902,7 +855,6 @@ class Class extends ModelElement
902
855
Operator o = new ModelElement .from (e, library, packageGraph,
903
856
enclosingClass: this );
904
857
_inheritedOperators.add (o);
905
- _genPageOperators.add (o);
906
858
}
907
859
_inheritedOperators.sort (byName);
908
860
}
@@ -914,7 +866,7 @@ class Class extends ModelElement
914
866
915
867
List <Field > get inheritedProperties {
916
868
if (_inheritedProperties == null ) {
917
- _inheritedProperties = allFields .where ((f) => f.isInherited).toList ()
869
+ _inheritedProperties = _allFields .where ((f) => f.isInherited).toList ()
918
870
..sort (byName);
919
871
}
920
872
return _inheritedProperties;
@@ -930,16 +882,14 @@ class Class extends ModelElement
930
882
.where ((m) => ! m.isStatic && ! m.isOperator)
931
883
.toList (growable: false )
932
884
..sort (byName);
933
-
934
- _genPageMethods.addAll (_instanceMethods);
935
885
return _instanceMethods;
936
886
}
937
887
938
888
Iterable <Method > get publicInstanceMethods => instanceMethods;
939
889
940
890
List <Field > get instanceProperties {
941
891
if (_instanceFields != null ) return _instanceFields;
942
- _instanceFields = allFields
892
+ _instanceFields = _allFields
943
893
.where ((f) => ! f.isStatic && ! f.isInherited && ! f.isConst)
944
894
.toList (growable: false )
945
895
..sort (byName);
@@ -989,8 +939,6 @@ class Class extends ModelElement
989
939
@override
990
940
String get kind => 'class' ;
991
941
992
- List <Method > get methodsForPages => _genPageMethods.toList (growable: false );
993
-
994
942
List <DefinedElementType > get mixins => _mixins;
995
943
996
944
Iterable <DefinedElementType > get publicMixins => filterNonPublic (mixins);
@@ -1005,30 +953,11 @@ class Class extends ModelElement
1005
953
.cast <Operator >()
1006
954
.toList (growable: false )
1007
955
..sort (byName);
1008
- _genPageOperators.addAll (_operators);
1009
-
1010
956
return _operators;
1011
957
}
1012
958
1013
959
Iterable <Operator > get publicOperators => filterNonPublic (operators);
1014
960
1015
- List <Operator > get operatorsForPages =>
1016
- new UnmodifiableListView (_genPageOperators.toList ());
1017
-
1018
- // TODO: make this method smarter about hierarchies and overrides. Right
1019
- // now, we're creating a flat list. We're not paying attention to where
1020
- // these methods are actually coming from. This might turn out to be a
1021
- // problem if we want to show that info later.
1022
- List <Field > _propertiesForPages;
1023
- List <Field > get propertiesForPages {
1024
- if (_propertiesForPages == null ) {
1025
- _propertiesForPages = []
1026
- ..addAll (allInstanceProperties)
1027
- ..sort (byName);
1028
- }
1029
- return _propertiesForPages;
1030
- }
1031
-
1032
961
List <Method > get staticMethods {
1033
962
if (_staticMethods != null ) return _staticMethods;
1034
963
@@ -1042,9 +971,8 @@ class Class extends ModelElement
1042
971
1043
972
List <Field > get staticProperties {
1044
973
if (_staticFields != null ) return _staticFields;
1045
- _staticFields = allFields
1046
- .where ((f) => f.isStatic)
1047
- .where ((f) => ! f.isConst)
974
+ _staticFields = _allFields
975
+ .where ((f) => f.isStatic && ! f.isConst)
1048
976
.toList (growable: false )
1049
977
..sort (byName);
1050
978
@@ -1124,7 +1052,9 @@ class Class extends ModelElement
1124
1052
return __inheritedElements;
1125
1053
}
1126
1054
1127
- List <Field > get allFields {
1055
+ /// Internal only because subclasses are allowed to override how
1056
+ /// these are mapped to [allInheritedFields] and so forth.
1057
+ List <Field > get _allFields {
1128
1058
if (_fields != null ) return _fields;
1129
1059
_fields = [];
1130
1060
Set <PropertyAccessorElement > inheritedAccessors = new Set ()
@@ -1243,12 +1173,18 @@ class Class extends ModelElement
1243
1173
return _allMethods;
1244
1174
}
1245
1175
1176
+ List <TypeParameter > _typeParameters;
1246
1177
// a stronger hash?
1247
1178
@override
1248
- List <TypeParameter > get typeParameters => _cls.typeParameters.map ((f) {
1179
+ List <TypeParameter > get typeParameters {
1180
+ if (_typeParameters == null ) {
1181
+ _typeParameters = _cls.typeParameters.map ((f) {
1249
1182
var lib = new Library (f.enclosingElement.library, packageGraph);
1250
1183
return new ModelElement .from (f, lib, packageGraph) as TypeParameter ;
1251
1184
}).toList ();
1185
+ }
1186
+ return _typeParameters;
1187
+ }
1252
1188
1253
1189
@override
1254
1190
bool operator == (o) =>
@@ -1594,9 +1530,6 @@ class Enum extends Class {
1594
1530
return _instanceProperties;
1595
1531
}
1596
1532
1597
- @override
1598
- List <Field > get propertiesForPages => allInstanceProperties;
1599
-
1600
1533
@override
1601
1534
String get kind => 'enum' ;
1602
1535
}
@@ -1859,6 +1792,12 @@ class Field extends ModelElement
1859
1792
abstract class GetterSetterCombo implements ModelElement {
1860
1793
Accessor get getter;
1861
1794
1795
+ Iterable <Accessor > get allAccessors sync * {
1796
+ for (Accessor a in [getter, setter]) {
1797
+ if (a != null ) yield a;
1798
+ }
1799
+ }
1800
+
1862
1801
Set <String > get comboFeatures {
1863
1802
Set <String > allFeatures = new Set ();
1864
1803
if (hasExplicitGetter && hasPublicGetter)
0 commit comments