OLD | NEW |
1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2014, 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 // This code was auto-generated, is not intended to be edited, and is subject to | 5 // This code was auto-generated, is not intended to be edited, and is subject to |
6 // significant change. Please see the README file for more information. | 6 // significant change. Please see the README file for more information. |
7 | 7 |
8 library engine.source.io; | 8 library engine.source.io; |
9 | 9 |
10 import 'source.dart'; | 10 import 'source.dart'; |
(...skipping 327 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
338 * | 338 * |
339 * @param packagesDirectories the package directories that `package` URI's are
assumed to be | 339 * @param packagesDirectories the package directories that `package` URI's are
assumed to be |
340 * relative to | 340 * relative to |
341 */ | 341 */ |
342 PackageUriResolver(this._packagesDirectories) { | 342 PackageUriResolver(this._packagesDirectories) { |
343 if (_packagesDirectories.length < 1) { | 343 if (_packagesDirectories.length < 1) { |
344 throw new IllegalArgumentException("At least one package directory must be
provided"); | 344 throw new IllegalArgumentException("At least one package directory must be
provided"); |
345 } | 345 } |
346 } | 346 } |
347 | 347 |
| 348 /** |
| 349 * If the list of package directories contains one element, return it. |
| 350 * Otherwise raise an exception. Intended for testing. |
| 351 */ |
| 352 String get packagesDirectory_forTesting { |
| 353 int length = _packagesDirectories.length; |
| 354 if (length != 1) { |
| 355 throw new Exception('Expected 1 package directory, found $length'); |
| 356 } |
| 357 return _packagesDirectories[0].getPath(); |
| 358 } |
| 359 |
348 @override | 360 @override |
349 Source resolveAbsolute(Uri uri) { | 361 Source resolveAbsolute(Uri uri) { |
350 if (!isPackageUri(uri)) { | 362 if (!isPackageUri(uri)) { |
351 return null; | 363 return null; |
352 } | 364 } |
353 String path = uri.path; | 365 String path = uri.path; |
354 if (path == null) { | 366 if (path == null) { |
355 path = uri.path; | 367 path = uri.path; |
356 if (path == null) { | 368 if (path == null) { |
357 return null; | 369 return null; |
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
489 for (JavaFile dir in _relativeDirectories) { | 501 for (JavaFile dir in _relativeDirectories) { |
490 JavaFile file = new JavaFile.relative(dir, filePath); | 502 JavaFile file = new JavaFile.relative(dir, filePath); |
491 if (file.exists()) { | 503 if (file.exists()) { |
492 return new FileBasedSource.con2(uri, file); | 504 return new FileBasedSource.con2(uri, file); |
493 } | 505 } |
494 } | 506 } |
495 } | 507 } |
496 return null; | 508 return null; |
497 } | 509 } |
498 } | 510 } |
OLD | NEW |