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

Side by Side Diff: pkg/analyzer/lib/src/generated/source_io.dart

Issue 1737693004: Update SOURCE_KIND when a missing source file appears (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 4 years, 9 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
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 analyzer.src.generated.source_io; 5 library analyzer.src.generated.source_io;
6 6
7 import 'dart:collection'; 7 import 'dart:collection';
8 8
9 import 'package:analyzer/src/generated/engine.dart'; 9 import 'package:analyzer/src/generated/engine.dart';
10 import 'package:analyzer/src/generated/java_core.dart'; 10 import 'package:analyzer/src/generated/java_core.dart';
(...skipping 476 matching lines...) Expand 10 before | Expand all | Expand 10 after
487 JavaFile.pathContext.toUri(filePath).toString(); 487 JavaFile.pathContext.toUri(filePath).toString();
488 488
489 /** 489 /**
490 * Return `true` if the given URI is a `package` URI. 490 * Return `true` if the given URI is a `package` URI.
491 * 491 *
492 * @param uri the URI being tested 492 * @param uri the URI being tested
493 * @return `true` if the given URI is a `package` URI 493 * @return `true` if the given URI is a `package` URI
494 */ 494 */
495 static bool isPackageUri(Uri uri) => PACKAGE_SCHEME == uri.scheme; 495 static bool isPackageUri(Uri uri) => PACKAGE_SCHEME == uri.scheme;
496 } 496 }
497
498 /**
499 * Instances of the class `RelativeFileUriResolver` resolve `file` URI's.
500 */
501 class RelativeFileUriResolver extends UriResolver {
Brian Wilkerson 2016/02/26 15:07:32 Removing this class is technically a breaking chan
502 /**
503 * The name of the `file` scheme.
504 */
505 static String FILE_SCHEME = "file";
506
507 /**
508 * The directories for the relatvie URI's
509 */
510 final List<JavaFile> _relativeDirectories;
511
512 /**
513 * The root directory for all the source trees
514 */
515 final JavaFile _rootDirectory;
516
517 /**
518 * Initialize a newly created resolver to resolve `file` URI's relative to the given root
519 * directory.
520 */
521 RelativeFileUriResolver(this._rootDirectory, this._relativeDirectories)
522 : super();
523
524 @override
525 Source resolveAbsolute(Uri uri, [Uri actualUri]) {
526 String rootPath = _rootDirectory.toURI().path;
527 String uriPath = uri.path;
528 if (uriPath != null && uriPath.startsWith(rootPath)) {
529 String filePath = uri.path.substring(rootPath.length);
530 for (JavaFile dir in _relativeDirectories) {
531 JavaFile file = new JavaFile.relative(dir, filePath);
532 if (file.exists()) {
533 return new FileBasedSource(file, actualUri != null ? actualUri : uri);
534 }
535 }
536 }
537 return null;
538 }
539
540 /**
541 * Return `true` if the given URI is a `file` URI.
542 *
543 * @param uri the URI being tested
544 * @return `true` if the given URI is a `file` URI
545 */
546 static bool isFileUri(Uri uri) => uri.scheme == FILE_SCHEME;
547 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698