@@ -607,10 +607,7 @@ class Library extends ModelElement {
607607 elements..removeWhere (isPrivate);
608608 _variables = elements
609609 .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);
614611
615612 return _variables;
616613 }
@@ -619,22 +616,15 @@ class Library extends ModelElement {
619616
620617 /// All variables ("properties") except constants.
621618 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);
627621 }
628622
629623 bool get hasConstants => _getVariables ().any ((v) => v.isConst);
630624
631625 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);
638628 }
639629
640630 bool get hasEnums => enums.isNotEmpty;
@@ -648,10 +638,7 @@ class Library extends ModelElement {
648638 _enums = enumClasses
649639 .where (isPublic)
650640 .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);
655642
656643 return _enums;
657644 }
@@ -674,11 +661,9 @@ class Library extends ModelElement {
674661 elements.addAll (_exportedNamespace
675662 .where ((element) => element is FunctionTypeAliasElement ));
676663 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);
682667
683668 return _typeDefs;
684669 }
@@ -699,10 +684,7 @@ class Library extends ModelElement {
699684 elements..removeWhere (isPrivate);
700685 _functions = elements.map ((e) {
701686 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);
706688
707689 return _functions;
708690 }
@@ -727,10 +709,7 @@ class Library extends ModelElement {
727709 _classes = types
728710 .where (isPublic)
729711 .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);
734713
735714 return _classes;
736715 }
@@ -748,13 +727,9 @@ class Library extends ModelElement {
748727 bool get hasExceptions => _allClasses.any ((c) => c.isErrorOrException);
749728
750729 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);
758733 }
759734
760735 @override
@@ -891,10 +866,7 @@ class Class extends ModelElement implements EnclosedElement {
891866 _fields = _cls.fields
892867 .where (isPublic)
893868 .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);
898870
899871 return _fields;
900872 }
@@ -904,10 +876,7 @@ class Class extends ModelElement implements EnclosedElement {
904876 _staticFields = _allFields
905877 .where ((f) => f.isStatic)
906878 .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);
911880
912881 return _staticFields;
913882 }
@@ -916,21 +885,17 @@ class Class extends ModelElement implements EnclosedElement {
916885
917886 List <Field > get instanceProperties {
918887 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);
924891
925892 return _instanceFields;
926893 }
927894
928895 List <Field > get constants {
929896 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);
934899
935900 return _constants;
936901 }
@@ -944,10 +909,7 @@ class Class extends ModelElement implements EnclosedElement {
944909
945910 _constructors = _cls.constructors.where (isPublic).map ((e) {
946911 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);
951913
952914 return _constructors;
953915 }
@@ -963,21 +925,16 @@ class Class extends ModelElement implements EnclosedElement {
963925 } else {
964926 return new Operator (e, library);
965927 }
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);
970929
971930 return _allMethods;
972931 }
973932
974933 List <Operator > get operators {
975934 if (_operators != null ) return _operators;
976935
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);
981938
982939 return _operators;
983940 }
@@ -997,10 +954,8 @@ class Class extends ModelElement implements EnclosedElement {
997954 List <Method > get staticMethods {
998955 if (_staticMethods != null ) return _staticMethods;
999956
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);
1004959
1005960 return _staticMethods;
1006961 }
@@ -1012,10 +967,7 @@ class Class extends ModelElement implements EnclosedElement {
1012967
1013968 _instanceMethods = _methods
1014969 .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);
1019971
1020972 return _instanceMethods;
1021973 }
@@ -1260,10 +1212,7 @@ class Enum extends Class {
12601212 .where (isPublic)
12611213 .where ((f) => f.isConst)
12621214 .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);
12671216
12681217 return _constants;
12691218 }
0 commit comments