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

Side by Side 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, 5 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 resource; 5 library resource;
6 6
7 import 'dart:async'; 7 import 'dart:async';
8 import 'dart:collection'; 8 import 'dart:collection';
9 import 'dart:io' as io; 9 import 'dart:io' as io;
10 10
(...skipping 441 matching lines...) Expand 10 before | Expand all | Expand 10 after
452 return new _PhysicalFolder(directory); 452 return new _PhysicalFolder(directory);
453 } else { 453 } else {
454 io.File file = new io.File(path); 454 io.File file = new io.File(path);
455 return new _PhysicalFile(file); 455 return new _PhysicalFile(file);
456 } 456 }
457 } 457 }
458 458
459 @override 459 @override
460 Context get pathContext => io.Platform.isWindows ? windows : posix; 460 Context get pathContext => io.Platform.isWindows ? windows : posix;
461 } 461 }
462
463
464 /**
465 * A [UriResolver] for [Resource]s.
466 */
467 class ResourceUriResolver extends UriResolver {
468 /**
469 * The name of the `file` scheme.
470 */
471 static String _FILE_SCHEME = "file";
472
473 final ResourceProvider _provider;
474
475 ResourceUriResolver(this._provider);
476
477 @override
478 Source fromEncoding(UriKind kind, Uri uri) {
479 if (kind == UriKind.FILE_URI) {
480 Resource resource = _provider.getResource(uri.path);
481 if (resource is File) {
482 return resource.createSource(kind);
483 }
484 }
485 return null;
486 }
487
488 @override
489 Source resolveAbsolute(Uri uri) {
490 if (!_isFileUri(uri)) {
491 return null;
492 }
493 Resource resource = _provider.getResource(uri.path);
494 if (resource is File) {
495 return resource.createSource(UriKind.FILE_URI);
496 }
497 return null;
498 }
499
500 /**
501 * Return `true` if the given URI is a `file` URI.
502 *
503 * @param uri the URI being tested
504 * @return `true` if the given URI is a `file` URI
505 */
506 static bool _isFileUri(Uri uri) => uri.scheme == _FILE_SCHEME;
507 }
OLDNEW
« 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