Skip to content

Commit ff4e679

Browse files
committed
WIP
1 parent 1997e7d commit ff4e679

File tree

1 file changed

+25
-71
lines changed

1 file changed

+25
-71
lines changed

lib/src/model.dart

Lines changed: 25 additions & 71 deletions
Original file line numberDiff line numberDiff line change
@@ -571,10 +571,7 @@ class Library extends ModelElement {
571571
elements..removeWhere(isPrivate);
572572
_variables = elements
573573
.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);
578575

579576
return _variables;
580577
}
@@ -583,22 +580,15 @@ class Library extends ModelElement {
583580

584581
/// All variables ("properties") except constants.
585582
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);
591585
}
592586

593587
bool get hasConstants => _getVariables().any((v) => v.isConst);
594588

595589
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);
602592
}
603593

604594
bool get hasEnums => enums.isNotEmpty;
@@ -612,10 +602,7 @@ class Library extends ModelElement {
612602
_enums = enumClasses
613603
.where(isPublic)
614604
.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);
619606

620607
return _enums;
621608
}
@@ -686,10 +673,7 @@ class Library extends ModelElement {
686673
_classes = types
687674
.where(isPublic)
688675
.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);
693677

694678
return _classes;
695679
}
@@ -707,13 +691,9 @@ class Library extends ModelElement {
707691
bool get hasExceptions => _allClasses.any((c) => c.isErrorOrException);
708692

709693
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);
717697
}
718698

719699
@override
@@ -846,10 +826,7 @@ class Class extends ModelElement {
846826
_fields = _cls.fields
847827
.where(isPublic)
848828
.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);
853830

854831
return _fields;
855832
}
@@ -859,10 +836,7 @@ class Class extends ModelElement {
859836
_staticFields = _allFields
860837
.where((f) => f.isStatic)
861838
.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);
866840

867841
return _staticFields;
868842
}
@@ -871,21 +845,17 @@ class Class extends ModelElement {
871845

872846
List<Field> get instanceProperties {
873847
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);
879851

880852
return _instanceFields;
881853
}
882854

883855
List<Field> get constants {
884856
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);
889859

890860
return _constants;
891861
}
@@ -899,10 +869,7 @@ class Class extends ModelElement {
899869

900870
_constructors = _cls.constructors.where(isPublic).map((e) {
901871
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);
906873

907874
return _constructors;
908875
}
@@ -918,21 +885,16 @@ class Class extends ModelElement {
918885
} else {
919886
return new Operator(e, library);
920887
}
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);
925889

926890
return _allMethods;
927891
}
928892

929893
List<Operator> get operators {
930894
if (_operators != null) return _operators;
931895

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);
936898

937899
return _operators;
938900
}
@@ -952,10 +914,8 @@ class Class extends ModelElement {
952914
List<Method> get staticMethods {
953915
if (_staticMethods != null) return _staticMethods;
954916

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);
959919

960920
return _staticMethods;
961921
}
@@ -967,10 +927,7 @@ class Class extends ModelElement {
967927

968928
_instanceMethods = _methods
969929
.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);
974931

975932
return _instanceMethods;
976933
}
@@ -1215,10 +1172,7 @@ class Enum extends Class {
12151172
.where(isPublic)
12161173
.where((f) => f.isConst)
12171174
.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);
12221176

12231177
return _constants;
12241178
}

0 commit comments

Comments
 (0)