Index: pkg/analyzer/lib/src/generated/source.dart |
=================================================================== |
--- pkg/analyzer/lib/src/generated/source.dart (revision 43787) |
+++ 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 { |
+ final Map<String, String> _urlMappings; |
+ |
+ CustomUriResolver(this._urlMappings); |
+ |
+ @override |
+ Source resolveAbsolute(Uri uri) { |
+ String mapping = _urlMappings[uri.toString()]; |
+ if (mapping == null) return null; |
+ |
+ Uri fileUri = new Uri.file(mapping); |
+ if (!fileUri.isAbsolute) return null; |
+ |
+ JavaFile 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. |