Skip to content

Commit f614435

Browse files
committed
Merge remote-tracking branch 'origin/master' into sl-underscores
2 parents 802c3ef + 6b1d987 commit f614435

File tree

2 files changed

+108
-47
lines changed

2 files changed

+108
-47
lines changed

lib/resource_loader.dart

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -91,9 +91,9 @@ Future<Uint8List> _doLoadOverHttp(final String resourcePath) {
9191
var scriptUri = Platform.script;
9292
var convertedResourcePath = _convertPackageSchemeToPackagesDir(resourcePath);
9393
// strip file name from script uri, append path to resource
94-
var segmentsToResource = scriptUri.pathSegments.sublist(
95-
0, scriptUri.pathSegments.length - 1)
96-
..addAll(p.split(convertedResourcePath));
94+
var segmentsToResource = scriptUri.pathSegments
95+
.sublist(0, scriptUri.pathSegments.length - 1)
96+
..addAll(p.split(convertedResourcePath));
9797
var fullPath = scriptUri.replace(pathSegments: segmentsToResource);
9898

9999
return http.readBytes(fullPath);

lib/src/model.dart

Lines changed: 105 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -296,8 +296,8 @@ abstract class ModelElement implements Comparable {
296296
buf.write(' <span class="parameter-name">${p.name}</span>');
297297
}
298298
buf.write('(');
299-
buf.write(p.modelType.element.linkedParams(
300-
showNames: showNames, showMetadata: showMetadata));
299+
buf.write(p.modelType.element
300+
.linkedParams(showNames: showNames, showMetadata: showMetadata));
301301
buf.write(')');
302302
} else if (p.modelType != null && p.modelType.element != null) {
303303
var mt = p.modelType;
@@ -570,7 +570,10 @@ class Library extends ModelElement {
570570
elements..removeWhere(isPrivate);
571571
_variables = elements
572572
.map((e) => new TopLevelVariable(e, this))
573-
.toList(growable: false)..sort(byName);
573+
.toList(growable: false);
574+
575+
// XXX working around a VM SDK issue. Once fixed, you can chain the sort()
576+
if (_variables.isNotEmpty) _variables.sort(byName);
574577

575578
return _variables;
576579
}
@@ -579,15 +582,22 @@ class Library extends ModelElement {
579582

580583
/// All variables ("properties") except constants.
581584
List<TopLevelVariable> get properties {
582-
return _getVariables().where((v) => !v.isConst).toList(growable: false)
583-
..sort(byName);
585+
List temp =
586+
_getVariables().where((v) => !v.isConst).toList(growable: false);
587+
// XXX working around a VM SDK issue. Once fixed, you can chain the sort()
588+
if (temp.isNotEmpty) temp.sort(byName);
589+
return temp;
584590
}
585591

586592
bool get hasConstants => _getVariables().any((v) => v.isConst);
587593

588594
List<TopLevelVariable> get constants {
589-
return _getVariables().where((v) => v.isConst).toList(growable: false)
590-
..sort(byName);
595+
List temp = _getVariables().where((v) => v.isConst).toList(growable: false);
596+
597+
// XXX working around a VM SDK issue. Once fixed, you can chain the sort()
598+
if (temp.isNotEmpty) temp.sort(byName);
599+
600+
return temp;
591601
}
592602

593603
bool get hasEnums => enums.isNotEmpty;
@@ -601,7 +611,11 @@ class Library extends ModelElement {
601611
_enums = enumClasses
602612
.where(isPublic)
603613
.map((e) => new Enum(e, this))
604-
.toList(growable: false)..sort((a, b) => a.name.compareTo(b.name));
614+
.toList(growable: false);
615+
616+
// XXX working around a VM SDK issue. Once fixed, you can chain the sort()
617+
if (_enums.isNotEmpty) _enums.sort(byName);
618+
605619
return _enums;
606620
}
607621

@@ -623,9 +637,12 @@ class Library extends ModelElement {
623637
elements.addAll(_exportedNamespace
624638
.where((element) => element is FunctionTypeAliasElement));
625639
elements..removeWhere(isPrivate);
626-
_typeDefs = elements
627-
.map((e) => new Typedef(e, this))
628-
.toList(growable: false)..sort(byName);
640+
_typeDefs =
641+
elements.map((e) => new Typedef(e, this)).toList(growable: false);
642+
643+
// XXX working around a VM SDK issue. Once fixed, you can chain the sort()
644+
if (_typeDefs.isNotEmpty) _typeDefs.sort(byName);
645+
629646
return _typeDefs;
630647
}
631648

@@ -645,7 +662,11 @@ class Library extends ModelElement {
645662
elements..removeWhere(isPrivate);
646663
_functions = elements.map((e) {
647664
return new ModelFunction(e, this);
648-
}).toList(growable: false)..sort(byName);
665+
}).toList(growable: false);
666+
667+
// XXX working around a VM SDK issue. Once fixed, you can chain the sort()
668+
if (_functions.isNotEmpty) _functions.sort(byName);
669+
649670
return _functions;
650671
}
651672

