| Index: pkg/front_end/lib/src/base/uri_resolver.dart
|
| diff --git a/pkg/front_end/lib/src/base/uri_resolver.dart b/pkg/front_end/lib/src/base/uri_resolver.dart
|
| index db469f0003df510d13a843e5714d15aa220f65be..3f2bbaafda0ad9f92ab4f6128ab2c05eae8c2297 100644
|
| --- a/pkg/front_end/lib/src/base/uri_resolver.dart
|
| +++ b/pkg/front_end/lib/src/base/uri_resolver.dart
|
| @@ -6,9 +6,13 @@ import 'package:path/path.dart' as p;
|
|
|
| /// The class `UriResolver` implements the rules for resolving URIs to file
|
| /// paths.
|
| -///
|
| -/// TODO(paulberry): Is it necessary to support the "http" scheme?
|
| class UriResolver {
|
| + /// The URI scheme used for "package" URIs.
|
| + static const PACKAGE_SCHEME = 'package';
|
| +
|
| + /// The URI scheme used for "dart" URIs.
|
| + static const DART_SCHEME = 'dart';
|
| +
|
| /// A map from package name to the file URI of the "lib" directory of the
|
| /// corresponding package. This is equivalent to the format returned by
|
| /// the "package_config" package's parse() function.
|
| @@ -22,32 +26,28 @@ class UriResolver {
|
| /// paths.
|
| final p.Context pathContext;
|
|
|
| - /// The URI scheme used for "package" URIs.
|
| - static const PACKAGE_SCHEME = 'package';
|
| -
|
| - /// The URI scheme used for "dart" URIs.
|
| - static const DART_SCHEME = 'dart';
|
| -
|
| - /// The URI scheme used for "file" URIs.
|
| - static const FILE_SCHEME = 'file';
|
| -
|
| UriResolver(this.packages, this.sdkLibraries, this.pathContext);
|
|
|
| - /// Converts a URI to a file path.
|
| + /// Converts "package:" and "dart:" URIs to the locations of the corresponding
|
| + /// files.
|
| ///
|
| - /// If the given URI is valid, and of a recognized form, returns the file path
|
| - /// it corresponds to. Otherwise returns `null`. It is not necessary for the
|
| - /// URI to be absolute (relative URIs will be converted to relative file
|
| - /// paths).
|
| + /// If the given URI is a "package:" or "dart:" URI, is well formed, and names
|
| + /// a package or dart library that is recognized, returns the file path it
|
| + /// corresponds to. If the given URI is a "package:" or "dart:" URI, and is
|
| + /// ill-formed or names a package or dart library that is not recognized,
|
| + /// returns `null`.
|
| + ///
|
| + /// If the given URI has any scheme other than "package:" or "dart:", it is
|
| + /// returned unchanged.
|
| + ///
|
| + /// It is not necessary for the URI to be absolute (relative URIs will be
|
| + /// converted to relative file paths).
|
| ///
|
| /// Note that no I/O is performed; the file path that is returned will be
|
| /// independent of whether or not any particular file exists on the file
|
| /// system.
|
| - String resolve(Uri uri) {
|
| - Uri fileUri;
|
| - if (uri.scheme == FILE_SCHEME) {
|
| - fileUri = uri;
|
| - } else {
|
| + Uri resolve(Uri uri) {
|
| + if (uri.scheme == DART_SCHEME || uri.scheme == PACKAGE_SCHEME) {
|
| var path = uri.path;
|
| var slashIndex = path.indexOf('/');
|
| String prefix;
|
| @@ -67,9 +67,9 @@ class UriResolver {
|
| libUri = sdkLibraries[prefix];
|
| }
|
| if (libUri == null) return null;
|
| - fileUri = libUri.resolve(rest);
|
| - if (fileUri.scheme != FILE_SCHEME) return null;
|
| + return libUri.resolve(rest);
|
| + } else {
|
| + return uri;
|
| }
|
| - return pathContext.fromUri(fileUri);
|
| }
|
| }
|
|
|