@@ -607,10 +607,7 @@ class Library extends ModelElement {
607
607
elements..removeWhere (isPrivate);
608
608
_variables = elements
609
609
.map ((e) => new TopLevelVariable (e, this ))
610
- .toList (growable: false );
611
-
612
- // XXX working around a VM SDK issue. Once fixed, you can chain the sort()
613
- if (_variables.isNotEmpty) _variables.sort (byName);
610
+ .toList (growable: false )..sort (byName);
614
611
615
612
return _variables;
616
613
}
@@ -619,22 +616,15 @@ class Library extends ModelElement {
619
616
620
617
/// All variables ("properties") except constants.
621
618
List <TopLevelVariable > get properties {
622
- List temp =
623
- _getVariables ().where ((v) => ! v.isConst).toList (growable: false );
624
- // XXX working around a VM SDK issue. Once fixed, you can chain the sort()
625
- if (temp.isNotEmpty) temp.sort (byName);
626
- return temp;
619
+ return _getVariables ().where ((v) => ! v.isConst).toList (growable: false )
620
+ ..sort (byName);
627
621
}
628
622
629
623
bool get hasConstants => _getVariables ().any ((v) => v.isConst);
630
624
631
625
List <TopLevelVariable > get constants {
632
- List temp = _getVariables ().where ((v) => v.isConst).toList (growable: false );
633
-
634
- // XXX working around a VM SDK issue. Once fixed, you can chain the sort()
635
- if (temp.isNotEmpty) temp.sort (byName);
636
-
637
- return temp;
626
+ return _getVariables ().where ((v) => v.isConst).toList (growable: false )
627
+ ..sort (byName);
638
628
}
639
629
640
630
bool get hasEnums => enums.isNotEmpty;
@@ -648,10 +638,7 @@ class Library extends ModelElement {
648
638
_enums = enumClasses
649
639
.where (isPublic)
650
640
.map ((e) => new Enum (e, this ))
651
- .toList (growable: false );
652
-
653
- // XXX working around a VM SDK issue. Once fixed, you can chain the sort()
654
- if (_enums.isNotEmpty) _enums.sort (byName);
641
+ .toList (growable: false )..sort (byName);
655
642
656
643
return _enums;
657
644
}
@@ -674,11 +661,9 @@ class Library extends ModelElement {
674
661
elements.addAll (_exportedNamespace
675
662
.where ((element) => element is FunctionTypeAliasElement ));
676
663
elements..removeWhere (isPrivate);
677
- _typeDefs =
678
- elements.map ((e) => new Typedef (e, this )).toList (growable: false );
679
-
680
- // XXX working around a VM SDK issue. Once fixed, you can chain the sort()
681
- if (_typeDefs.isNotEmpty) _typeDefs.sort (byName);
664
+ _typeDefs = elements
665
+ .map ((e) => new Typedef (e, this ))
666
+ .toList (growable: false )..sort (byName);
682
667
683
668
return _typeDefs;
684
669
}
@@ -699,10 +684,7 @@ class Library extends ModelElement {
699
684
elements..removeWhere (isPrivate);
700
685
_functions = elements.map ((e) {
701
686
return new ModelFunction (e, this );
702
- }).toList (growable: false );
703
-
704
- // XXX working around a VM SDK issue. Once fixed, you can chain the sort()
705
- if (_functions.isNotEmpty) _functions.sort (byName);
687
+ }).toList (growable: false )..sort (byName);
706
688
707
689
return _functions;
708
690
}
@@ -727,10 +709,7 @@ class Library extends ModelElement {
727
709
_classes = types
728
710
.where (isPublic)
729
711
.map ((e) => new Class (e, this ))
730
- .toList (growable: false );
731
-
732
- // XXX working around a VM SDK issue. Once fixed, you can chain the sort()
733
- if (_classes.isNotEmpty) _classes.sort (byName);
712
+ .toList (growable: false )..sort (byName);
734
713
735
714
return _classes;
736
715
}
@@ -748,13 +727,9 @@ class Library extends ModelElement {
748
727
bool get hasExceptions => _allClasses.any ((c) => c.isErrorOrException);
749
728
750
729
List <Class > get exceptions {
751
- List temp =
752
- _allClasses.where ((c) => c.isErrorOrException).toList (growable: false );
753
-
754
- // XXX working around a VM SDK issue. Once fixed, you can chain the sort()
755
- if (temp.isNotEmpty) temp.sort (byName);
756
-
757
- return temp;
730
+ return _allClasses
731
+ .where ((c) => c.isErrorOrException)
732
+ .toList (growable: false )..sort (byName);
758
733
}
759
734
760
735
@override
@@ -891,10 +866,7 @@ class Class extends ModelElement implements EnclosedElement {
891
866
_fields = _cls.fields
892
867
.where (isPublic)
893
868
.map ((e) => new Field (e, library))
894
- .toList (growable: false );
895
-
896
- // XXX working around a VM SDK issue. Once fixed, you can chain the sort()
897
- if (_fields.isNotEmpty) _fields.sort (byName);
869
+ .toList (growable: false )..sort (byName);
898
870
899
871
return _fields;
900
872
}
@@ -904,10 +876,7 @@ class Class extends ModelElement implements EnclosedElement {
904
876
_staticFields = _allFields
905
877
.where ((f) => f.isStatic)
906
878
.where ((f) => ! f.isConst)
907
- .toList (growable: false );
908
-
909
- // XXX working around a VM SDK issue. Once fixed, you can chain the sort()
910
- if (_staticFields.isNotEmpty) _staticFields.sort (byName);
879
+ .toList (growable: false )..sort (byName);
911
880
912
881
return _staticFields;
913
882
}
@@ -916,21 +885,17 @@ class Class extends ModelElement implements EnclosedElement {
916
885
917
886
List <Field > get instanceProperties {
918
887
if (_instanceFields != null ) return _instanceFields;
919
- _instanceFields =
920
- _allFields.where ((f) => ! f.isStatic).toList (growable: false );
921
-
922
- // XXX working around a VM SDK issue. Once fixed, you can chain the sort()
923
- if (_instanceFields.isNotEmpty) _instanceFields.sort (byName);
888
+ _instanceFields = _allFields
889
+ .where ((f) => ! f.isStatic)
890
+ .toList (growable: false )..sort (byName);
924
891
925
892
return _instanceFields;
926
893
}
927
894
928
895
List <Field > get constants {
929
896
if (_constants != null ) return _constants;
930
- _constants = _allFields.where ((f) => f.isConst).toList (growable: false );
931
-
932
- // XXX working around a VM SDK issue. Once fixed, you can chain the sort()
933
- if (_constants.isNotEmpty) _constants.sort (byName);
897
+ _constants = _allFields.where ((f) => f.isConst).toList (growable: false )
898
+ ..sort (byName);
934
899
935
900
return _constants;
936
901
}
@@ -944,10 +909,7 @@ class Class extends ModelElement implements EnclosedElement {
944
909
945
910
_constructors = _cls.constructors.where (isPublic).map ((e) {
946
911
return new Constructor (e, library);
947
- }).toList (growable: true );
948
-
949
- // XXX working around a VM SDK issue. Once fixed, you can chain the sort()
950
- if (_constructors.isNotEmpty) _constructors.sort (byName);
912
+ }).toList (growable: true )..sort (byName);
951
913
952
914
return _constructors;
953
915
}
@@ -963,21 +925,16 @@ class Class extends ModelElement implements EnclosedElement {
963
925
} else {
964
926
return new Operator (e, library);
965
927
}
966
- }).toList (growable: false );
967
-
968
- // XXX working around a VM SDK issue. Once fixed, you can chain the sort()
969
- if (_allMethods.isNotEmpty) _allMethods.sort (byName);
928
+ }).toList (growable: false )..sort (byName);
970
929
971
930
return _allMethods;
972
931
}
973
932
974
933
List <Operator > get operators {
975
934
if (_operators != null ) return _operators;
976
935
977
- _operators = _methods.where ((m) => m.isOperator).toList (growable: false );
978
-
979
- // XXX working around a VM SDK issue. Once fixed, you can chain the sort()
980
- if (_operators.isNotEmpty) _operators.sort (byName);
936
+ _operators = _methods.where ((m) => m.isOperator).toList (growable: false )
937
+ ..sort (byName);
981
938
982
939
return _operators;
983
940
}
@@ -997,10 +954,8 @@ class Class extends ModelElement implements EnclosedElement {
997
954
List <Method > get staticMethods {
998
955
if (_staticMethods != null ) return _staticMethods;
999
956
1000
- _staticMethods = _methods.where ((m) => m.isStatic).toList (growable: false );
1001
-
1002
- // XXX working around a VM SDK issue. Once fixed, you can chain the sort()
1003
- if (_staticMethods.isNotEmpty) _staticMethods.sort (byName);
957
+ _staticMethods = _methods.where ((m) => m.isStatic).toList (growable: false )
958
+ ..sort (byName);
1004
959
1005
960
return _staticMethods;
1006
961
}
@@ -1012,10 +967,7 @@ class Class extends ModelElement implements EnclosedElement {
1012
967
1013
968
_instanceMethods = _methods
1014
969
.where ((m) => ! m.isStatic && ! m.isOperator)
1015
- .toList (growable: false );
1016
-
1017
- // XXX working around a VM SDK issue. Once fixed, you can chain the sort()
1018
- if (_instanceMethods.isNotEmpty) _instanceMethods.sort (byName);
970
+ .toList (growable: false )..sort (byName);
1019
971
1020
972
return _instanceMethods;
1021
973
}
@@ -1260,10 +1212,7 @@ class Enum extends Class {
1260
1212
.where (isPublic)
1261
1213
.where ((f) => f.isConst)
1262
1214
.map ((field) => new EnumField .forConstant (index++ , field, library))
1263
- .toList (growable: false );
1264
-
1265
- // XXX working around a VM SDK issue. Once fixed, you can chain the sort()
1266
- if (_constants.isNotEmpty) _constants.sort (byName);
1215
+ .toList (growable: false )..sort (byName);
1267
1216
1268
1217
return _constants;
1269
1218
}
0 commit comments