@@ -571,10 +571,7 @@ class Library extends ModelElement {
571
571
elements..removeWhere (isPrivate);
572
572
_variables = elements
573
573
.map ((e) => new TopLevelVariable (e, this ))
574
- .toList (growable: false );
575
-
576
- // XXX working around a VM SDK issue. Once fixed, you can chain the sort()
577
- if (_variables.isNotEmpty) _variables.sort (byName);
574
+ .toList (growable: false )..sort (byName);
578
575
579
576
return _variables;
580
577
}
@@ -583,22 +580,15 @@ class Library extends ModelElement {
583
580
584
581
/// All variables ("properties") except constants.
585
582
List <TopLevelVariable > get properties {
586
- List temp =
587
- _getVariables ().where ((v) => ! v.isConst).toList (growable: false );
588
- // XXX working around a VM SDK issue. Once fixed, you can chain the sort()
589
- if (temp.isNotEmpty) temp.sort (byName);
590
- return temp;
583
+ return _getVariables ().where ((v) => ! v.isConst).toList (growable: false )
584
+ ..sort (byName);
591
585
}
592
586
593
587
bool get hasConstants => _getVariables ().any ((v) => v.isConst);
594
588
595
589
List <TopLevelVariable > get constants {
596
- List temp = _getVariables ().where ((v) => v.isConst).toList (growable: false );
597
-
598
- // XXX working around a VM SDK issue. Once fixed, you can chain the sort()
599
- if (temp.isNotEmpty) temp.sort (byName);
600
-
601
- return temp;
590
+ return _getVariables ().where ((v) => v.isConst).toList (growable: false )
591
+ ..sort (byName);
602
592
}
603
593
604
594
bool get hasEnums => enums.isNotEmpty;
@@ -612,10 +602,7 @@ class Library extends ModelElement {
612
602
_enums = enumClasses
613
603
.where (isPublic)
614
604
.map ((e) => new Enum (e, this ))
615
- .toList (growable: false );
616
-
617
- // XXX working around a VM SDK issue. Once fixed, you can chain the sort()
618
- if (_enums.isNotEmpty) _enums.sort (byName);
605
+ .toList (growable: false )..sort (byName);
619
606
620
607
return _enums;
621
608
}
@@ -686,10 +673,7 @@ class Library extends ModelElement {
686
673
_classes = types
687
674
.where (isPublic)
688
675
.map ((e) => new Class (e, this ))
689
- .toList (growable: false );
690
-
691
- // XXX working around a VM SDK issue. Once fixed, you can chain the sort()
692
- if (_classes.isNotEmpty) _classes.sort (byName);
676
+ .toList (growable: false )..sort (byName);
693
677
694
678
return _classes;
695
679
}
@@ -707,13 +691,9 @@ class Library extends ModelElement {
707
691
bool get hasExceptions => _allClasses.any ((c) => c.isErrorOrException);
708
692
709
693
List <Class > get exceptions {
710
- List temp =
711
- _allClasses.where ((c) => c.isErrorOrException).toList (growable: false );
712
-
713
- // XXX working around a VM SDK issue. Once fixed, you can chain the sort()
714
- if (temp.isNotEmpty) temp.sort (byName);
715
-
716
- return temp;
694
+ return _allClasses
695
+ .where ((c) => c.isErrorOrException)
696
+ .toList (growable: false )..sort (byName);
717
697
}
718
698
719
699
@override
@@ -846,10 +826,7 @@ class Class extends ModelElement {
846
826
_fields = _cls.fields
847
827
.where (isPublic)
848
828
.map ((e) => new Field (e, library))
849
- .toList (growable: false );
850
-
851
- // XXX working around a VM SDK issue. Once fixed, you can chain the sort()
852
- if (_fields.isNotEmpty) _fields.sort (byName);
829
+ .toList (growable: false )..sort (byName);
853
830
854
831
return _fields;
855
832
}
@@ -859,10 +836,7 @@ class Class extends ModelElement {
859
836
_staticFields = _allFields
860
837
.where ((f) => f.isStatic)
861
838
.where ((f) => ! f.isConst)
862
- .toList (growable: false );
863
-
864
- // XXX working around a VM SDK issue. Once fixed, you can chain the sort()
865
- if (_staticFields.isNotEmpty) _staticFields.sort (byName);
839
+ .toList (growable: false )..sort (byName);
866
840
867
841
return _staticFields;
868
842
}
@@ -871,21 +845,17 @@ class Class extends ModelElement {
871
845
872
846
List <Field > get instanceProperties {
873
847
if (_instanceFields != null ) return _instanceFields;
874
- _instanceFields =
875
- _allFields.where ((f) => ! f.isStatic).toList (growable: false );
876
-
877
- // XXX working around a VM SDK issue. Once fixed, you can chain the sort()
878
- if (_instanceFields.isNotEmpty) _instanceFields.sort (byName);
848
+ _instanceFields = _allFields
849
+ .where ((f) => ! f.isStatic)
850
+ .toList (growable: false )..sort (byName);
879
851
880
852
return _instanceFields;
881
853
}
882
854
883
855
List <Field > get constants {
884
856
if (_constants != null ) return _constants;
885
- _constants = _allFields.where ((f) => f.isConst).toList (growable: false );
886
-
887
- // XXX working around a VM SDK issue. Once fixed, you can chain the sort()
888
- if (_constants.isNotEmpty) _constants.sort (byName);
857
+ _constants = _allFields.where ((f) => f.isConst).toList (growable: false )
858
+ ..sort (byName);
889
859
890
860
return _constants;
891
861
}
@@ -899,10 +869,7 @@ class Class extends ModelElement {
899
869
900
870
_constructors = _cls.constructors.where (isPublic).map ((e) {
901
871
return new Constructor (e, library);
902
- }).toList (growable: true );
903
-
904
- // XXX working around a VM SDK issue. Once fixed, you can chain the sort()
905
- if (_constructors.isNotEmpty) _constructors.sort (byName);
872
+ }).toList (growable: true )..sort (byName);
906
873
907
874
return _constructors;
908
875
}
@@ -918,21 +885,16 @@ class Class extends ModelElement {
918
885
} else {
919
886
return new Operator (e, library);
920
887
}
921
- }).toList (growable: false );
922
-
923
- // XXX working around a VM SDK issue. Once fixed, you can chain the sort()
924
- if (_allMethods.isNotEmpty) _allMethods.sort (byName);
888
+ }).toList (growable: false )..sort (byName);
925
889
926
890
return _allMethods;
927
891
}
928
892
929
893
List <Operator > get operators {
930
894
if (_operators != null ) return _operators;
931
895
932
- _operators = _methods.where ((m) => m.isOperator).toList (growable: false );
933
-
934
- // XXX working around a VM SDK issue. Once fixed, you can chain the sort()
935
- if (_operators.isNotEmpty) _operators.sort (byName);
896
+ _operators = _methods.where ((m) => m.isOperator).toList (growable: false )
897
+ ..sort (byName);
936
898
937
899
return _operators;
938
900
}
@@ -952,10 +914,8 @@ class Class extends ModelElement {
952
914
List <Method > get staticMethods {
953
915
if (_staticMethods != null ) return _staticMethods;
954
916
955
- _staticMethods = _methods.where ((m) => m.isStatic).toList (growable: false );
956
-
957
- // XXX working around a VM SDK issue. Once fixed, you can chain the sort()
958
- if (_staticMethods.isNotEmpty) _staticMethods.sort (byName);
917
+ _staticMethods = _methods.where ((m) => m.isStatic).toList (growable: false )
918
+ ..sort (byName);
959
919
960
920
return _staticMethods;
961
921
}
@@ -967,10 +927,7 @@ class Class extends ModelElement {
967
927
968
928
_instanceMethods = _methods
969
929
.where ((m) => ! m.isStatic && ! m.isOperator)
970
- .toList (growable: false );
971
-
972
- // XXX working around a VM SDK issue. Once fixed, you can chain the sort()
973
- if (_instanceMethods.isNotEmpty) _instanceMethods.sort (byName);
930
+ .toList (growable: false )..sort (byName);
974
931
975
932
return _instanceMethods;
976
933
}
@@ -1215,10 +1172,7 @@ class Enum extends Class {
1215
1172
.where (isPublic)
1216
1173
.where ((f) => f.isConst)
1217
1174
.map ((field) => new EnumField .forConstant (index++ , field, library))
1218
- .toList (growable: false );
1219
-
1220
- // XXX working around a VM SDK issue. Once fixed, you can chain the sort()
1221
- if (_constants.isNotEmpty) _constants.sort (byName);
1175
+ .toList (growable: false )..sort (byName);
1222
1176
1223
1177
return _constants;
1224
1178
}
0 commit comments