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

Unified Diff: pkg/analysis_server/lib/src/resource.dart

Issue 351813002: A local file-based Index implementation. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Tweaks Created 6 years, 6 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/analysis_server/lib/src/index/store/split_store.dart ('k') | pkg/analysis_server/pubspec.yaml » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/analysis_server/lib/src/resource.dart
diff --git a/pkg/analysis_server/lib/src/resource.dart b/pkg/analysis_server/lib/src/resource.dart
index 0c8f8021075e00a6baf5dfa81a562f2bb279280d..5659eb61c1488bb72736d75285ece5ad97c5479b 100644
--- a/pkg/analysis_server/lib/src/resource.dart
+++ b/pkg/analysis_server/lib/src/resource.dart
@@ -459,3 +459,49 @@ class PhysicalResourceProvider implements ResourceProvider {
@override
Context get pathContext => io.Platform.isWindows ? windows : posix;
}
+
+
+/**
+ * A [UriResolver] for [Resource]s.
+ */
+class ResourceUriResolver extends UriResolver {
+ /**
+ * The name of the `file` scheme.
+ */
+ static String _FILE_SCHEME = "file";
+
+ final ResourceProvider _provider;
+
+ ResourceUriResolver(this._provider);
+
+ @override
+ Source fromEncoding(UriKind kind, Uri uri) {
+ if (kind == UriKind.FILE_URI) {
+ Resource resource = _provider.getResource(uri.path);
+ if (resource is File) {
+ return resource.createSource(kind);
+ }
+ }
+ return null;
+ }
+
+ @override
+ Source resolveAbsolute(Uri uri) {
+ if (!_isFileUri(uri)) {
+ return null;
+ }
+ Resource resource = _provider.getResource(uri.path);
+ if (resource is File) {
+ return resource.createSource(UriKind.FILE_URI);
+ }
+ return 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
+ */
+ static bool _isFileUri(Uri uri) => uri.scheme == _FILE_SCHEME;
+}
« no previous file with comments | « pkg/analysis_server/lib/src/index/store/split_store.dart ('k') | pkg/analysis_server/pubspec.yaml » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698