Chromium Code Reviews| Index: pkg/analyzer/lib/src/generated/source.dart |
| =================================================================== |
| --- pkg/analyzer/lib/src/generated/source.dart (revision 43472) |
| +++ pkg/analyzer/lib/src/generated/source.dart (working copy) |
| @@ -17,7 +17,9 @@ |
| import 'engine.dart'; |
| import 'java_core.dart'; |
| import 'java_engine.dart'; |
| +import 'java_io.dart' show JavaFile; |
| import 'sdk.dart' show DartSdk; |
| +import 'source_io.dart' show FileBasedSource; |
| /** |
| * A function that is used to handle [ContentCache] entries. |
| @@ -165,6 +167,24 @@ |
| static bool isDartUri(Uri uri) => DART_SCHEME == uri.scheme; |
| } |
| +class CustomUriResolver extends UriResolver { |
|
Brian Wilkerson
2015/02/13 23:56:13
It would be good to have some tests for this class
zra
2015/02/14 01:01:56
Done.
|
| + final Map<String, String> _urlMappings; |
| + |
| + CustomUriResolver(this._urlMappings); |
| + |
| + @override |
| + Source resolveAbsolute(Uri uri) { |
| + var mapping = _urlMappings[uri.toString()]; |
| + if (mapping == null) return null; |
| + |
| + var fileUri = new Uri.file(mapping); |
| + if (!fileUri.isAbsolute) return null; |
|
Brian Wilkerson
2015/02/13 23:56:13
I don't have source available at the moment, but i
zra
2015/02/14 01:01:56
The docs for Uri.file say "If the path starts with
|
| + |
| + var javaFile = new JavaFile.fromUri(fileUri); |
| + return new FileBasedSource.con1(javaFile); |
| + } |
| +} |
| + |
| /** |
| * Instances of the class `LineInfo` encapsulate information about line and column information |
| * within a source file. |