| OLD | NEW |
| 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 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 91 | 91 |
| 92 /** | 92 /** |
| 93 * Construct an [ExplicitSourceResolver] based on the given [uriToFileMap]. | 93 * Construct an [ExplicitSourceResolver] based on the given [uriToFileMap]. |
| 94 */ | 94 */ |
| 95 ExplicitSourceResolver(Map<Uri, JavaFile> uriToFileMap) | 95 ExplicitSourceResolver(Map<Uri, JavaFile> uriToFileMap) |
| 96 : uriToFileMap = uriToFileMap, | 96 : uriToFileMap = uriToFileMap, |
| 97 pathToUriMap = _computePathToUriMap(uriToFileMap); | 97 pathToUriMap = _computePathToUriMap(uriToFileMap); |
| 98 | 98 |
| 99 @override | 99 @override |
| 100 Source resolveAbsolute(Uri uri, [Uri actualUri]) { | 100 Source resolveAbsolute(Uri uri, [Uri actualUri]) { |
| 101 return new FileBasedSource(uriToFileMap[uri], actualUri ?? uri); | 101 JavaFile file = uriToFileMap[uri]; |
| 102 actualUri ??= uri; |
| 103 if (file == null) { |
| 104 return new NonExistingSource( |
| 105 uri.toString(), actualUri, UriKind.fromScheme(actualUri.scheme)); |
| 106 } else { |
| 107 return new FileBasedSource(file, actualUri); |
| 108 } |
| 102 } | 109 } |
| 103 | 110 |
| 104 @override | 111 @override |
| 105 Uri restoreAbsolute(Source source) { | 112 Uri restoreAbsolute(Source source) { |
| 106 return pathToUriMap[source.fullName]; | 113 return pathToUriMap[source.fullName]; |
| 107 } | 114 } |
| 108 | 115 |
| 109 /** | 116 /** |
| 110 * Build the inverse mapping of [uriToSourceMap]. | 117 * Build the inverse mapping of [uriToSourceMap]. |
| 111 */ | 118 */ |
| (...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 222 | 229 |
| 223 @override | 230 @override |
| 224 int get modificationStamp => file.lastModified(); | 231 int get modificationStamp => file.lastModified(); |
| 225 | 232 |
| 226 @override | 233 @override |
| 227 String get shortName => file.getName(); | 234 String get shortName => file.getName(); |
| 228 | 235 |
| 229 @override | 236 @override |
| 230 UriKind get uriKind { | 237 UriKind get uriKind { |
| 231 String scheme = uri.scheme; | 238 String scheme = uri.scheme; |
| 232 if (scheme == PackageUriResolver.PACKAGE_SCHEME) { | 239 return UriKind.fromScheme(scheme); |
| 233 return UriKind.PACKAGE_URI; | |
| 234 } else if (scheme == DartUriResolver.DART_SCHEME) { | |
| 235 return UriKind.DART_URI; | |
| 236 } else if (scheme == FileUriResolver.FILE_SCHEME) { | |
| 237 return UriKind.FILE_URI; | |
| 238 } | |
| 239 return UriKind.FILE_URI; | |
| 240 } | 240 } |
| 241 | 241 |
| 242 @override | 242 @override |
| 243 bool operator ==(Object object) => | 243 bool operator ==(Object object) => |
| 244 object is FileBasedSource && id == object.id; | 244 object is FileBasedSource && id == object.id; |
| 245 | 245 |
| 246 @override | 246 @override |
| 247 bool exists() => file.isFile(); | 247 bool exists() => file.isFile(); |
| 248 | 248 |
| 249 @override | 249 @override |
| (...skipping 303 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 553 } | 553 } |
| 554 | 554 |
| 555 /** | 555 /** |
| 556 * Return `true` if the given URI is a `file` URI. | 556 * Return `true` if the given URI is a `file` URI. |
| 557 * | 557 * |
| 558 * @param uri the URI being tested | 558 * @param uri the URI being tested |
| 559 * @return `true` if the given URI is a `file` URI | 559 * @return `true` if the given URI is a `file` URI |
| 560 */ | 560 */ |
| 561 static bool isFileUri(Uri uri) => uri.scheme == FILE_SCHEME; | 561 static bool isFileUri(Uri uri) => uri.scheme == FILE_SCHEME; |
| 562 } | 562 } |
| OLD | NEW |