From 2baaec30ebac89d0f10d8438e1b7103aad9ce792 Mon Sep 17 00:00:00 2001 From: Janice Collins Date: Mon, 28 Jun 2021 16:05:52 -0700 Subject: [PATCH 1/4] Stabilize the global table insertion order in the new lookup code. --- lib/src/model/package.dart | 2 +- lib/src/model/package_graph.dart | 16 +++++++++++----- 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/lib/src/model/package.dart b/lib/src/model/package.dart index e1f4113964..327207a6b8 100644 --- a/lib/src/model/package.dart +++ b/lib/src/model/package.dart @@ -406,7 +406,7 @@ class Package extends LibraryContainer Map get referenceChildren { if (_referenceChildren == null) { _referenceChildren = {}; - _referenceChildren.addEntries(allLibraries.generateEntries()); + _referenceChildren.addEntries(publicLibrariesSorted.generateEntries()); // Do not override any preexisting data, and insert based on the // public library sort order. // TODO(jcollins-g): warn when results require package-global diff --git a/lib/src/model/package_graph.dart b/lib/src/model/package_graph.dart index 62b501dbdf..0d27d65776 100644 --- a/lib/src/model/package_graph.dart +++ b/lib/src/model/package_graph.dart @@ -1030,19 +1030,25 @@ class PackageGraph with CommentReferable, Nameable { Map get referenceChildren { if (_referenceChildren == null) { _referenceChildren = {}; + // We have to use a stable order or otherwise references depending + // on ambiguous resolution (see below) will change where they + // resolve based on internal implementation details. + var sortedPackages = documentedPackages.toList()..sort(byName); // Packages are the top priority. - _referenceChildren.addEntries(packages.generateEntries()); + _referenceChildren.addEntries(sortedPackages.generateEntries()); // Libraries are next. // TODO(jcollins-g): Warn about directly referencing libraries out of - // scope? - _referenceChildren.addEntriesIfAbsent(documentedPackages + // scope? Doing this is always going to be ambiguous and potentially + // confusing. + _referenceChildren.addEntriesIfAbsent(sortedPackages .expand((p) => p.publicLibrariesSorted) .generateEntries()); // TODO(jcollins-g): Warn about directly referencing top level items - // out of scope? - _referenceChildren.addEntriesIfAbsent(documentedPackages + // out of scope? Doing this will be even more ambiguous and + // potentially confusing than doing so with libraries. + _referenceChildren.addEntriesIfAbsent(sortedPackages .expand((p) => p.publicLibrariesSorted) .expand((l) => [ ...l.publicConstants, From c69329464593ccdeea5b06b85896299e7fe50c11 Mon Sep 17 00:00:00 2001 From: Janice Collins Date: Mon, 28 Jun 2021 16:20:24 -0700 Subject: [PATCH 2/4] Keep using all packages -- might be necessary in some cases and I've done all my testing that way so far. --- lib/src/model/package_graph.dart | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/lib/src/model/package_graph.dart b/lib/src/model/package_graph.dart index 0d27d65776..d088ec260f 100644 --- a/lib/src/model/package_graph.dart +++ b/lib/src/model/package_graph.dart @@ -1033,7 +1033,8 @@ class PackageGraph with CommentReferable, Nameable { // We have to use a stable order or otherwise references depending // on ambiguous resolution (see below) will change where they // resolve based on internal implementation details. - var sortedPackages = documentedPackages.toList()..sort(byName); + var sortedPackages = packages.toList()..sort(byName); + var sortedDocumentedPackages = documentedPackages.toList()..sort(byName); // Packages are the top priority. _referenceChildren.addEntries(sortedPackages.generateEntries()); @@ -1041,14 +1042,14 @@ class PackageGraph with CommentReferable, Nameable { // TODO(jcollins-g): Warn about directly referencing libraries out of // scope? Doing this is always going to be ambiguous and potentially // confusing. - _referenceChildren.addEntriesIfAbsent(sortedPackages + _referenceChildren.addEntriesIfAbsent(sortedDocumentedPackages .expand((p) => p.publicLibrariesSorted) .generateEntries()); // TODO(jcollins-g): Warn about directly referencing top level items // out of scope? Doing this will be even more ambiguous and // potentially confusing than doing so with libraries. - _referenceChildren.addEntriesIfAbsent(sortedPackages + _referenceChildren.addEntriesIfAbsent(sortedDocumentedPackages .expand((p) => p.publicLibrariesSorted) .expand((l) => [ ...l.publicConstants, From b72aaf713826dcba189d131ae091421dfc52861f Mon Sep 17 00:00:00 2001 From: Janice Collins Date: Mon, 28 Jun 2021 16:53:59 -0700 Subject: [PATCH 3/4] Make byName more stable via hashCode. --- lib/src/model/class.dart | 7 +++--- lib/src/model/container.dart | 18 +++++++------- lib/src/model/extension_target.dart | 2 +- lib/src/model/library_container.dart | 2 +- lib/src/model/nameable.dart | 9 +++++-- lib/src/model/package.dart | 2 +- lib/src/model/package_graph.dart | 5 ++-- lib/src/model/top_level_container.dart | 18 +++++++------- test/end2end/model_test.dart | 33 ++++++++++++++++++++++---- 9 files changed, 64 insertions(+), 32 deletions(-) diff --git a/lib/src/model/class.dart b/lib/src/model/class.dart index db3f826765..84d12f2bb6 100644 --- a/lib/src/model/class.dart +++ b/lib/src/model/class.dart @@ -126,7 +126,8 @@ class Class extends Container @override Iterable get publicConstructorsSorted => - _publicConstructorsSorted ??= publicConstructors.toList()..sort(byName); + _publicConstructorsSorted ??= publicConstructors.toList() + ..sort(byNameStable); /// Returns the library that encloses this element. @override @@ -207,8 +208,8 @@ class Class extends Container List _publicImplementorsSorted; - Iterable get publicImplementorsSorted => - _publicImplementorsSorted ??= publicImplementors.toList()..sort(byName); + Iterable get publicImplementorsSorted => _publicImplementorsSorted ??= + publicImplementors.toList()..sort(byNameStable); /*lazy final*/ List _inheritedMethods; diff --git a/lib/src/model/container.dart b/lib/src/model/container.dart index 75becea76b..681d7c34b9 100644 --- a/lib/src/model/container.dart +++ b/lib/src/model/container.dart @@ -97,7 +97,7 @@ abstract class Container extends ModelElement with TypeParameters { List _publicInstanceMethodsSorted; List get publicInstanceMethodsSorted => _publicInstanceMethodsSorted ?? publicInstanceMethods.toList() - ..sort(byName); + ..sort(byNameStable); Iterable _declaredOperators; @nonVirtual @@ -123,7 +123,7 @@ abstract class Container extends ModelElement with TypeParameters { List _publicInstanceOperatorsSorted; List get publicInstanceOperatorsSorted => _publicInstanceOperatorsSorted ??= publicInstanceOperators.toList() - ..sort(byName); + ..sort(byNameStable); /// Fields fully declared in this [Container]. Iterable get declaredFields; @@ -143,7 +143,7 @@ abstract class Container extends ModelElement with TypeParameters { List _publicInstanceFieldsSorted; List get publicInstanceFieldsSorted => _publicInstanceFieldsSorted ??= - publicInstanceFields.toList()..sort(byName); + publicInstanceFields.toList()..sort(byNameStable); Iterable get constantFields => declaredFields.where((f) => f.isConst); @@ -154,7 +154,7 @@ abstract class Container extends ModelElement with TypeParameters { List _publicConstantFieldsSorted; List get publicConstantFieldsSorted => _publicConstantFieldsSorted ??= - publicConstantFields.toList()..sort(byName); + publicConstantFields.toList()..sort(byNameStable); Iterable get instanceAccessors => instanceFields.expand((f) => f.allAccessors); @@ -223,8 +223,8 @@ abstract class Container extends ModelElement with TypeParameters { model_utils.filterNonPublic(staticFields); List _publicStaticFieldsSorted; - List get publicStaticFieldsSorted => - _publicStaticFieldsSorted ??= publicStaticFields.toList()..sort(byName); + List get publicStaticFieldsSorted => _publicStaticFieldsSorted ??= + publicStaticFields.toList()..sort(byNameStable); Iterable get staticFields => declaredFields.where((f) => f.isStatic); @@ -240,7 +240,7 @@ abstract class Container extends ModelElement with TypeParameters { List _publicVariableStaticFieldsSorted; List get publicVariableStaticFieldsSorted => _publicVariableStaticFieldsSorted ??= publicVariableStaticFields.toList() - ..sort(byName); + ..sort(byNameStable); Iterable get staticMethods => declaredMethods.where((m) => m.isStatic); @@ -252,8 +252,8 @@ abstract class Container extends ModelElement with TypeParameters { model_utils.filterNonPublic(staticMethods); List _publicStaticMethodsSorted; - List get publicStaticMethodsSorted => - _publicStaticMethodsSorted ??= publicStaticMethods.toList()..sort(byName); + List get publicStaticMethodsSorted => _publicStaticMethodsSorted ??= + publicStaticMethods.toList()..sort(byNameStable); /// For subclasses to add items after the main pass but before the /// parameter-global. diff --git a/lib/src/model/extension_target.dart b/lib/src/model/extension_target.dart index bea6e7c65f..368a7a9a67 100644 --- a/lib/src/model/extension_target.dart +++ b/lib/src/model/extension_target.dart @@ -31,5 +31,5 @@ mixin ExtensionTarget on ModelElement { ElementType get modelType; List get potentiallyApplicableExtensionsSorted => - potentiallyApplicableExtensions.toList()..sort(byName); + potentiallyApplicableExtensions.toList()..sort(byNameStable); } diff --git a/lib/src/model/library_container.dart b/lib/src/model/library_container.dart index 2a10757c4c..54642529aa 100644 --- a/lib/src/model/library_container.dart +++ b/lib/src/model/library_container.dart @@ -21,7 +21,7 @@ abstract class LibraryContainer List _publicLibrariesSorted; Iterable get publicLibrariesSorted => - _publicLibrariesSorted ??= publicLibraries.toList()..sort(byName); + _publicLibrariesSorted ??= publicLibraries.toList()..sort(byNameStable); bool get hasPublicLibraries => publicLibraries.isNotEmpty; diff --git a/lib/src/model/nameable.dart b/lib/src/model/nameable.dart index 3e8818caae..e6018302fd 100644 --- a/lib/src/model/nameable.dart +++ b/lib/src/model/nameable.dart @@ -35,5 +35,10 @@ abstract class Nameable { String toString() => name; } -int byName(Nameable a, Nameable b) => - compareAsciiLowerCaseNatural(a.name, b.name); +int byNameStable(Nameable a, Nameable b) { + var stringCompare = compareAsciiLowerCaseNatural(a.name, b.name); + if (stringCompare == 0) { + return a.hashCode.compareTo(b.hashCode); + } + return stringCompare; +} diff --git a/lib/src/model/package.dart b/lib/src/model/package.dart index 327207a6b8..8967733403 100644 --- a/lib/src/model/package.dart +++ b/lib/src/model/package.dart @@ -357,7 +357,7 @@ class Package extends LibraryContainer if (config.categoryOrder.isEmpty) { return documentedCategories; } - return documentedCategories.toList()..sort(byName); + return documentedCategories.toList()..sort(byNameStable); } bool get hasDocumentedCategories => documentedCategories.isNotEmpty; diff --git a/lib/src/model/package_graph.dart b/lib/src/model/package_graph.dart index d088ec260f..5f3529d791 100644 --- a/lib/src/model/package_graph.dart +++ b/lib/src/model/package_graph.dart @@ -1033,8 +1033,9 @@ class PackageGraph with CommentReferable, Nameable { // We have to use a stable order or otherwise references depending // on ambiguous resolution (see below) will change where they // resolve based on internal implementation details. - var sortedPackages = packages.toList()..sort(byName); - var sortedDocumentedPackages = documentedPackages.toList()..sort(byName); + var sortedPackages = packages.toList()..sort(byNameStable); + var sortedDocumentedPackages = documentedPackages.toList() + ..sort(byNameStable); // Packages are the top priority. _referenceChildren.addEntries(sortedPackages.generateEntries()); diff --git a/lib/src/model/top_level_container.dart b/lib/src/model/top_level_container.dart index 0f29d608cb..da77369e8c 100644 --- a/lib/src/model/top_level_container.dart +++ b/lib/src/model/top_level_container.dart @@ -52,57 +52,57 @@ abstract class TopLevelContainer implements Nameable { List _publicClassesSorted; Iterable get publicClassesSorted => - _publicClassesSorted ??= publicClasses.toList()..sort(byName); + _publicClassesSorted ??= publicClasses.toList()..sort(byNameStable); Iterable get publicExtensions => model_utils.filterNonPublic(extensions); List _publicExtensionsSorted; Iterable get publicExtensionsSorted => - _publicExtensionsSorted ??= publicExtensions.toList()..sort(byName); + _publicExtensionsSorted ??= publicExtensions.toList()..sort(byNameStable); Iterable get publicConstants => model_utils.filterNonPublic(constants); Iterable get publicConstantsSorted => - publicConstants.toList()..sort(byName); + publicConstants.toList()..sort(byNameStable); Iterable get publicEnums => model_utils.filterNonPublic(enums); List _publicEnumsSorted; Iterable get publicEnumsSorted => - _publicEnumsSorted ??= publicEnums.toList()..sort(byName); + _publicEnumsSorted ??= publicEnums.toList()..sort(byNameStable); Iterable get publicExceptions => model_utils.filterNonPublic(exceptions); List _publicExceptionsSorted; Iterable get publicExceptionsSorted => - _publicExceptionsSorted ??= publicExceptions.toList()..sort(byName); + _publicExceptionsSorted ??= publicExceptions.toList()..sort(byNameStable); Iterable get publicFunctions => model_utils.filterNonPublic(functions); List _publicFunctionsSorted; Iterable get publicFunctionsSorted => - _publicFunctionsSorted ??= publicFunctions.toList()..sort(byName); + _publicFunctionsSorted ??= publicFunctions.toList()..sort(byNameStable); Iterable get publicMixins => model_utils.filterNonPublic(mixins); List _publicMixinsSorted; Iterable get publicMixinsSorted => - _publicMixinsSorted ??= publicMixins.toList()..sort(byName); + _publicMixinsSorted ??= publicMixins.toList()..sort(byNameStable); Iterable get publicProperties => model_utils.filterNonPublic(properties); List _publicPropertiesSorted; Iterable get publicPropertiesSorted => - _publicPropertiesSorted ??= publicProperties.toList()..sort(byName); + _publicPropertiesSorted ??= publicProperties.toList()..sort(byNameStable); Iterable get publicTypedefs => model_utils.filterNonPublic(typedefs); List _publicTypedefsSorted; Iterable get publicTypedefsSorted => - _publicTypedefsSorted ??= publicTypedefs.toList()..sort(byName); + _publicTypedefsSorted ??= publicTypedefs.toList()..sort(byNameStable); } diff --git a/test/end2end/model_test.dart b/test/end2end/model_test.dart index 66552dc856..45631e09ef 100644 --- a/test/end2end/model_test.dart +++ b/test/end2end/model_test.dart @@ -4964,12 +4964,22 @@ String topLevelFunction(int param1, bool param2, Cool coolBeans, var a = StringName(names[i - 1]); var b = StringName(names[i]); test('"$a" < "$b"', () { - expect(byName(a, a), 0); - expect(byName(b, b), 0); - expect(byName(a, b), -1); - expect(byName(b, a), 1); + expect(byNameStable(a, a), 0); + expect(byNameStable(b, b), 0); + expect(byNameStable(a, b), -1); + expect(byNameStable(b, a), 1); }); } + + test('sort order is stable when necessary', () { + var a = StringNameHashCode('a', 12); + var b = StringNameHashCode('b', 12); + var aa = StringNameHashCode('a', 14); + expect(byNameStable(a, aa), -1); + expect(byNameStable(a, b), -1); + expect(byNameStable(b, a), 1); + expect(byNameStable(aa, b), -1); + }); }); } @@ -4982,3 +4992,18 @@ class StringName extends Nameable { @override String toString() => name; } + +class StringNameHashCode extends Nameable { + @override + final String name; + @override + final int hashCode; + + StringNameHashCode(this.name, this.hashCode); + + @override + String toString() => name; + + @override + bool operator ==(Object other) => super == other; +} From a8cc5d73692801a9869f253c1ba1b624a663ae3f Mon Sep 17 00:00:00 2001 From: Janice Collins Date: Mon, 28 Jun 2021 17:00:57 -0700 Subject: [PATCH 4/4] No need to rename it --- lib/src/model/class.dart | 7 +++---- lib/src/model/container.dart | 18 +++++++++--------- lib/src/model/extension_target.dart | 2 +- lib/src/model/library_container.dart | 2 +- lib/src/model/nameable.dart | 2 +- lib/src/model/package.dart | 2 +- lib/src/model/package_graph.dart | 5 ++--- lib/src/model/top_level_container.dart | 18 +++++++++--------- test/end2end/model_test.dart | 16 ++++++++-------- 9 files changed, 35 insertions(+), 37 deletions(-) diff --git a/lib/src/model/class.dart b/lib/src/model/class.dart index 84d12f2bb6..db3f826765 100644 --- a/lib/src/model/class.dart +++ b/lib/src/model/class.dart @@ -126,8 +126,7 @@ class Class extends Container @override Iterable get publicConstructorsSorted => - _publicConstructorsSorted ??= publicConstructors.toList() - ..sort(byNameStable); + _publicConstructorsSorted ??= publicConstructors.toList()..sort(byName); /// Returns the library that encloses this element. @override @@ -208,8 +207,8 @@ class Class extends Container List _publicImplementorsSorted; - Iterable get publicImplementorsSorted => _publicImplementorsSorted ??= - publicImplementors.toList()..sort(byNameStable); + Iterable get publicImplementorsSorted => + _publicImplementorsSorted ??= publicImplementors.toList()..sort(byName); /*lazy final*/ List _inheritedMethods; diff --git a/lib/src/model/container.dart b/lib/src/model/container.dart index 681d7c34b9..75becea76b 100644 --- a/lib/src/model/container.dart +++ b/lib/src/model/container.dart @@ -97,7 +97,7 @@ abstract class Container extends ModelElement with TypeParameters { List _publicInstanceMethodsSorted; List get publicInstanceMethodsSorted => _publicInstanceMethodsSorted ?? publicInstanceMethods.toList() - ..sort(byNameStable); + ..sort(byName); Iterable _declaredOperators; @nonVirtual @@ -123,7 +123,7 @@ abstract class Container extends ModelElement with TypeParameters { List _publicInstanceOperatorsSorted; List get publicInstanceOperatorsSorted => _publicInstanceOperatorsSorted ??= publicInstanceOperators.toList() - ..sort(byNameStable); + ..sort(byName); /// Fields fully declared in this [Container]. Iterable get declaredFields; @@ -143,7 +143,7 @@ abstract class Container extends ModelElement with TypeParameters { List _publicInstanceFieldsSorted; List get publicInstanceFieldsSorted => _publicInstanceFieldsSorted ??= - publicInstanceFields.toList()..sort(byNameStable); + publicInstanceFields.toList()..sort(byName); Iterable get constantFields => declaredFields.where((f) => f.isConst); @@ -154,7 +154,7 @@ abstract class Container extends ModelElement with TypeParameters { List _publicConstantFieldsSorted; List get publicConstantFieldsSorted => _publicConstantFieldsSorted ??= - publicConstantFields.toList()..sort(byNameStable); + publicConstantFields.toList()..sort(byName); Iterable get instanceAccessors => instanceFields.expand((f) => f.allAccessors); @@ -223,8 +223,8 @@ abstract class Container extends ModelElement with TypeParameters { model_utils.filterNonPublic(staticFields); List _publicStaticFieldsSorted; - List get publicStaticFieldsSorted => _publicStaticFieldsSorted ??= - publicStaticFields.toList()..sort(byNameStable); + List get publicStaticFieldsSorted => + _publicStaticFieldsSorted ??= publicStaticFields.toList()..sort(byName); Iterable get staticFields => declaredFields.where((f) => f.isStatic); @@ -240,7 +240,7 @@ abstract class Container extends ModelElement with TypeParameters { List _publicVariableStaticFieldsSorted; List get publicVariableStaticFieldsSorted => _publicVariableStaticFieldsSorted ??= publicVariableStaticFields.toList() - ..sort(byNameStable); + ..sort(byName); Iterable get staticMethods => declaredMethods.where((m) => m.isStatic); @@ -252,8 +252,8 @@ abstract class Container extends ModelElement with TypeParameters { model_utils.filterNonPublic(staticMethods); List _publicStaticMethodsSorted; - List get publicStaticMethodsSorted => _publicStaticMethodsSorted ??= - publicStaticMethods.toList()..sort(byNameStable); + List get publicStaticMethodsSorted => + _publicStaticMethodsSorted ??= publicStaticMethods.toList()..sort(byName); /// For subclasses to add items after the main pass but before the /// parameter-global. diff --git a/lib/src/model/extension_target.dart b/lib/src/model/extension_target.dart index 368a7a9a67..bea6e7c65f 100644 --- a/lib/src/model/extension_target.dart +++ b/lib/src/model/extension_target.dart @@ -31,5 +31,5 @@ mixin ExtensionTarget on ModelElement { ElementType get modelType; List get potentiallyApplicableExtensionsSorted => - potentiallyApplicableExtensions.toList()..sort(byNameStable); + potentiallyApplicableExtensions.toList()..sort(byName); } diff --git a/lib/src/model/library_container.dart b/lib/src/model/library_container.dart index 54642529aa..2a10757c4c 100644 --- a/lib/src/model/library_container.dart +++ b/lib/src/model/library_container.dart @@ -21,7 +21,7 @@ abstract class LibraryContainer List _publicLibrariesSorted; Iterable get publicLibrariesSorted => - _publicLibrariesSorted ??= publicLibraries.toList()..sort(byNameStable); + _publicLibrariesSorted ??= publicLibraries.toList()..sort(byName); bool get hasPublicLibraries => publicLibraries.isNotEmpty; diff --git a/lib/src/model/nameable.dart b/lib/src/model/nameable.dart index e6018302fd..761ea0150c 100644 --- a/lib/src/model/nameable.dart +++ b/lib/src/model/nameable.dart @@ -35,7 +35,7 @@ abstract class Nameable { String toString() => name; } -int byNameStable(Nameable a, Nameable b) { +int byName(Nameable a, Nameable b) { var stringCompare = compareAsciiLowerCaseNatural(a.name, b.name); if (stringCompare == 0) { return a.hashCode.compareTo(b.hashCode); diff --git a/lib/src/model/package.dart b/lib/src/model/package.dart index 8967733403..327207a6b8 100644 --- a/lib/src/model/package.dart +++ b/lib/src/model/package.dart @@ -357,7 +357,7 @@ class Package extends LibraryContainer if (config.categoryOrder.isEmpty) { return documentedCategories; } - return documentedCategories.toList()..sort(byNameStable); + return documentedCategories.toList()..sort(byName); } bool get hasDocumentedCategories => documentedCategories.isNotEmpty; diff --git a/lib/src/model/package_graph.dart b/lib/src/model/package_graph.dart index 5f3529d791..d088ec260f 100644 --- a/lib/src/model/package_graph.dart +++ b/lib/src/model/package_graph.dart @@ -1033,9 +1033,8 @@ class PackageGraph with CommentReferable, Nameable { // We have to use a stable order or otherwise references depending // on ambiguous resolution (see below) will change where they // resolve based on internal implementation details. - var sortedPackages = packages.toList()..sort(byNameStable); - var sortedDocumentedPackages = documentedPackages.toList() - ..sort(byNameStable); + var sortedPackages = packages.toList()..sort(byName); + var sortedDocumentedPackages = documentedPackages.toList()..sort(byName); // Packages are the top priority. _referenceChildren.addEntries(sortedPackages.generateEntries()); diff --git a/lib/src/model/top_level_container.dart b/lib/src/model/top_level_container.dart index da77369e8c..0f29d608cb 100644 --- a/lib/src/model/top_level_container.dart +++ b/lib/src/model/top_level_container.dart @@ -52,57 +52,57 @@ abstract class TopLevelContainer implements Nameable { List _publicClassesSorted; Iterable get publicClassesSorted => - _publicClassesSorted ??= publicClasses.toList()..sort(byNameStable); + _publicClassesSorted ??= publicClasses.toList()..sort(byName); Iterable get publicExtensions => model_utils.filterNonPublic(extensions); List _publicExtensionsSorted; Iterable get publicExtensionsSorted => - _publicExtensionsSorted ??= publicExtensions.toList()..sort(byNameStable); + _publicExtensionsSorted ??= publicExtensions.toList()..sort(byName); Iterable get publicConstants => model_utils.filterNonPublic(constants); Iterable get publicConstantsSorted => - publicConstants.toList()..sort(byNameStable); + publicConstants.toList()..sort(byName); Iterable get publicEnums => model_utils.filterNonPublic(enums); List _publicEnumsSorted; Iterable get publicEnumsSorted => - _publicEnumsSorted ??= publicEnums.toList()..sort(byNameStable); + _publicEnumsSorted ??= publicEnums.toList()..sort(byName); Iterable get publicExceptions => model_utils.filterNonPublic(exceptions); List _publicExceptionsSorted; Iterable get publicExceptionsSorted => - _publicExceptionsSorted ??= publicExceptions.toList()..sort(byNameStable); + _publicExceptionsSorted ??= publicExceptions.toList()..sort(byName); Iterable get publicFunctions => model_utils.filterNonPublic(functions); List _publicFunctionsSorted; Iterable get publicFunctionsSorted => - _publicFunctionsSorted ??= publicFunctions.toList()..sort(byNameStable); + _publicFunctionsSorted ??= publicFunctions.toList()..sort(byName); Iterable get publicMixins => model_utils.filterNonPublic(mixins); List _publicMixinsSorted; Iterable get publicMixinsSorted => - _publicMixinsSorted ??= publicMixins.toList()..sort(byNameStable); + _publicMixinsSorted ??= publicMixins.toList()..sort(byName); Iterable get publicProperties => model_utils.filterNonPublic(properties); List _publicPropertiesSorted; Iterable get publicPropertiesSorted => - _publicPropertiesSorted ??= publicProperties.toList()..sort(byNameStable); + _publicPropertiesSorted ??= publicProperties.toList()..sort(byName); Iterable get publicTypedefs => model_utils.filterNonPublic(typedefs); List _publicTypedefsSorted; Iterable get publicTypedefsSorted => - _publicTypedefsSorted ??= publicTypedefs.toList()..sort(byNameStable); + _publicTypedefsSorted ??= publicTypedefs.toList()..sort(byName); } diff --git a/test/end2end/model_test.dart b/test/end2end/model_test.dart index 45631e09ef..f1134d9e7b 100644 --- a/test/end2end/model_test.dart +++ b/test/end2end/model_test.dart @@ -4964,10 +4964,10 @@ String topLevelFunction(int param1, bool param2, Cool coolBeans, var a = StringName(names[i - 1]); var b = StringName(names[i]); test('"$a" < "$b"', () { - expect(byNameStable(a, a), 0); - expect(byNameStable(b, b), 0); - expect(byNameStable(a, b), -1); - expect(byNameStable(b, a), 1); + expect(byName(a, a), 0); + expect(byName(b, b), 0); + expect(byName(a, b), -1); + expect(byName(b, a), 1); }); } @@ -4975,10 +4975,10 @@ String topLevelFunction(int param1, bool param2, Cool coolBeans, var a = StringNameHashCode('a', 12); var b = StringNameHashCode('b', 12); var aa = StringNameHashCode('a', 14); - expect(byNameStable(a, aa), -1); - expect(byNameStable(a, b), -1); - expect(byNameStable(b, a), 1); - expect(byNameStable(aa, b), -1); + expect(byName(a, aa), -1); + expect(byName(a, b), -1); + expect(byName(b, a), 1); + expect(byName(aa, b), -1); }); }); }