Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file | |
| 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. | |
| 4 | |
| 5 library analyzer.source.custom_resolver; | |
| 6 | |
| 7 import 'package:analyzer/file_system/file_system.dart'; | |
| 8 import 'package:analyzer/src/generated/source.dart'; | |
| 9 | |
| 10 /** | |
| 11 * A resolver that maps individual URI's to other URI's. | |
|
scheglov
2016/09/13 18:27:24
The comment seems too generic.
Brian Wilkerson
2016/09/13 20:37:20
The original class had no comment, and I don't act
| |
| 12 */ | |
| 13 class CustomUriResolver extends UriResolver { | |
| 14 final ResourceProvider resourceProvider; | |
| 15 final Map<String, String> _urlMappings; | |
| 16 | |
| 17 CustomUriResolver(this.resourceProvider, this._urlMappings); | |
| 18 | |
| 19 @override | |
| 20 Source resolveAbsolute(Uri uri, [Uri actualUri]) { | |
| 21 String mapping = _urlMappings[uri.toString()]; | |
| 22 if (mapping == null) { | |
| 23 return null; | |
| 24 } | |
| 25 Uri fileUri = new Uri.file(mapping); | |
| 26 if (!fileUri.isAbsolute) { | |
| 27 return null; | |
| 28 } | |
| 29 return resourceProvider | |
| 30 .getFile(fileUri.toFilePath()) | |
|
scheglov
2016/09/13 18:27:24
I think we need to use ResourceProvider's path con
Brian Wilkerson
2016/09/13 20:37:20
Done
| |
| 31 .createSource(actualUri ?? uri); | |
| 32 } | |
| 33 } | |
| OLD | NEW |