| Index: pkg/analyzer/lib/src/generated/source_io.dart
|
| diff --git a/pkg/analyzer/lib/src/generated/source_io.dart b/pkg/analyzer/lib/src/generated/source_io.dart
|
| index 4d23c42ba9e468e31c12806ed7c3c11170b35f39..b9d8067fa4e004b4cf0b577567af8e69f6c84fdd 100644
|
| --- a/pkg/analyzer/lib/src/generated/source_io.dart
|
| +++ b/pkg/analyzer/lib/src/generated/source_io.dart
|
| @@ -15,61 +15,67 @@ import 'engine.dart';
|
| export 'source.dart';
|
|
|
| /**
|
| - * Instances of the class `RelativeFileUriResolver` resolve `file` URI's.
|
| + * Instances of the class [DirectoryBasedSourceContainer] represent a source container that
|
| + * contains all sources within a given directory.
|
| */
|
| -class RelativeFileUriResolver extends UriResolver {
|
| +class DirectoryBasedSourceContainer implements SourceContainer {
|
| /**
|
| - * The name of the `file` scheme.
|
| + * Append the system file separator to the given path unless the path already ends with a
|
| + * separator.
|
| + *
|
| + * @param path the path to which the file separator is to be added
|
| + * @return a path that ends with the system file separator
|
| */
|
| - static String FILE_SCHEME = "file";
|
| + static String _appendFileSeparator(String path) {
|
| + if (path == null || path.length <= 0 || path.codeUnitAt(path.length - 1) == JavaFile.separatorChar) {
|
| + return path;
|
| + }
|
| + return "${path}${JavaFile.separator}";
|
| + }
|
|
|
| /**
|
| - * Return `true` if the given URI is a `file` URI.
|
| - *
|
| - * @param uri the URI being tested
|
| - * @return `true` if the given URI is a `file` URI
|
| + * The container's path (not `null`).
|
| */
|
| - static bool isFileUri(Uri uri) => uri.scheme == FILE_SCHEME;
|
| + String _path;
|
|
|
| /**
|
| - * The directories for the relatvie URI's
|
| + * Construct a container representing the specified directory and containing any sources whose
|
| + * [Source#getFullName] starts with the directory's path. This is a convenience method,
|
| + * fully equivalent to [DirectoryBasedSourceContainer#DirectoryBasedSourceContainer]
|
| + * .
|
| + *
|
| + * @param directory the directory (not `null`)
|
| */
|
| - final List<JavaFile> _relativeDirectories;
|
| + DirectoryBasedSourceContainer.con1(JavaFile directory) : this.con2(directory.getPath());
|
|
|
| /**
|
| - * The root directory for all the source trees
|
| + * Construct a container representing the specified path and containing any sources whose
|
| + * [Source#getFullName] starts with the specified path.
|
| + *
|
| + * @param path the path (not `null` and not empty)
|
| */
|
| - final JavaFile _rootDirectory;
|
| + DirectoryBasedSourceContainer.con2(String path) {
|
| + this._path = _appendFileSeparator(path);
|
| + }
|
| +
|
| + @override
|
| + bool contains(Source source) => source.fullName.startsWith(_path);
|
| +
|
| + @override
|
| + bool operator ==(Object obj) => (obj is DirectoryBasedSourceContainer) && obj.path == path;
|
|
|
| /**
|
| - * Initialize a newly created resolver to resolve `file` URI's relative to the given root
|
| - * directory.
|
| + * Answer the receiver's path, used to determine if a source is contained in the receiver.
|
| + *
|
| + * @return the path (not `null`, not empty)
|
| */
|
| - RelativeFileUriResolver(this._rootDirectory, this._relativeDirectories) : super();
|
| + String get path => _path;
|
|
|
| @override
|
| - Source fromEncoding(UriKind kind, Uri uri) {
|
| - if (kind == UriKind.FILE_URI) {
|
| - return new FileBasedSource.con2(new JavaFile.fromUri(uri), kind);
|
| - }
|
| - return null;
|
| - }
|
| + int get hashCode => _path.hashCode;
|
|
|
| @override
|
| - Source resolveAbsolute(Uri uri) {
|
| - String rootPath = _rootDirectory.toURI().path;
|
| - String uriPath = uri.path;
|
| - if (uriPath != null && uriPath.startsWith(rootPath)) {
|
| - String filePath = uri.path.substring(rootPath.length);
|
| - for (JavaFile dir in _relativeDirectories) {
|
| - JavaFile file = new JavaFile.relative(dir, filePath);
|
| - if (file.exists()) {
|
| - return new FileBasedSource.con2(file, UriKind.FILE_URI);
|
| - }
|
| - }
|
| - }
|
| - return null;
|
| - }
|
| + String toString() => "SourceContainer[${_path}]";
|
| }
|
|
|
| /**
|
| @@ -215,47 +221,6 @@ class FileUriResolver extends UriResolver {
|
| }
|
|
|
| /**
|
| - * An implementation of an non-existing [Source].
|
| - */
|
| -class NonExistingSource implements Source {
|
| - final String _name;
|
| -
|
| - final UriKind uriKind;
|
| -
|
| - NonExistingSource(this._name, this.uriKind);
|
| -
|
| - @override
|
| - bool exists() => false;
|
| -
|
| - @override
|
| - TimestampedData<String> get contents {
|
| - throw new UnsupportedOperationException("${_name}does not exist.");
|
| - }
|
| -
|
| - @override
|
| - String get encoding {
|
| - throw new UnsupportedOperationException("${_name}does not exist.");
|
| - }
|
| -
|
| - @override
|
| - String get fullName => _name;
|
| -
|
| - @override
|
| - int get modificationStamp => 0;
|
| -
|
| - @override
|
| - String get shortName => _name;
|
| -
|
| - @override
|
| - bool get isInSystemLibrary => false;
|
| -
|
| - @override
|
| - Source resolveRelative(Uri relativeUri) {
|
| - throw new UnsupportedOperationException("${_name}does not exist.");
|
| - }
|
| -}
|
| -
|
| -/**
|
| * Instances of interface `LocalSourcePredicate` are used to determine if the given
|
| * [Source] is "local" in some sense, so can be updated.
|
| */
|
| @@ -290,14 +255,55 @@ class LocalSourcePredicate_FALSE implements LocalSourcePredicate {
|
| bool isLocal(Source source) => false;
|
| }
|
|
|
| +class LocalSourcePredicate_NOT_SDK implements LocalSourcePredicate {
|
| + @override
|
| + bool isLocal(Source source) => source.uriKind != UriKind.DART_URI;
|
| +}
|
| +
|
| class LocalSourcePredicate_TRUE implements LocalSourcePredicate {
|
| @override
|
| bool isLocal(Source source) => true;
|
| }
|
|
|
| -class LocalSourcePredicate_NOT_SDK implements LocalSourcePredicate {
|
| +/**
|
| + * An implementation of an non-existing [Source].
|
| + */
|
| +class NonExistingSource implements Source {
|
| + final String _name;
|
| +
|
| + final UriKind uriKind;
|
| +
|
| + NonExistingSource(this._name, this.uriKind);
|
| +
|
| @override
|
| - bool isLocal(Source source) => source.uriKind != UriKind.DART_URI;
|
| + bool exists() => false;
|
| +
|
| + @override
|
| + TimestampedData<String> get contents {
|
| + throw new UnsupportedOperationException("${_name}does not exist.");
|
| + }
|
| +
|
| + @override
|
| + String get encoding {
|
| + throw new UnsupportedOperationException("${_name}does not exist.");
|
| + }
|
| +
|
| + @override
|
| + String get fullName => _name;
|
| +
|
| + @override
|
| + int get modificationStamp => 0;
|
| +
|
| + @override
|
| + String get shortName => _name;
|
| +
|
| + @override
|
| + bool get isInSystemLibrary => false;
|
| +
|
| + @override
|
| + Source resolveRelative(Uri relativeUri) {
|
| + throw new UnsupportedOperationException("${_name}does not exist.");
|
| + }
|
| }
|
|
|
| /**
|
| @@ -454,65 +460,59 @@ class PackageUriResolver extends UriResolver {
|
| }
|
|
|
| /**
|
| - * Instances of the class [DirectoryBasedSourceContainer] represent a source container that
|
| - * contains all sources within a given directory.
|
| + * Instances of the class `RelativeFileUriResolver` resolve `file` URI's.
|
| */
|
| -class DirectoryBasedSourceContainer implements SourceContainer {
|
| +class RelativeFileUriResolver extends UriResolver {
|
| /**
|
| - * Append the system file separator to the given path unless the path already ends with a
|
| - * separator.
|
| - *
|
| - * @param path the path to which the file separator is to be added
|
| - * @return a path that ends with the system file separator
|
| + * The name of the `file` scheme.
|
| */
|
| - static String _appendFileSeparator(String path) {
|
| - if (path == null || path.length <= 0 || path.codeUnitAt(path.length - 1) == JavaFile.separatorChar) {
|
| - return path;
|
| - }
|
| - return "${path}${JavaFile.separator}";
|
| - }
|
| + static String FILE_SCHEME = "file";
|
|
|
| /**
|
| - * The container's path (not `null`).
|
| + * Return `true` if the given URI is a `file` URI.
|
| + *
|
| + * @param uri the URI being tested
|
| + * @return `true` if the given URI is a `file` URI
|
| */
|
| - String _path;
|
| + static bool isFileUri(Uri uri) => uri.scheme == FILE_SCHEME;
|
|
|
| /**
|
| - * Construct a container representing the specified directory and containing any sources whose
|
| - * [Source#getFullName] starts with the directory's path. This is a convenience method,
|
| - * fully equivalent to [DirectoryBasedSourceContainer#DirectoryBasedSourceContainer]
|
| - * .
|
| - *
|
| - * @param directory the directory (not `null`)
|
| + * The directories for the relatvie URI's
|
| */
|
| - DirectoryBasedSourceContainer.con1(JavaFile directory) : this.con2(directory.getPath());
|
| + final List<JavaFile> _relativeDirectories;
|
|
|
| /**
|
| - * Construct a container representing the specified path and containing any sources whose
|
| - * [Source#getFullName] starts with the specified path.
|
| - *
|
| - * @param path the path (not `null` and not empty)
|
| + * The root directory for all the source trees
|
| */
|
| - DirectoryBasedSourceContainer.con2(String path) {
|
| - this._path = _appendFileSeparator(path);
|
| - }
|
| -
|
| - @override
|
| - bool contains(Source source) => source.fullName.startsWith(_path);
|
| -
|
| - @override
|
| - bool operator ==(Object obj) => (obj is DirectoryBasedSourceContainer) && obj.path == path;
|
| + final JavaFile _rootDirectory;
|
|
|
| /**
|
| - * Answer the receiver's path, used to determine if a source is contained in the receiver.
|
| - *
|
| - * @return the path (not `null`, not empty)
|
| + * Initialize a newly created resolver to resolve `file` URI's relative to the given root
|
| + * directory.
|
| */
|
| - String get path => _path;
|
| + RelativeFileUriResolver(this._rootDirectory, this._relativeDirectories) : super();
|
|
|
| @override
|
| - int get hashCode => _path.hashCode;
|
| + Source fromEncoding(UriKind kind, Uri uri) {
|
| + if (kind == UriKind.FILE_URI) {
|
| + return new FileBasedSource.con2(new JavaFile.fromUri(uri), kind);
|
| + }
|
| + return null;
|
| + }
|
|
|
| @override
|
| - String toString() => "SourceContainer[${_path}]";
|
| + Source resolveAbsolute(Uri uri) {
|
| + String rootPath = _rootDirectory.toURI().path;
|
| + String uriPath = uri.path;
|
| + if (uriPath != null && uriPath.startsWith(rootPath)) {
|
| + String filePath = uri.path.substring(rootPath.length);
|
| + for (JavaFile dir in _relativeDirectories) {
|
| + JavaFile file = new JavaFile.relative(dir, filePath);
|
| + if (file.exists()) {
|
| + return new FileBasedSource.con2(file, UriKind.FILE_URI);
|
| + }
|
| + }
|
| + }
|
| + return null;
|
| + }
|
| }
|
|
|