Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(629)

Unified Diff: pkg/analyzer/lib/src/generated/source_io.dart

Issue 243263004: New analyzer snapshot. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « pkg/analyzer/lib/src/generated/sdk_io.dart ('k') | pkg/analyzer/pubspec.yaml » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 0be26ecba953fcd57c3b992888d15051f98a516f..554985dbfbda2d594e786170c85774fe458ec918 100644
--- a/pkg/analyzer/lib/src/generated/source_io.dart
+++ b/pkg/analyzer/lib/src/generated/source_io.dart
@@ -168,6 +168,105 @@ class FileBasedSource implements Source {
}
/**
+ * 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 the class `RelativeFileUriResolver` resolve `file` URI's.
+ */
+class RelativeFileUriResolver extends UriResolver {
+ /**
+ * The name of the `file` scheme.
+ */
+ static String FILE_SCHEME = "file";
+
+ /**
+ * 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
+ */
+ static bool isFileUri(Uri uri) => uri.scheme == FILE_SCHEME;
+
+ /**
+ * The directories for the relatvie URI's
+ */
+ final List<JavaFile> _relativeDirectories;
+
+ /**
+ * The root directory for all the source trees
+ */
+ final JavaFile _rootDirectory;
+
+ /**
+ * Initialize a newly created resolver to resolve `file` URI's relative to the given root
+ * directory.
+ */
+ RelativeFileUriResolver(this._rootDirectory, this._relativeDirectories) : super();
+
+ @override
+ Source fromEncoding(UriKind kind, Uri uri) {
+ if (kind == UriKind.FILE_URI) {
+ return new FileBasedSource.con2(new JavaFile.fromUri(uri), kind);
+ }
+ return null;
+ }
+
+ @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;
+ }
+}
+
+/**
* Instances of the class `PackageUriResolver` resolve `package` URI's in the context of
* an application.
*
« no previous file with comments | « pkg/analyzer/lib/src/generated/sdk_io.dart ('k') | pkg/analyzer/pubspec.yaml » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698