Chromium Code Reviews| Index: pkg/analyzer/lib/source/custom_resolver.dart |
| diff --git a/pkg/analyzer/lib/source/custom_resolver.dart b/pkg/analyzer/lib/source/custom_resolver.dart |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..06a2d10a8fe98c37df065d31e5320c3b55638aba |
| --- /dev/null |
| +++ b/pkg/analyzer/lib/source/custom_resolver.dart |
| @@ -0,0 +1,33 @@ |
| +// Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file |
| +// for details. All rights reserved. Use of this source code is governed by a |
| +// BSD-style license that can be found in the LICENSE file. |
| + |
| +library analyzer.source.custom_resolver; |
| + |
| +import 'package:analyzer/file_system/file_system.dart'; |
| +import 'package:analyzer/src/generated/source.dart'; |
| + |
| +/** |
| + * 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
|
| + */ |
| +class CustomUriResolver extends UriResolver { |
| + final ResourceProvider resourceProvider; |
| + final Map<String, String> _urlMappings; |
| + |
| + CustomUriResolver(this.resourceProvider, this._urlMappings); |
| + |
| + @override |
| + Source resolveAbsolute(Uri uri, [Uri actualUri]) { |
| + String mapping = _urlMappings[uri.toString()]; |
| + if (mapping == null) { |
| + return null; |
| + } |
| + Uri fileUri = new Uri.file(mapping); |
| + if (!fileUri.isAbsolute) { |
| + return null; |
| + } |
| + return resourceProvider |
| + .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
|
| + .createSource(actualUri ?? uri); |
| + } |
| +} |