Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(196)

Unified Diff: sdk/lib/_internal/pub/lib/src/source_registry.dart

Issue 228703006: Add “pub cache repair” to forcibly re-install previously cached packages. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Revise. Created 6 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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) {

Powered by Google App Engine
This is Rietveld 408576698