Index: sdk/lib/_internal/pub/lib/src/source_registry.dart |
diff --git a/sdk/lib/_internal/pub/lib/src/source_registry.dart b/sdk/lib/_internal/pub/lib/src/source_registry.dart |
index cd3dc3ef162cbd46ccfcd330ded435c71a505897..9d05e153274ccfd632fe851e510e0f5c0aef3a09 100644 |
--- a/sdk/lib/_internal/pub/lib/src/source_registry.dart |
+++ b/sdk/lib/_internal/pub/lib/src/source_registry.dart |
@@ -4,10 +4,12 @@ |
library pub.source_registry; |
+import 'dart:collection'; |
+ |
import 'source.dart'; |
/// A class that keeps track of [Source]s used for getting packages. |
-class SourceRegistry { |
+class SourceRegistry extends IterableBase<Source> { |
final Map<String, Source> _map; |
Source _default; |
@@ -17,6 +19,13 @@ class SourceRegistry { |
/// Returns the default source, which is used when no source is specified. |
Source get defaultSource => _default; |
+ /// Iterates over the registered sources in name order. |
+ Iterator<Source> get iterator { |
+ var sources = _map.values.toList(); |
+ sources.sort((a, b) => a.name.compareTo(b.name)); |
+ return sources.iterator; |
+ } |
+ |
/// Sets the default source. This takes a string, which must be the name of a |
/// registered source. |
void setDefault(String name) { |