@@ -669,14 +690,18 @@ class Library extends ModelElement {
669690
_classes = types
670691
.where(isPublic)
671692
.map((e) => new Class(e, this))
672-
.toList(growable: false)..sort(byName);
693+
.toList(growable: false);
694+
695+
// XXX working around a VM SDK issue. Once fixed, you can chain the sort()
696+
if (_classes.isNotEmpty) _classes.sort(byName);
673697

674698
return _classes;
675699
}
676700

677701
List<Class> get classes {
678-
return _allClasses.where((c) => !c.isErrorOrException).toList(
679-
growable: false);
702+
return _allClasses
703+
.where((c) => !c.isErrorOrException)
704+
.toList(growable: false);
680705
}
681706

682707
List<Class> get allClasses => _allClasses;
@@ -686,8 +711,13 @@ class Library extends ModelElement {
686711
bool get hasExceptions => _allClasses.any((c) => c.isErrorOrException);
687712

688713
List<Class> get exceptions {
689-
return _allClasses.where((c) => c.isErrorOrException).toList(
690-
growable: false)..sort(byName);
714+
List temp =
715+
_allClasses.where((c) => c.isErrorOrException).toList(growable: false);
716+
717+
// XXX working around a VM SDK issue. Once fixed, you can chain the sort()
718+
if (temp.isNotEmpty) temp.sort(byName);
719+
720+
return temp;
691721
}
692722

693723
@override
@@ -768,9 +798,9 @@ class Class extends ModelElement {
768798
}
769799

770800
List<TypeParameter> get _typeParameters => _cls.typeParameters.map((f) {
771-
var lib = new Library(f.enclosingElement.library, package);
772-
return new TypeParameter(f, lib);
773-
}).toList();
801+
var lib = new Library(f.enclosingElement.library, package);
802+
return new TypeParameter(f, lib);
803+
}).toList();
774804

775805
String get kind => 'class';
776806

@@ -820,7 +850,10 @@ class Class extends ModelElement {
820850
_fields = _cls.fields
821851
.where(isPublic)
822852
.map((e) => new Field(e, library))
823-
.toList(growable: false)..sort(byName);
853+
.toList(growable: false);
854+
855+
// XXX working around a VM SDK issue. Once fixed, you can chain the sort()
856+
if (_fields.isNotEmpty) _fields.sort(byName);
824857

825858
return _fields;
826859
}
@@ -830,25 +863,34 @@ class Class extends ModelElement {
830863
_staticFields = _allFields
831864
.where((f) => f.isStatic)
832865
.where((f) => !f.isConst)
833-
.toList(growable: false)..sort(byName);
866+
.toList(growable: false);
867+
868+
// XXX working around a VM SDK issue. Once fixed, you can chain the sort()
869+
if (_staticFields.isNotEmpty) _staticFields.sort(byName);
870+
834871
return _staticFields;
835872
}
836873

837874
bool get hasInstanceProperties => instanceProperties.isNotEmpty;
838875

839876
List<Field> get instanceProperties {
840877
if (_instanceFields != null) return _instanceFields;
841-
_instanceFields = _allFields
842-
.where((f) => !f.isStatic)
843-
.toList(growable: false)..sort(byName);
878+
_instanceFields =
879+
_allFields.where((f) => !f.isStatic).toList(growable: false);
880+
881+
// XXX working around a VM SDK issue. Once fixed, you can chain the sort()
882+
if (_instanceFields.isNotEmpty) _instanceFields.sort(byName);
844883

845884
return _instanceFields;
846885
}
847886

848887
List<Field> get constants {
849888
if (_constants != null) return _constants;
850-
_constants = _allFields.where((f) => f.isConst).toList(growable: false)
851-
..sort((a, b) => a.name.compareTo(b.name));
889+
_constants = _allFields.where((f) => f.isConst).toList(growable: false);
890+
891+
// XXX working around a VM SDK issue. Once fixed, you can chain the sort()
892+
if (_constants.isNotEmpty) _constants.sort(byName);
893+
852894
return _constants;
853895
}
854896

@@ -861,7 +903,10 @@ class Class extends ModelElement {
861903

862904
_constructors = _cls.constructors.where(isPublic).map((e) {
863905
return new Constructor(e, library);
864-
}).toList(growable: true)..sort(byName);
906+
}).toList(growable: true);
907+
908+
// XXX working around a VM SDK issue. Once fixed, you can chain the sort()
909+
if (_constructors.isNotEmpty) _constructors.sort(byName);
865910

