| 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 class CustomUriResolver extends UriResolver { |
| 11 final ResourceProvider resourceProvider; |
| 12 final Map<String, String> _urlMappings; |
| 13 |
| 14 CustomUriResolver(this.resourceProvider, this._urlMappings); |
| 15 |
| 16 @override |
| 17 Source resolveAbsolute(Uri uri, [Uri actualUri]) { |
| 18 String mapping = _urlMappings[uri.toString()]; |
| 19 if (mapping == null) { |
| 20 return null; |
| 21 } |
| 22 Uri fileUri = new Uri.file(mapping); |
| 23 if (!fileUri.isAbsolute) { |
| 24 return null; |
| 25 } |
| 26 return resourceProvider |
| 27 .getFile(resourceProvider.pathContext.fromUri(fileUri)) |
| 28 .createSource(actualUri ?? uri); |
| 29 } |
| 30 } |
| OLD | NEW |