Skip to content

Commit 6b1d987

Browse files
committed
work-around issue in latest bleeding edge build
Closes #765 Squashed commit of the following: commit e90be03 Author: Seth Ladd <[email protected]> Date: Tue Aug 4 17:22:30 2015 -0700 rollback resource loader commit feb560b Author: Seth Ladd <[email protected]> Date: Tue Aug 4 17:17:02 2015 -0700 work-around issue in latest bleeding edge build
1 parent 6e3c1dd commit 6b1d987

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
@@ -292,8 +292,8 @@ abstract class ModelElement implements Comparable {
292292
buf.write(' <span class="parameter-name">${p.name}</span>');
293293
}
294294
buf.write('(');
295-
buf.write(p.modelType.element.linkedParams(
296-
showNames: showNames, showMetadata: showMetadata));
295+
buf.write(p.modelType.element
296+
.linkedParams(showNames: showNames, showMetadata: showMetadata));
297297
buf.write(')');
298298
} else if (p.modelType != null && p.modelType.element != null) {
299299
var mt = p.modelType;
@@ -553,7 +553,10 @@ class Library extends ModelElement {
553553
elements..removeWhere(isPrivate);
554554
_variables = elements
555555
.map((e) => new TopLevelVariable(e, this))
556-
.toList(growable: false)..sort(byName);
556+
.toList(growable: false);
557+
558+
// XXX working around a VM SDK issue. Once fixed, you can chain the sort()
559+
if (_variables.isNotEmpty) _variables.sort(byName);
557560

558561
return _variables;
559562
}
@@ -562,15 +565,22 @@ class Library extends ModelElement {
562565

563566
/// All variables ("properties") except constants.
564567
List<TopLevelVariable> get properties {
565-
return _getVariables().where((v) => !v.isConst).toList(growable: false)
566-
..sort(byName);
568+
List temp =
569+
_getVariables().where((v) => !v.isConst).toList(growable: false);
570+
// XXX working around a VM SDK issue. Once fixed, you can chain the sort()
571+
if (temp.isNotEmpty) temp.sort(byName);
572+
return temp;
567573
}
568574

569575
bool get hasConstants => _getVariables().any((v) => v.isConst);
570576

571577
List<TopLevelVariable> get constants {
572-
return _getVariables().where((v) => v.isConst).toList(growable: false)
573-
..sort(byName);
578+
List temp = _getVariables().where((v) => v.isConst).toList(growable: false);
579+
580+
// XXX working around a VM SDK issue. Once fixed, you can chain the sort()
581+
if (temp.isNotEmpty) temp.sort(byName);
582+
583+
return temp;
574584
}
575585

576586
bool get hasEnums => enums.isNotEmpty;
@@ -584,7 +594,11 @@ class Library extends ModelElement {
584594
_enums = enumClasses
585595
.where(isPublic)
586596
.map((e) => new Enum(e, this))
587-
.toList(growable: false)..sort((a, b) => a.name.compareTo(b.name));
597+
.toList(growable: false);
598+
599+
// XXX working around a VM SDK issue. Once fixed, you can chain the sort()
600+
if (_enums.isNotEmpty) _enums.sort(byName);
601+
588602
return _enums;
589603
}
590604

@@ -606,9 +620,12 @@ class Library extends ModelElement {
606620
elements.addAll(_exportedNamespace
607621
.where((element) => element is FunctionTypeAliasElement));
608622
elements..removeWhere(isPrivate);
609-
_typeDefs = elements
610-
.map((e) => new Typedef(e, this))
611-
.toList(growable: false)..sort(byName);
623+
_typeDefs =
624+
elements.map((e) => new Typedef(e, this)).toList(growable: false);
625+
626+
// XXX working around a VM SDK issue. Once fixed, you can chain the sort()
627+
if (_typeDefs.isNotEmpty) _typeDefs.sort(byName);
628+
612629
return _typeDefs;
613630
}
614631

@@ -628,7 +645,11 @@ class Library extends ModelElement {
628645
elements..removeWhere(isPrivate);
629646
_functions = elements.map((e) {
630647
return new ModelFunction(e, this);
631-
}).toList(growable: false)..sort(byName);
648+
}).toList(growable: false);
649+
650+
// XXX working around a VM SDK issue. Once fixed, you can chain the sort()
651+
if (_functions.isNotEmpty) _functions.sort(byName);
652+
632653
return _functions;
633654
}
634655

