Adding package-level breakdown info for dart URIs

Change-Id: If1456ff6e409c44e4fd422d65766013b7161d445
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/235168
Reviewed-by: Sigmund Cherem <sigmund@google.com>
Commit-Queue: Mark Zhou <markzipan@google.com>
diff --git a/pkg/dart2js_info/bin/src/runtime_coverage_analysis.dart b/pkg/dart2js_info/bin/src/runtime_coverage_analysis.dart
index c2fa5f6..53bb655 100644
--- a/pkg/dart2js_info/bin/src/runtime_coverage_analysis.dart
+++ b/pkg/dart2js_info/bin/src/runtime_coverage_analysis.dart
@@ -141,9 +141,9 @@
     var name = qualifiedName(i);
     var used = coverage.contains(name);
 
-    var package = packageNameOrScheme(i);
-    packageData.putIfAbsent(package, () => PackageInfo());
-    packageData[package].add(i, used: used);
+    var groupName = libraryGroupName(i);
+    packageData.putIfAbsent(groupName, () => PackageInfo());
+    packageData[groupName].add(i, used: used);
 
     if (used) {
       usedCode += i.size;
diff --git a/pkg/dart2js_info/lib/src/util.dart b/pkg/dart2js_info/lib/src/util.dart
index 5478ec8..45a10d3 100644
--- a/pkg/dart2js_info/lib/src/util.dart
+++ b/pkg/dart2js_info/lib/src/util.dart
@@ -123,9 +123,11 @@
   return null;
 }
 
-/// Provides the package name associated with [info], the URI scheme if
-/// available, or null otherwise.
-String packageNameOrScheme(Info info) {
+/// Provides the group name associated with [info].
+///
+/// This corresponds to the package name, a Dart core library, 'file' for loose
+/// files, or null otherwise.
+String libraryGroupName(Info info) {
   while (info.parent != null) {
     info = info.parent;
   }
@@ -133,6 +135,9 @@
     if (info.uri.isScheme('package')) {
       return '${info.uri}'.split('/').first;
     }
+    if (info.uri.isScheme('dart')) {
+      return 'dart:${info.uri.path}';
+    }
     if (info.uri.hasScheme) {
       return info.uri.scheme;
     }