866911
return _constructors;
867912
}
@@ -877,16 +922,21 @@ class Class extends ModelElement {
877922
} else {
878923
return new Operator(e, library);
879924
}
880-
}).toList(growable: false)..sort(byName);
925+
}).toList(growable: false);
926+
927+
// XXX working around a VM SDK issue. Once fixed, you can chain the sort()
928+
if (_allMethods.isNotEmpty) _allMethods.sort(byName);
881929

882930
return _allMethods;
883931
}
884932

885933
List<Operator> get operators {
886934
if (_operators != null) return _operators;
887935

888-
_operators = _methods.where((m) => m.isOperator).toList(growable: false)
889-
..sort(byName);
936+
_operators = _methods.where((m) => m.isOperator).toList(growable: false);
937+
938+
// XXX working around a VM SDK issue. Once fixed, you can chain the sort()
939+
if (_operators.isNotEmpty) _operators.sort(byName);
890940

891941
return _operators;
892942
}
@@ -906,8 +956,10 @@ class Class extends ModelElement {
906956
List<Method> get staticMethods {
907957
if (_staticMethods != null) return _staticMethods;
908958

909-
_staticMethods = _methods.where((m) => m.isStatic).toList(growable: false)
910-
..sort(byName);
959+
_staticMethods = _methods.where((m) => m.isStatic).toList(growable: false);
960+
961+
// XXX working around a VM SDK issue. Once fixed, you can chain the sort()
962+
if (_staticMethods.isNotEmpty) _staticMethods.sort(byName);
911963

912964
return _staticMethods;
913965
}
@@ -919,7 +971,10 @@ class Class extends ModelElement {
919971

920972
_instanceMethods = _methods
921973
.where((m) => !m.isStatic && !m.isOperator)
922-
.toList(growable: false)..sort(byName);
974+
.toList(growable: false);
975+
976+
// XXX working around a VM SDK issue. Once fixed, you can chain the sort()
977+
if (_instanceMethods.isNotEmpty) _instanceMethods.sort(byName);
923978

924979
return _instanceMethods;
925980
}
@@ -979,7 +1034,7 @@ class Class extends ModelElement {
9791034
}
9801035
}
9811036

982-
_inheritedMethods..sort(byName);
1037+
_inheritedMethods.sort(byName);
9831038

9841039
return _inheritedMethods;
9851040
}
@@ -1038,7 +1093,7 @@ class Class extends ModelElement {
10381093
_inheritedOperators.add(new Operator.inherited(value, lib));
10391094
}
10401095

1041-
_inheritedOperators..sort(byName);
1096+
_inheritedOperators.sort(byName);
10421097

10431098
return _inheritedOperators;
10441099
}
@@ -1097,7 +1152,7 @@ class Class extends ModelElement {
10971152
}
10981153
}
10991154

1100-
_inheritedProperties..sort(byName);
1155+
_inheritedProperties.sort(byName);
11011156

11021157
return _inheritedProperties;
11031158
}
@@ -1164,14 +1219,18 @@ class Enum extends Class {
11641219
.where(isPublic)
11651220
.where((f) => f.isConst)
11661221
.map((field) => new EnumField.forConstant(index++, field, library))
1167-
.toList(growable: false)..sort(byName);
1222+
.toList(growable: false);
1223+
1224+
// XXX working around a VM SDK issue. Once fixed, you can chain the sort()
1225+
if (_constants.isNotEmpty) _constants.sort(byName);
11681226

11691227
return _constants;
11701228
}
11711229

11721230
@override
11731231
List<EnumField> get instanceProperties {
1174-
return super.instanceProperties
1232+
return super
1233+
.instanceProperties
11751234
.map((Field p) => new EnumField(p.element, p.library))
11761235
.toList(growable: false);
11771236
}
@@ -1664,8 +1723,10 @@ class ElementType {
16641723

16651724
ElementType get _returnType {
16661725
var rt = (_type as FunctionType).returnType;
1667-
return new ElementType(rt, new ModelElement.from(
1668-
rt.element, new Library(_element.library.element, _element.package)));
1726+
return new ElementType(
1727+
rt,
1728+
new ModelElement.from(rt.element,
1729+
new Library(_element.library.element, _element.package)));
16691730
}
16701731

16711732
ModelElement get returnElement {
@@ -1679,9 +1740,9 @@ class ElementType {
16791740

16801741
List<ElementType> get typeArguments =>
16811742
(_type as ParameterizedType).typeArguments.map((f) {
1682-
var lib = new Library(f.element.library, _element.package);
1683-
return new ElementType(f, new ModelElement.from(f.element, lib));
1684-
}).toList();
1743+
var lib = new Library(f.element.library, _element.package);
1744+
return new ElementType(f, new ModelElement.from(f.element, lib));
1745+
}).toList();
16851746

16861747
String get linkedName {
16871748
if (_linkedName != null) return _linkedName;

0 commit comments

Comments
 (0)