Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(281)

Unified Diff: lib/src/mirror_loader.dart

Issue 880713002: add LibraryIdentifier (Closed) Base URL: git@github.com:dart-lang/static-init.git@master
Patch Set: Created 5 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: lib/src/mirror_loader.dart
diff --git a/lib/src/mirror_loader.dart b/lib/src/mirror_loader.dart
index 1512ec9b63f4f82506e3b26c581e70eb32214f18..e37801b07d914676bb77a3e537792be1b4cdb859 100644
--- a/lib/src/mirror_loader.dart
+++ b/lib/src/mirror_loader.dart
@@ -145,7 +145,22 @@ class InitializationCrawler {
annotatedValue = (declaration.owner as ObjectMirror)
.getField(declaration.simpleName).reflectee;
} else if (declaration is LibraryMirror) {
- annotatedValue = declaration.qualifiedName;
+ var package;
+ var filePath;
+ Uri uri = declaration.uri;
+ if (uri.scheme == 'file') {
+ filePath = path.url.relative(
+ uri.path, from: path.url.dirname(_root.uri.path));
+ } else if (uri.scheme == 'package') {
+ var segments = uri.pathSegments;
+ package = segments[0];
+ filePath = path.url.joinAll(segments.getRange(1, segments.length));
+ } else {
+ throw new UnsupportedError('Unsupported uri scheme ${uri.scheme} for '
+ 'library ${declaration}.');
+ }
+ annotatedValue =
+ new LibraryIdentifier(declaration.qualifiedName, package, filePath);
} else {
throw _UNSUPPORTED_DECLARATION;
}

Powered by Google App Engine
This is Rietveld 408576698