@@ -652,14 +673,18 @@ class Library extends ModelElement {
652673
_classes = types
653674
.where(isPublic)
654675
.map((e) => new Class(e, this))
655-
.toList(growable: false)..sort(byName);
676+
.toList(growable: false);
677+
678+
// XXX working around a VM SDK issue. Once fixed, you can chain the sort()
679+
if (_classes.isNotEmpty) _classes.sort(byName);
656680

657681
return _classes;
658682
}
659683

660684
List<Class> get classes {
661-
return _allClasses.where((c) => !c.isErrorOrException).toList(
662-
growable: false);
685+
return _allClasses
686+
.where((c) => !c.isErrorOrException)
687+
.toList(growable: false);
663688
}
664689

665690
List<Class> get allClasses => _allClasses;
@@ -669,8 +694,13 @@ class Library extends ModelElement {
669694
bool get hasExceptions => _allClasses.any((c) => c.isErrorOrException);
670695

671696
List<Class> get exceptions {
672-
return _allClasses.where((c) => c.isErrorOrException).toList(
673-
growable: false)..sort(byName);
697+
List temp =
698+
_allClasses.where((c) => c.isErrorOrException).toList(growable: false);
699+
700+
// XXX working around a VM SDK issue. Once fixed, you can chain the sort()
701+
if (temp.isNotEmpty) temp.sort(byName);
702+
703+
return temp;
674704
}
675705

676706
@override
@@ -751,9 +781,9 @@ class Class extends ModelElement {
751781
}
752782

753783
List<TypeParameter> get _typeParameters => _cls.typeParameters.map((f) {
754-
var lib = new Library(f.enclosingElement.library, package);
755-
return new TypeParameter(f, lib);
756-
}).toList();
784+
var lib = new Library(f.enclosingElement.library, package);
785+
return new TypeParameter(f, lib);
786+
}).toList();
757787

758788
String get kind => 'class';
759789

@@ -803,7 +833,10 @@ class Class extends ModelElement {
803833
_fields = _cls.fields
804834
.where(isPublic)
805835
.map((e) => new Field(e, library))
806-
.toList(growable: false)..sort(byName);
836+
.toList(growable: false);
837+
838+
// XXX working around a VM SDK issue. Once fixed, you can chain the sort()
839+
if (_fields.isNotEmpty) _fields.sort(byName);
807840

808841
return _fields;
809842
}
@@ -813,25 +846,34 @@ class Class extends ModelElement {
813846
_staticFields = _allFields
814847
.where((f) => f.isStatic)
815848
.where((f) => !f.isConst)
816-
.toList(growable: false)..sort(byName);
849+
.toList(growable: false);
850+
851+
// XXX working around a VM SDK issue. Once fixed, you can chain the sort()
852+
if (_staticFields.isNotEmpty) _staticFields.sort(byName);
853+
817854
return _staticFields;
818855
}
819856

820857
bool get hasInstanceProperties => instanceProperties.isNotEmpty;
821858

822859
List<Field> get instanceProperties {
823860
if (_instanceFields != null) return _instanceFields;
824-
_instanceFields = _allFields
825-
.where((f) => !f.isStatic)
826-
.toList(growable: false)..sort(byName);
861+
_instanceFields =
862+
_allFields.where((f) => !f.isStatic).toList(growable: false);
863+
864+
// XXX working around a VM SDK issue. Once fixed, you can chain the sort()
865+
if (_instanceFields.isNotEmpty) _instanceFields.sort(byName);
827866

828867
return _instanceFields;
829868
}
830869

831870
List<Field> get constants {
832871
if (_constants != null) return _constants;
833-
_constants = _allFields.where((f) => f.isConst).toList(growable: false)
834-
..sort((a, b) => a.name.compareTo(b.name));
872+
_constants = _allFields.where((f) => f.isConst).toList(growable: false);
873+
874+
// XXX working around a VM SDK issue. Once fixed, you can chain the sort()
875+
if (_constants.isNotEmpty) _constants.sort(byName);
876+
835877
return _constants;
836878
}
837879

@@ -844,7 +886,10 @@ class Class extends ModelElement {
844886

845887
_constructors = _cls.constructors.where(isPublic).map((e) {
846888
return new Constructor(e, library);
847-
}).toList(growable: true)..sort(byName);
889+
}).toList(growable: true);
890+
891+
// XXX working around a VM SDK issue. Once fixed, you can chain the sort()
892+
if (_constructors.isNotEmpty) _constructors.sort(byName);
848893

849894
return _constructors;
850895
}
@@ -860,16 +905,21 @@ class Class extends ModelElement {
860905
} else {
861906
return new Operator(e, library);
862907
}
863-
}).toList(growable: false)..sort(byName);
908+
}).toList(growable: false);
909+
910+
// XXX working around a VM SDK issue. Once fixed, you can chain the sort()
911+
if (_allMethods.isNotEmpty) _allMethods.sort(byName);
864912

