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

Unified Diff: lib/src/compiler/code_generator.dart

Issue 1917863005: Qualify library names in packages (Closed) Base URL: https://github.com/dart-lang/dev_compiler.git@master
Patch Set: Created 4 years, 8 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
« no previous file with comments | « no previous file | lib/src/compiler/module_builder.dart » ('j') | lib/src/compiler/module_builder.dart » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: lib/src/compiler/code_generator.dart
diff --git a/lib/src/compiler/code_generator.dart b/lib/src/compiler/code_generator.dart
index 2c19b39ef6f2c7ac0a9af6e10978145d953ec503..608a896307951c205cf6f07e01168d5dd0b8212c 100644
--- a/lib/src/compiler/code_generator.dart
+++ b/lib/src/compiler/code_generator.dart
@@ -3761,6 +3761,17 @@ class CodeGenerator extends GeneralizingAstVisitor
/// This never uses the library's name (the identifier in the `library`
/// declaration) as it doesn't have any meaningful rules enforced.
String jsLibraryName(LibraryElement library) {
+ var uri = library.source.uri;
+ if (uri.scheme == 'package') {
+ // Strip the package name.
+ // TODO(vsm): This is not unique if an escaped '/'appears in a filename.
+ // E.g., "foo/bar.dart" and "foo$47bar.dart" would collide.
+ var packageRelativePath = uri.pathSegments.skip(1).join('/');
Jennifer Messerly 2016/04/26 22:59:33 Yeah in general it's not going to be unique. Also
+ return pathToJSIdentifier(packageRelativePath);
+ }
+ // TODO(vsm): This is not unique, but we're not in
+ // a package. We need a mechanism for creating a unique library
+ // name.
return pathToJSIdentifier(library.source.uri.pathSegments.last);
}
« no previous file with comments | « no previous file | lib/src/compiler/module_builder.dart » ('j') | lib/src/compiler/module_builder.dart » ('J')

Powered by Google App Engine
This is Rietveld 408576698