| OLD | NEW |
| 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file |
| 2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
| 3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
| 4 | 4 |
| 5 #library('source_registry'); |
| 6 |
| 7 #import('source.dart'); |
| 8 |
| 5 /** | 9 /** |
| 6 * A class that keeps track of [Source]s used for installing packages. | 10 * A class that keeps track of [Source]s used for installing packages. |
| 7 */ | 11 */ |
| 8 class SourceRegistry { | 12 class SourceRegistry { |
| 9 final Map<String, Source> _map; | 13 final Map<String, Source> _map; |
| 10 Source _default; | 14 Source _default; |
| 11 | 15 |
| 12 /** | 16 /** |
| 13 * Creates a new registry with no packages registered. | 17 * Creates a new registry with no packages registered. |
| 14 */ | 18 */ |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 52 Source operator[](String name) { | 56 Source operator[](String name) { |
| 53 if (name == null) { | 57 if (name == null) { |
| 54 if (defaultSource != null) return defaultSource; | 58 if (defaultSource != null) return defaultSource; |
| 55 // TODO(nweiz): Real error-handling system | 59 // TODO(nweiz): Real error-handling system |
| 56 throw 'No default source has been registered'; | 60 throw 'No default source has been registered'; |
| 57 } | 61 } |
| 58 if (_map.containsKey(name)) return _map[name]; | 62 if (_map.containsKey(name)) return _map[name]; |
| 59 throw 'No source named $name is registered'; | 63 throw 'No source named $name is registered'; |
| 60 } | 64 } |
| 61 } | 65 } |
| OLD | NEW |