865913
return _allMethods;
866914
}
867915

868916
List<Operator> get operators {
869917
if (_operators != null) return _operators;
870918

871-
_operators = _methods.where((m) => m.isOperator).toList(growable: false)
872-
..sort(byName);
919+
_operators = _methods.where((m) => m.isOperator).toList(growable: false);
920+
921+
// XXX working around a VM SDK issue. Once fixed, you can chain the sort()
922+
if (_operators.isNotEmpty) _operators.sort(byName);
873923

874924
return _operators;
875925
}
@@ -889,8 +939,10 @@ class Class extends ModelElement {
889939
List<Method> get staticMethods {
890940
if (_staticMethods != null) return _staticMethods;
891941

892-
_staticMethods = _methods.where((m) => m.isStatic).toList(growable: false)
893-
..sort(byName);
942+
_staticMethods = _methods.where((m) => m.isStatic).toList(growable: false);
943+
944+
// XXX working around a VM SDK issue. Once fixed, you can chain the sort()
945+
if (_staticMethods.isNotEmpty) _staticMethods.sort(byName);
894946

895947
return _staticMethods;
896948
}
@@ -902,7 +954,10 @@ class Class extends ModelElement {
902954

903955
_instanceMethods = _methods
904956
.where((m) => !m.isStatic && !m.isOperator)
905-
.toList(growable: false)..sort(byName);
957+
.toList(growable: false);
958+
959+
// XXX working around a VM SDK issue. Once fixed, you can chain the sort()
960+
if (_instanceMethods.isNotEmpty) _instanceMethods.sort(byName);
906961

907962
return _instanceMethods;
908963
}
@@ -962,7 +1017,7 @@ class Class extends ModelElement {
9621017
}
9631018
}
9641019

965-
_inheritedMethods..sort(byName);
1020+
_inheritedMethods.sort(byName);
9661021

9671022
return _inheritedMethods;
9681023
}
@@ -1021,7 +1076,7 @@ class Class extends ModelElement {
10211076
_inheritedOperators.add(new Operator.inherited(value, lib));
10221077
}
10231078

1024-
_inheritedOperators..sort(byName);
1079+
_inheritedOperators.sort(byName);
10251080

10261081
return _inheritedOperators;
10271082
}
@@ -1080,7 +1135,7 @@ class Class extends ModelElement {
10801135
}
10811136
}
10821137

1083-
_inheritedProperties..sort(byName);
1138+
_inheritedProperties.sort(byName);
10841139

10851140
return _inheritedProperties;
10861141
}
@@ -1147,14 +1202,18 @@ class Enum extends Class {
11471202
.where(isPublic)
11481203
.where((f) => f.isConst)
11491204
.map((field) => new EnumField.forConstant(index++, field, library))
1150-
.toList(growable: false)..sort(byName);
1205+
.toList(growable: false);
1206+
1207+
// XXX working around a VM SDK issue. Once fixed, you can chain the sort()
1208+
if (_constants.isNotEmpty) _constants.sort(byName);
11511209

11521210
return _constants;
11531211
}
11541212

11551213
@override
11561214
List<EnumField> get instanceProperties {
1157-
return super.instanceProperties
1215+
return super
1216+
.instanceProperties
11581217
.map((Field p) => new EnumField(p.element, p.library))
11591218
.toList(growable: false);
11601219
}
@@ -1647,8 +1706,10 @@ class ElementType {
16471706

16481707
ElementType get _returnType {
16491708
var rt = (_type as FunctionType).returnType;
1650-
return new ElementType(rt, new ModelElement.from(
1651-
rt.element, new Library(_element.library.element, _element.package)));
1709+
return new ElementType(
1710+
rt,
1711+
new ModelElement.from(rt.element,
1712+
new Library(_element.library.element, _element.package)));
16521713
}
16531714

16541715
ModelElement get returnElement {
@@ -1662,9 +1723,9 @@ class ElementType {
16621723

16631724
List<ElementType> get typeArguments =>
16641725
(_type as ParameterizedType).typeArguments.map((f) {
1665-
var lib = new Library(f.element.library, _element.package);
1666-
return new ElementType(f, new ModelElement.from(f.element, lib));
1667-
}).toList();
1726+
var lib = new Library(f.element.library, _element.package);
1727+
return new ElementType(f, new ModelElement.from(f.element, lib));
1728+
}).toList();
16681729

16691730
String get linkedName {
16701731
if (_linkedName != null) return _linkedName;

0 commit comments

Comments
 (0)