Chromium Code Reviews| 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.file_system.file_system; | 5 library analyzer.file_system.file_system; |
| 6 | 6 |
| 7 import 'dart:async'; | 7 import 'dart:async'; |
| 8 | 8 |
| 9 import 'package:analyzer/src/generated/source.dart'; | 9 import 'package:analyzer/src/generated/source.dart'; |
| 10 import 'package:analyzer/src/util/absolute_path.dart'; | 10 import 'package:analyzer/src/util/absolute_path.dart'; |
| (...skipping 201 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 212 Folder getStateLocation(String pluginId); | 212 Folder getStateLocation(String pluginId); |
| 213 } | 213 } |
| 214 | 214 |
| 215 /** | 215 /** |
| 216 * A [UriResolver] for [Resource]s. | 216 * A [UriResolver] for [Resource]s. |
| 217 */ | 217 */ |
| 218 class ResourceUriResolver extends UriResolver { | 218 class ResourceUriResolver extends UriResolver { |
| 219 /** | 219 /** |
| 220 * The name of the `file` scheme. | 220 * The name of the `file` scheme. |
| 221 */ | 221 */ |
| 222 static String _FILE_SCHEME = "file"; | 222 static String FILE_SCHEME = "file"; |
|
Brian Wilkerson
2016/06/16 17:39:30
This should be marked 'final' now that it's public
jwren
2016/06/16 18:09:56
Done.
| |
| 223 | 223 |
| 224 final ResourceProvider _provider; | 224 final ResourceProvider _provider; |
| 225 | 225 |
| 226 ResourceUriResolver(this._provider); | 226 ResourceUriResolver(this._provider); |
| 227 | 227 |
| 228 @override | 228 @override |
| 229 Source resolveAbsolute(Uri uri, [Uri actualUri]) { | 229 Source resolveAbsolute(Uri uri, [Uri actualUri]) { |
| 230 if (!_isFileUri(uri)) { | 230 if (!isFileUri(uri)) { |
| 231 return null; | 231 return null; |
| 232 } | 232 } |
| 233 Resource resource = | 233 Resource resource = |
| 234 _provider.getResource(_provider.pathContext.fromUri(uri)); | 234 _provider.getResource(_provider.pathContext.fromUri(uri)); |
| 235 if (resource is File) { | 235 if (resource is File) { |
| 236 return resource.createSource(actualUri ?? uri); | 236 return resource.createSource(actualUri ?? uri); |
| 237 } | 237 } |
| 238 return null; | 238 return null; |
| 239 } | 239 } |
| 240 | 240 |
| 241 @override | 241 @override |
| 242 Uri restoreAbsolute(Source source) => | 242 Uri restoreAbsolute(Source source) => |
| 243 _provider.pathContext.toUri(source.fullName); | 243 _provider.pathContext.toUri(source.fullName); |
| 244 | 244 |
| 245 /** | 245 /** |
| 246 * Return `true` if the given [uri] is a `file` URI. | 246 * Return `true` if the given [uri] is a `file` URI. |
| 247 */ | 247 */ |
| 248 static bool _isFileUri(Uri uri) => uri.scheme == _FILE_SCHEME; | 248 static bool isFileUri(Uri uri) => uri.scheme == FILE_SCHEME; |
| 249 } | 249 } |
| OLD | NEW |