| 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 library resolver.package; | 5 library source.package_map_resolver; |
| 6 | 6 |
| 7 import 'package:analyzer/file_system/file_system.dart'; | 7 import 'package:analyzer/file_system/file_system.dart'; |
| 8 import 'package:analyzer/src/generated/source.dart'; | 8 import 'package:analyzer/src/generated/source.dart'; |
| 9 | 9 |
| 10 | 10 |
| 11 /** | 11 /** |
| 12 * A [UriResolver] implementation for the `package:` scheme that uses a map of | 12 * A [UriResolver] implementation for the `package:` scheme that uses a map of |
| 13 * package names to their directories. | 13 * package names to their directories. |
| 14 */ | 14 */ |
| 15 class PackageMapUriResolver extends UriResolver { | 15 class PackageMapUriResolver extends UriResolver { |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 74 Resource result = packageDir.getChild(relPath); | 74 Resource result = packageDir.getChild(relPath); |
| 75 if (result is File && result.exists) { | 75 if (result is File && result.exists) { |
| 76 return result.createSource(UriKind.PACKAGE_URI); | 76 return result.createSource(UriKind.PACKAGE_URI); |
| 77 } | 77 } |
| 78 } | 78 } |
| 79 } | 79 } |
| 80 } | 80 } |
| 81 // Return a NonExistingSource instance. | 81 // Return a NonExistingSource instance. |
| 82 // This helps provide more meaningful error messages to users | 82 // This helps provide more meaningful error messages to users |
| 83 // (a missing file error, as opposed to an invalid URI error). | 83 // (a missing file error, as opposed to an invalid URI error). |
| 84 // TODO(scheglov) move NonExistingSource to "source.dart" | |
| 85 return new NonExistingSource(uri.toString(), UriKind.PACKAGE_URI); | 84 return new NonExistingSource(uri.toString(), UriKind.PACKAGE_URI); |
| 86 } | 85 } |
| 87 | 86 |
| 88 /** | 87 /** |
| 89 * Returns `true` if [uri] is a `package` URI. | 88 * Returns `true` if [uri] is a `package` URI. |
| 90 */ | 89 */ |
| 91 static bool isPackageUri(Uri uri) { | 90 static bool isPackageUri(Uri uri) { |
| 92 return uri.scheme == PACKAGE_SCHEME; | 91 return uri.scheme == PACKAGE_SCHEME; |
| 93 } | 92 } |
| 94 } | 93 } |
| OLD | NEW |