[dart2js_info] Update pubspec to 3.7 and reformat.
Change-Id: I2e3eb18c9bc515d96efa6f454d092f66a63c7090
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/400720
Auto-Submit: Mayank Patke <fishythefish@google.com>
Reviewed-by: Nate Biggs <natebiggs@google.com>
Commit-Queue: Nate Biggs <natebiggs@google.com>
Commit-Queue: Mayank Patke <fishythefish@google.com>
diff --git a/pkg/dart2js_info/bin/src/code_deps.dart b/pkg/dart2js_info/bin/src/code_deps.dart
index 3b7f3b35..c412137 100644
--- a/pkg/dart2js_info/bin/src/code_deps.dart
+++ b/pkg/dart2js_info/bin/src/code_deps.dart
@@ -57,17 +57,21 @@
void run() async {
var args = argResults!.rest;
if (args.length < 3) {
- usageException("Missing arguments for some_path, expected: "
- "info.data <element-regexp-1> <element-regexp-2>");
+ usageException(
+ "Missing arguments for some_path, expected: "
+ "info.data <element-regexp-1> <element-regexp-2>",
+ );
}
var info = await infoFromFile(args.first);
var graph = graphFromInfo(info);
- final source =
- info.functions.firstWhereOrNull(_longNameMatcher(RegExp(args[1])));
- final target =
- info.functions.firstWhereOrNull(_longNameMatcher(RegExp(args[2])));
+ final source = info.functions.firstWhereOrNull(
+ _longNameMatcher(RegExp(args[1])),
+ );
+ final target = info.functions.firstWhereOrNull(
+ _longNameMatcher(RegExp(args[2])),
+ );
print('query: some_path');
if (source == null) {
usageException("source '${args[1]}' not found in '${args[0]}'");
diff --git a/pkg/dart2js_info/bin/src/common_command.dart b/pkg/dart2js_info/bin/src/common_command.dart
index a96826f..d9d8df0 100644
--- a/pkg/dart2js_info/bin/src/common_command.dart
+++ b/pkg/dart2js_info/bin/src/common_command.dart
@@ -19,20 +19,29 @@
"See code element commonalities between two dump-info files.";
CommonCommand() {
- argParser.addFlag('packages-only',
- defaultsTo: false,
- help: "Show only packages in common. "
- "Cannot be used with `main-only`.");
- argParser.addFlag('order-by-size',
- defaultsTo: false,
- help: "Show output ordered by size in bytes (decreasing). "
- "If there are size discrepancies, orders by the first "
- "dump-info file's reported size.");
- argParser.addFlag('main-only',
- defaultsTo: false,
- help: "Only shows output comparison for main output unit. Provides "
- "results by class and member rather than by library. "
- "Cannot be used with `packages-only`.");
+ argParser.addFlag(
+ 'packages-only',
+ defaultsTo: false,
+ help:
+ "Show only packages in common. "
+ "Cannot be used with `main-only`.",
+ );
+ argParser.addFlag(
+ 'order-by-size',
+ defaultsTo: false,
+ help:
+ "Show output ordered by size in bytes (decreasing). "
+ "If there are size discrepancies, orders by the first "
+ "dump-info file's reported size.",
+ );
+ argParser.addFlag(
+ 'main-only',
+ defaultsTo: false,
+ help:
+ "Only shows output comparison for main output unit. Provides "
+ "results by class and member rather than by library. "
+ "Cannot be used with `packages-only`.",
+ );
}
@override
@@ -41,7 +50,8 @@
final args = argRes.rest;
if (args.length < 2) {
usageException(
- 'Missing arguments, expected two dump-info files to compare');
+ 'Missing arguments, expected two dump-info files to compare',
+ );
}
var oldInfo = await infoFromFile(args[0]);
@@ -51,11 +61,15 @@
bool mainOnly = argRes['main-only'];
if (packagesOnly && mainOnly) {
throw ArgumentError(
- 'Only one of `main-only` and `packages-only` can be provided.');
+ 'Only one of `main-only` and `packages-only` can be provided.',
+ );
}
- var commonElements =
- findCommonalities(oldInfo, newInfo, mainOnly: mainOnly);
+ var commonElements = findCommonalities(
+ oldInfo,
+ newInfo,
+ mainOnly: mainOnly,
+ );
if (packagesOnly) {
reportPackages(commonElements, orderBySize: orderBySize);
@@ -78,10 +92,12 @@
}
}
- _section('COMMON ELEMENTS',
- elementCount: commonElements.length,
- oldSizeTotal: oldSizeTotal,
- newSizeTotal: newSizeTotal);
+ _section(
+ 'COMMON ELEMENTS',
+ elementCount: commonElements.length,
+ oldSizeTotal: oldSizeTotal,
+ newSizeTotal: newSizeTotal,
+ );
if (orderBySize) {
commonElements.sort((a, b) => b.oldInfo.size.compareTo(a.oldInfo.size));
@@ -95,8 +111,10 @@
if (oldSize == newSize) {
print('${element.name}: ${element.oldInfo.size} bytes');
} else {
- print('${element.name}: ${element.oldInfo.size} -> '
- '${element.newInfo.size} bytes');
+ print(
+ '${element.name}: ${element.oldInfo.size} -> '
+ '${element.newInfo.size} bytes',
+ );
}
}
}
@@ -128,10 +146,12 @@
newSizeTotal += newPackageSize;
});
- _section('COMMON ELEMENTS (PACKAGES)',
- elementCount: oldPackageInfo.keys.length,
- oldSizeTotal: oldSizeTotal,
- newSizeTotal: newSizeTotal);
+ _section(
+ 'COMMON ELEMENTS (PACKAGES)',
+ elementCount: oldPackageInfo.keys.length,
+ oldSizeTotal: oldSizeTotal,
+ newSizeTotal: newSizeTotal,
+ );
var packageInfoEntries = oldPackageInfo.entries.toList();
@@ -152,15 +172,19 @@
}
}
-void _section(String title,
- {required int elementCount,
- required int oldSizeTotal,
- required int newSizeTotal}) {
+void _section(
+ String title, {
+ required int elementCount,
+ required int oldSizeTotal,
+ required int newSizeTotal,
+}) {
if (oldSizeTotal == newSizeTotal) {
print('$title ($elementCount common elements, $oldSizeTotal bytes)');
} else {
- print('$title ($elementCount common elements, '
- '$oldSizeTotal bytes -> $newSizeTotal bytes)');
+ print(
+ '$title ($elementCount common elements, '
+ '$oldSizeTotal bytes -> $newSizeTotal bytes)',
+ );
}
print('=' * 72);
}
diff --git a/pkg/dart2js_info/bin/src/convert.dart b/pkg/dart2js_info/bin/src/convert.dart
index 6abb135..595e8c8 100644
--- a/pkg/dart2js_info/bin/src/convert.dart
+++ b/pkg/dart2js_info/bin/src/convert.dart
@@ -25,16 +25,22 @@
void _addSubcommand(Command<void> command) {
addSubcommand(command);
command.argParser
- ..addOption('out',
- abbr: 'o',
- help: 'Output file '
- '(to_json defauts to <input>.json, to_binary defaults to\n'
- '<input>.data, and to_proto defaults to <input>.pb)')
- ..addFlag('inject-text',
- negatable: false,
- help: 'Whether to inject output code snippets.\n\n'
- 'By default dart2js produces code spans, but excludes the text. This\n'
- 'option can be used to embed the text directly in the output.\n'
- 'Note: this requires access to dart2js output files.\n');
+ ..addOption(
+ 'out',
+ abbr: 'o',
+ help:
+ 'Output file '
+ '(to_json defauts to <input>.json, to_binary defaults to\n'
+ '<input>.data, and to_proto defaults to <input>.pb)',
+ )
+ ..addFlag(
+ 'inject-text',
+ negatable: false,
+ help:
+ 'Whether to inject output code snippets.\n\n'
+ 'By default dart2js produces code spans, but excludes the text. This\n'
+ 'option can be used to embed the text directly in the output.\n'
+ 'Note: this requires access to dart2js output files.\n',
+ );
}
}
diff --git a/pkg/dart2js_info/bin/src/coverage_log_server.dart b/pkg/dart2js_info/bin/src/coverage_log_server.dart
index c1c4ad4..9041f0a 100644
--- a/pkg/dart2js_info/bin/src/coverage_log_server.dart
+++ b/pkg/dart2js_info/bin/src/coverage_log_server.dart
@@ -41,16 +41,24 @@
CoverageLogServerCommand() {
argParser
..addOption('port', abbr: 'p', help: 'port number', defaultsTo: "8080")
- ..addOption('host',
- help: 'host name (use 0.0.0.0 for all interfaces)',
- defaultsTo: 'localhost')
- ..addOption('uri-prefix',
- help:
- 'uri path prefix that will hit this server. This will be injected'
- ' into the .js file',
- defaultsTo: '')
- ..addOption('out',
- abbr: 'o', help: 'output log file', defaultsTo: _defaultOutTemplate);
+ ..addOption(
+ 'host',
+ help: 'host name (use 0.0.0.0 for all interfaces)',
+ defaultsTo: 'localhost',
+ )
+ ..addOption(
+ 'uri-prefix',
+ help:
+ 'uri path prefix that will hit this server. This will be injected'
+ ' into the .js file',
+ defaultsTo: '',
+ )
+ ..addOption(
+ 'out',
+ abbr: 'o',
+ help: 'output log file',
+ defaultsTo: _defaultOutTemplate,
+ );
}
@override
@@ -67,8 +75,14 @@
}
var outPath = args['out'];
if (outPath == _defaultOutTemplate) outPath = '$jsPath.coverage.json';
- var server = _Server(args['host'], int.parse(args['port']), jsPath,
- htmlPath, outPath, args['uri-prefix']);
+ var server = _Server(
+ args['host'],
+ int.parse(args['port']),
+ jsPath,
+ htmlPath,
+ outPath,
+ args['uri-prefix'],
+ );
await server.run();
}
}
@@ -108,19 +122,26 @@
String get _serializedData => JsonEncoder.withIndent(' ').convert(data);
- _Server(this.hostname, this.port, this.jsPath, this.htmlPath, this.outPath,
- String prefix)
- : jsCode = _adjustRequestUrl(File(jsPath).readAsStringSync(), prefix),
- prefix = _normalize(prefix);
+ _Server(
+ this.hostname,
+ this.port,
+ this.jsPath,
+ this.htmlPath,
+ this.outPath,
+ String prefix,
+ ) : jsCode = _adjustRequestUrl(File(jsPath).readAsStringSync(), prefix),
+ prefix = _normalize(prefix);
Future<void> run() async {
await shelf.serve(_handler, hostname, port);
var urlBase = "http://$hostname:$port${prefix == '' ? '/' : '/$prefix/'}";
var htmlFilename = htmlPath == null ? '' : path.basename(htmlPath!);
- print("Server is listening\n"
- " - html page: $urlBase$htmlFilename\n"
- " - js code: $urlBase${path.basename(jsPath)}\n"
- " - coverage reporting: ${urlBase}coverage\n");
+ print(
+ "Server is listening\n"
+ " - html page: $urlBase$htmlFilename\n"
+ " - js code: $urlBase${path.basename(jsPath)}\n"
+ " - coverage reporting: ${urlBase}coverage\n",
+ );
}
String _expectedPath(String tail) => prefix == '' ? tail : '$prefix/$tail';
@@ -136,9 +157,10 @@
if (urlPath == prefix ||
urlPath == '$prefix/' ||
urlPath == _expectedPath(baseHtmlName)) {
- var contents = htmlPath == null
- ? '<html><script src="$baseJsName"></script>'
- : await File(htmlPath!).readAsString();
+ var contents =
+ htmlPath == null
+ ? '<html><script src="$baseJsName"></script>'
+ : await File(htmlPath!).readAsString();
return shelf.Response.ok(contents, headers: _htmlHeaders);
}
@@ -180,9 +202,11 @@
await Future.delayed(Duration(seconds: 3));
await File(outPath).writeAsString(_serializedData);
var diff = data.length - _total;
- print(diff == 0
- ? ' - no new element covered'
- : ' - $diff new elements covered');
+ print(
+ diff == 0
+ ? ' - no new element covered'
+ : ' - $diff new elements covered',
+ );
_savePending = false;
_total = data.length;
}
diff --git a/pkg/dart2js_info/bin/src/debug_info.dart b/pkg/dart2js_info/bin/src/debug_info.dart
index 90ba3c2..6489979 100644
--- a/pkg/dart2js_info/bin/src/debug_info.dart
+++ b/pkg/dart2js_info/bin/src/debug_info.dart
@@ -21,8 +21,10 @@
final String description = "Dart2js-team diagnostics on a dump-info file.";
DebugCommand() {
- argParser.addOption('show-library',
- help: "Show detailed data for a library with the given name");
+ argParser.addOption(
+ 'show-library',
+ help: "Show detailed data for a library with the given name",
+ );
}
@override
@@ -58,12 +60,16 @@
_pass('all fields and functions are covered');
} else {
if (diff1.isNotEmpty) {
- _fail("some elements where listed globally that weren't part of any "
- "library (non-zero ${diff1.where((f) => f.size > 0).length})");
+ _fail(
+ "some elements where listed globally that weren't part of any "
+ "library (non-zero ${diff1.where((f) => f.size > 0).length})",
+ );
}
if (diff2.isNotEmpty) {
- _fail("some elements found in libraries weren't part of the global list"
- " (non-zero ${diff2.where((f) => f.size > 0).length})");
+ _fail(
+ "some elements found in libraries weren't part of the global list"
+ " (non-zero ${diff2.where((f) => f.size > 0).length})",
+ );
}
}
@@ -74,10 +80,13 @@
int accounted = totalLib + constantsSize;
if (accounted != realTotal) {
- var percent =
- ((realTotal - accounted) * 100 / realTotal).toStringAsFixed(2);
- _fail('$percent% size missing: $accounted (all libs + consts) '
- '< $realTotal (total)');
+ var percent = ((realTotal - accounted) * 100 / realTotal).toStringAsFixed(
+ 2,
+ );
+ _fail(
+ '$percent% size missing: $accounted (all libs + consts) '
+ '< $realTotal (total)',
+ );
}
int missingTotal = tracker.missing.values.fold(0, (a, b) => a + b);
if (missingTotal > 0) {
@@ -161,7 +170,7 @@
bool _debug = false;
@override
void visitLibrary(LibraryInfo info) {
- if (_debugLibName != null) _debug = info.name.contains(_debugLibName!);
+ if (_debugLibName != null) _debug = info.name.contains(_debugLibName);
_push();
if (_debug) {
_debugCode.write('{\n');
@@ -317,9 +326,11 @@
if (inUsesNotInDependencies == 0 && inDependenciesNotInUses == 0) {
_pass('dependency data is consistent');
} else {
- _fail('inconsistencies in dependency data:\n'
- ' $inUsesNotInDependencies edges missing from "dependencies" graph\n'
- ' $inDependenciesNotInUses edges missing from "uses" graph');
+ _fail(
+ 'inconsistencies in dependency data:\n'
+ ' $inUsesNotInDependencies edges missing from "dependencies" graph\n'
+ ' $inDependenciesNotInUses edges missing from "uses" graph',
+ );
}
}
@@ -331,11 +342,14 @@
var reachables = Set.from(graph.preOrder(entrypoint));
var functionsAndFields = <BasicInfo>[...info.functions, ...info.fields];
- var unreachables =
- functionsAndFields.where((func) => !reachables.contains(func));
+ var unreachables = functionsAndFields.where(
+ (func) => !reachables.contains(func),
+ );
if (unreachables.isNotEmpty) {
- _fail('${unreachables.length} elements are unreachable from the '
- 'entrypoint');
+ _fail(
+ '${unreachables.length} elements are unreachable from the '
+ 'entrypoint',
+ );
} else {
_pass('all elements are reachable from the entrypoint');
}
diff --git a/pkg/dart2js_info/bin/src/deferred_library_layout.dart b/pkg/dart2js_info/bin/src/deferred_library_layout.dart
index 4fcb488..2705540 100644
--- a/pkg/dart2js_info/bin/src/deferred_library_layout.dart
+++ b/pkg/dart2js_info/bin/src/deferred_library_layout.dart
@@ -64,9 +64,10 @@
print(' contains:');
map.forEach((lib, elements) {
final uri = lib.uri;
- final shortUri = (uri.isScheme('file') && uri.path.startsWith(dir))
- ? uri.path.substring(dir.length + 1)
- : '$uri';
+ final shortUri =
+ (uri.isScheme('file') && uri.path.startsWith(dir))
+ ? uri.path.substring(dir.length + 1)
+ : '$uri';
// If the entire library is in one chunk, just report the library name
// otherwise report which functions are on this chunk.
diff --git a/pkg/dart2js_info/bin/src/deferred_library_size.dart b/pkg/dart2js_info/bin/src/deferred_library_size.dart
index 2bba6f7..313627f 100644
--- a/pkg/dart2js_info/bin/src/deferred_library_size.dart
+++ b/pkg/dart2js_info/bin/src/deferred_library_size.dart
@@ -52,12 +52,16 @@
});
// Sort by size, largest first.
importSizes.sort((a, b) => b.size - a.size);
- int longest = importSizes.fold('Percent of code deferred'.length,
- (longest, importSize) => max(longest, importSize.import.length));
+ int longest = importSizes.fold(
+ 'Percent of code deferred'.length,
+ (longest, importSize) => max(longest, importSize.import.length),
+ );
void printRow(label, data, {int width = 15}) {
- print('${label.toString().padRight(longest + 1)}'
- '${data.toString().padLeft(width)}');
+ print(
+ '${label.toString().padRight(longest + 1)}'
+ '${data.toString().padLeft(width)}',
+ );
}
print('');
@@ -84,8 +88,11 @@
sizeByImport['main'] = outputUnit.size;
} else {
for (final import in outputUnit.imports) {
- sizeByImport.update(import, (value) => value + outputUnit.size,
- ifAbsent: () => outputUnit.size);
+ sizeByImport.update(
+ import,
+ (value) => value + outputUnit.size,
+ ifAbsent: () => outputUnit.size,
+ );
}
}
}
diff --git a/pkg/dart2js_info/bin/src/diff.dart b/pkg/dart2js_info/bin/src/diff.dart
index e601360..a902cf2 100644
--- a/pkg/dart2js_info/bin/src/diff.dart
+++ b/pkg/dart2js_info/bin/src/diff.dart
@@ -19,13 +19,16 @@
"See code size differences between two dump-info files.";
DiffCommand() {
- argParser.addFlag('summary-only',
- defaultsTo: false,
- help: "Show only a summary and hide details of each library");
- argParser.addFlag('main-only',
- defaultsTo: false,
- help:
- "Only includes diffs where the entity is in the main output unit.");
+ argParser.addFlag(
+ 'summary-only',
+ defaultsTo: false,
+ help: "Show only a summary and hide details of each library",
+ );
+ argParser.addFlag(
+ 'main-only',
+ defaultsTo: false,
+ help: "Only includes diffs where the entity is in the main output unit.",
+ );
}
@override
@@ -34,7 +37,8 @@
var args = argRes.rest;
if (args.length < 2) {
usageException(
- 'Missing arguments, expected two dump-info files to compare');
+ 'Missing arguments, expected two dump-info files to compare',
+ );
}
final oldInfo = await infoFromFile(args[0]);
@@ -110,25 +114,42 @@
}
totalSizes[sizeChanges] = totalSizeChange;
- reportSummary(oldInfo, newInfo, adds, removals, sizeChanges, becameDeferred,
- becameUndeferred, totalSizes);
+ reportSummary(
+ oldInfo,
+ newInfo,
+ adds,
+ removals,
+ sizeChanges,
+ becameDeferred,
+ becameUndeferred,
+ totalSizes,
+ );
if (!summaryOnly) {
print('');
- reportFull(oldInfo, newInfo, adds, removals, sizeChanges, becameDeferred,
- becameUndeferred, totalSizes);
+ reportFull(
+ oldInfo,
+ newInfo,
+ adds,
+ removals,
+ sizeChanges,
+ becameDeferred,
+ becameUndeferred,
+ totalSizes,
+ );
}
}
}
void reportSummary(
- AllInfo oldInfo,
- AllInfo newInfo,
- List<AddDiff> adds,
- List<RemoveDiff> removals,
- List<SizeDiff> sizeChanges,
- List<DeferredStatusDiff> becameDeferred,
- List<DeferredStatusDiff> becameUndeferred,
- Map<List<Diff>, int> totalSizes) {
+ AllInfo oldInfo,
+ AllInfo newInfo,
+ List<AddDiff> adds,
+ List<RemoveDiff> removals,
+ List<SizeDiff> sizeChanges,
+ List<DeferredStatusDiff> becameDeferred,
+ List<DeferredStatusDiff> becameUndeferred,
+ Map<List<Diff>, int> totalSizes,
+) {
var overallSizeDiff = newInfo.program!.size - oldInfo.program!.size;
print('total_size_difference $overallSizeDiff');
@@ -140,14 +161,15 @@
}
void reportFull(
- AllInfo oldInfo,
- AllInfo newInfo,
- List<AddDiff> adds,
- List<RemoveDiff> removals,
- List<SizeDiff> sizeChanges,
- List<DeferredStatusDiff> becameDeferred,
- List<DeferredStatusDiff> becameUndeferred,
- Map<List<Diff>, int> totalSizes) {
+ AllInfo oldInfo,
+ AllInfo newInfo,
+ List<AddDiff> adds,
+ List<RemoveDiff> removals,
+ List<SizeDiff> sizeChanges,
+ List<DeferredStatusDiff> becameDeferred,
+ List<DeferredStatusDiff> becameUndeferred,
+ Map<List<Diff>, int> totalSizes,
+) {
// TODO(het): Improve this output. Siggi has good suggestions in
// https://github.com/dart-lang/dart2js_info/pull/19
@@ -159,29 +181,37 @@
_section('REMOVED', size: totalSizes[removals]);
for (var removal in removals) {
- print('${longName(removal.info, useLibraryUri: true)}: '
- '${removal.info.size} bytes');
+ print(
+ '${longName(removal.info, useLibraryUri: true)}: '
+ '${removal.info.size} bytes',
+ );
}
print('');
_section('CHANGED SIZE', size: totalSizes[sizeChanges]);
for (var sizeChange in sizeChanges) {
- print('${longName(sizeChange.info, useLibraryUri: true)}: '
- '${sizeChange.sizeDifference} bytes');
+ print(
+ '${longName(sizeChange.info, useLibraryUri: true)}: '
+ '${sizeChange.sizeDifference} bytes',
+ );
}
print('');
_section('BECAME DEFERRED', size: totalSizes[becameDeferred]);
for (var diff in becameDeferred) {
- print('${longName(diff.info, useLibraryUri: true)}: '
- '${diff.info.size} bytes');
+ print(
+ '${longName(diff.info, useLibraryUri: true)}: '
+ '${diff.info.size} bytes',
+ );
}
print('');
_section('NO LONGER DEFERRED', size: totalSizes[becameUndeferred]);
for (var diff in becameUndeferred) {
- print('${longName(diff.info, useLibraryUri: true)}: '
- '${diff.info.size} bytes');
+ print(
+ '${longName(diff.info, useLibraryUri: true)}: '
+ '${diff.info.size} bytes',
+ );
}
}
diff --git a/pkg/dart2js_info/bin/src/function_size_analysis.dart b/pkg/dart2js_info/bin/src/function_size_analysis.dart
index e02ebbe..109a835 100644
--- a/pkg/dart2js_info/bin/src/function_size_analysis.dart
+++ b/pkg/dart2js_info/bin/src/function_size_analysis.dart
@@ -33,13 +33,16 @@
}
}
-void showCodeDistribution(AllInfo info,
- {bool Function(Info info)? filter, bool showLibrarySizes = false}) {
+void showCodeDistribution(
+ AllInfo info, {
+ bool Function(Info info)? filter,
+ bool showLibrarySizes = false,
+}) {
var realTotal = info.program!.size;
filter ??= (i) => true;
var reported = <BasicInfo>[
...info.functions.where(filter),
- ...info.fields.where(filter)
+ ...info.fields.where(filter),
];
// Compute a graph from the dependencies in [info].
@@ -68,8 +71,10 @@
nodeData[f] = sccData;
}
}
- print('scc sizes: min: $minS, max: $maxS, '
- 'avg ${totalCount / components.length}');
+ print(
+ 'scc sizes: min: $minS, max: $maxS, '
+ 'avg ${totalCount / components.length}',
+ );
// Compute a dominator tree and calculate the size dominated by each element.
// TODO(sigmund): we need a more reliable way to fetch main.
@@ -91,11 +96,13 @@
for (var n in reported) {
dominatedSize.putIfAbsent(n, () => n.size);
}
- reported.sort((a, b) =>
- // ignore: avoid_dynamic_calls
- (dominatedSize[b] + nodeData[b].maxSize) -
- // ignore: avoid_dynamic_calls
- (dominatedSize[a] + nodeData[a].maxSize));
+ reported.sort(
+ (a, b) =>
+ // ignore: avoid_dynamic_calls
+ (dominatedSize[b] + nodeData[b].maxSize) -
+ // ignore: avoid_dynamic_calls
+ (dominatedSize[a] + nodeData[a].maxSize),
+ );
if (showLibrarySizes) {
print(' --- Results per library ---');
@@ -108,8 +115,11 @@
lib = lib.parent;
}
if (lib == null) return;
- totals.update(lib as LibraryInfo, (value) => value + size,
- ifAbsent: () => size);
+ totals.update(
+ lib as LibraryInfo,
+ (value) => value + size,
+ ifAbsent: () => size,
+ );
longest = math.max(longest, '${lib.uri}'.length);
}
@@ -129,7 +139,12 @@
// ignore: avoid_dynamic_calls
var max = nodeData[info].maxSize;
_showElement(
- longName(info, useLibraryUri: true), size, min, max, realTotal);
+ longName(info, useLibraryUri: true),
+ size,
+ min,
+ max,
+ realTotal,
+ );
}
}
@@ -156,30 +171,43 @@
}
void _showLibHeader(int namePadding) {
- print(' ${pad("Library", namePadding, right: true)}'
- ' ${pad("bytes", 8)} ${pad("%", 6)}');
+ print(
+ ' ${pad("Library", namePadding, right: true)}'
+ ' ${pad("bytes", 8)} ${pad("%", 6)}',
+ );
}
void _showLib(String msg, int size, int total, int namePadding) {
var percent = (size * 100 / total).toStringAsFixed(2);
- print(' ${pad(msg, namePadding, right: true)}'
- ' ${pad(size, 8)} ${pad(percent, 6)}%');
+ print(
+ ' ${pad(msg, namePadding, right: true)}'
+ ' ${pad(size, 8)} ${pad(percent, 6)}%',
+ );
}
void _showElementHeader() {
- print('${pad("element size", 16)} '
- '${pad("dominated size", 18)} '
- '${pad("reachable size", 18)} '
- 'Element identifier');
+ print(
+ '${pad("element size", 16)} '
+ '${pad("dominated size", 18)} '
+ '${pad("reachable size", 18)} '
+ 'Element identifier',
+ );
}
void _showElement(
- String name, int size, int dominatedSize, int maxSize, int total) {
+ String name,
+ int size,
+ int dominatedSize,
+ int maxSize,
+ int total,
+) {
var percent = (size * 100 / total).toStringAsFixed(2);
var minPercent = (dominatedSize * 100 / total).toStringAsFixed(2);
var maxPercent = (maxSize * 100 / total).toStringAsFixed(2);
- print('${pad(size, 8)} ${pad(percent, 6)}% '
- '${pad(dominatedSize, 10)} ${pad(minPercent, 6)}% '
- '${pad(maxSize, 10)} ${pad(maxPercent, 6)}% '
- '$name');
+ print(
+ '${pad(size, 8)} ${pad(percent, 6)}% '
+ '${pad(dominatedSize, 10)} ${pad(minPercent, 6)}% '
+ '${pad(maxSize, 10)} ${pad(maxPercent, 6)}% '
+ '$name',
+ );
}
diff --git a/pkg/dart2js_info/bin/src/library_size_split.dart b/pkg/dart2js_info/bin/src/library_size_split.dart
index b4c4e93..7a3f16c 100644
--- a/pkg/dart2js_info/bin/src/library_size_split.dart
+++ b/pkg/dart2js_info/bin/src/library_size_split.dart
@@ -79,8 +79,10 @@
final String description = "See breakdown of code size by library.";
LibrarySizeCommand() {
- argParser.addOption('grouping',
- help: 'YAML file specifying how libraries should be grouped.');
+ argParser.addOption(
+ 'grouping',
+ help: 'YAML file specifying how libraries should be grouped.',
+ );
}
@override
@@ -94,14 +96,16 @@
final info = await infoFromFile(args.first);
final groupingFile = argRes['grouping'];
- final groupingText = groupingFile != null
- ? File(groupingFile).readAsStringSync()
- : defaultGrouping;
+ final groupingText =
+ groupingFile != null
+ ? File(groupingFile).readAsStringSync()
+ : defaultGrouping;
final groupingYaml = loadYaml(groupingText);
final groups = [];
for (var group in groupingYaml['groups']) {
- groups.add(_Group(
- group['name'], RegExp(group['regexp']), group['cluster'] ?? 0));
+ groups.add(
+ _Group(group['name'], RegExp(group['regexp']), group['cluster'] ?? 0),
+ );
}
final sizes = {};
@@ -141,11 +145,14 @@
return;
}
- var percent = row.value == realTotal
- ? '100'
- : (row.value * 100 / realTotal).toStringAsFixed(2);
- print(' ${_pad(row.label, longest + 1, right: true)}'
- ' ${_pad(row.value, 8)} ${_pad(percent, 6)}%');
+ var percent =
+ row.value == realTotal
+ ? '100'
+ : (row.value * 100 / realTotal).toStringAsFixed(2);
+ print(
+ ' ${_pad(row.label, longest + 1, right: true)}'
+ ' ${_pad(row.value, 8)} ${_pad(percent, 6)}%',
+ );
}
var lastCluster = 0;
diff --git a/pkg/dart2js_info/bin/src/live_code_size_analysis.dart b/pkg/dart2js_info/bin/src/live_code_size_analysis.dart
index 8196fe0..5a7a22b 100644
--- a/pkg/dart2js_info/bin/src/live_code_size_analysis.dart
+++ b/pkg/dart2js_info/bin/src/live_code_size_analysis.dart
@@ -51,12 +51,17 @@
@override
final String name = "coverage_analysis";
@override
- final String description = "Analyze coverage data collected via the"
+ final String description =
+ "Analyze coverage data collected via the"
" 'coverage_server' command";
LiveCodeAnalysisCommand() {
- argParser.addFlag('verbose',
- abbr: 'v', negatable: false, help: 'Show verbose details.');
+ argParser.addFlag(
+ 'verbose',
+ abbr: 'v',
+ negatable: false,
+ help: 'Show verbose details.',
+ );
}
@override
@@ -125,9 +130,11 @@
// TODO(sigmund): support grouping results by package.
if (verbose) {
print('\nDistribution of code that was not used when running the app:');
- showCodeDistribution(info,
- filter: (f) => !coverage.containsKey(f.coverageId) && f.size > 0,
- showLibrarySizes: true);
+ showCodeDistribution(
+ info,
+ filter: (f) => !coverage.containsKey(f.coverageId) && f.size > 0,
+ showLibrarySizes: true,
+ );
} else {
print('\nUse `-v` to see details about the size of unreachable code');
}
diff --git a/pkg/dart2js_info/bin/src/runtime_coverage_analysis.dart b/pkg/dart2js_info/bin/src/runtime_coverage_analysis.dart
index 8a1435a..f8a0159 100644
--- a/pkg/dart2js_info/bin/src/runtime_coverage_analysis.dart
+++ b/pkg/dart2js_info/bin/src/runtime_coverage_analysis.dart
@@ -49,10 +49,16 @@
final String description = "Analyze runtime coverage data";
RuntimeCoverageAnalysisCommand() {
- argParser.addFlag('show-packages',
- defaultsTo: false, help: "Show coverage details at the package level.");
- argParser.addOption('class-filter',
- defaultsTo: '', help: "Show coverage details filtered by class.");
+ argParser.addFlag(
+ 'show-packages',
+ defaultsTo: false,
+ help: "Show coverage details at the package level.",
+ );
+ argParser.addOption(
+ 'class-filter',
+ defaultsTo: '',
+ help: "Show coverage details filtered by class.",
+ );
}
@override
@@ -76,10 +82,7 @@
}
}
-Future<void> _report(
- String infoFile,
- String coverageFile,
-) async {
+Future<void> _report(String infoFile, String coverageFile) async {
final info = await infoFromFile(infoFile);
final coverageRaw = jsonDecode(File(coverageFile).readAsStringSync());
// The value associated with each coverage item isn't used for now.
@@ -146,10 +149,7 @@
}
/// Generates a report aggregated at the package level.
-Future<void> _reportWithPackages(
- String infoFile,
- String coverageFile,
-) async {
+Future<void> _reportWithPackages(String infoFile, String coverageFile) async {
final info = await infoFromFile(infoFile);
final coverageRaw = jsonDecode(File(coverageFile).readAsStringSync());
// The value associated with each coverage item isn't used for now.
@@ -222,46 +222,58 @@
var packageRatioString = (packageInfo.usedRatio * 100).toStringAsFixed(2);
_leftPadded(
- ' proportion of package used:',
- '${packageInfo.usedSize}/${packageInfo.totalSize} '
- '($packageRatioString%)');
+ ' proportion of package used:',
+ '${packageInfo.usedSize}/${packageInfo.totalSize} '
+ '($packageRatioString%)',
+ );
- var codeRatioString =
- (packageInfo.unusedSize / totalCode * 100).toStringAsFixed(2);
- _leftPadded(' proportion of unused code to all code:',
- '${packageInfo.unusedSize}/$totalCode ($codeRatioString%)');
-
- var unusedCodeRatioString =
- (packageInfo.unusedSize / unusedTotal * 100).toStringAsFixed(2);
- _leftPadded(' proportion of unused code to all unused code:',
- '${packageInfo.unusedSize}/$unusedTotal ($unusedCodeRatioString%)');
-
- var mainUnitPackageRatioString =
- (packageInfo.mainUnitSize / packageInfo.totalSize * 100)
- .toStringAsFixed(2);
+ var codeRatioString = (packageInfo.unusedSize / totalCode * 100)
+ .toStringAsFixed(2);
_leftPadded(
- ' proportion of main unit code to package code:',
- '${packageInfo.mainUnitSize}/${packageInfo.totalSize} '
- '($mainUnitPackageRatioString%)');
+ ' proportion of unused code to all code:',
+ '${packageInfo.unusedSize}/$totalCode ($codeRatioString%)',
+ );
- var unusedMainUnitRatioString =
- (packageInfo.unusedMainUnitSize / packageInfo.mainUnitSize * 100)
- .toStringAsFixed(2);
+ var unusedCodeRatioString = (packageInfo.unusedSize / unusedTotal * 100)
+ .toStringAsFixed(2);
_leftPadded(
- ' proportion of main unit code that is unused:',
- '${packageInfo.unusedMainUnitSize}/${packageInfo.mainUnitSize} '
- '($unusedMainUnitRatioString%)');
+ ' proportion of unused code to all unused code:',
+ '${packageInfo.unusedSize}/$unusedTotal ($unusedCodeRatioString%)',
+ );
+
+ var mainUnitPackageRatioString = (packageInfo.mainUnitSize /
+ packageInfo.totalSize *
+ 100)
+ .toStringAsFixed(2);
+ _leftPadded(
+ ' proportion of main unit code to package code:',
+ '${packageInfo.mainUnitSize}/${packageInfo.totalSize} '
+ '($mainUnitPackageRatioString%)',
+ );
+
+ var unusedMainUnitRatioString = (packageInfo.unusedMainUnitSize /
+ packageInfo.mainUnitSize *
+ 100)
+ .toStringAsFixed(2);
+ _leftPadded(
+ ' proportion of main unit code that is unused:',
+ '${packageInfo.unusedMainUnitSize}/${packageInfo.mainUnitSize} '
+ '($unusedMainUnitRatioString%)',
+ );
print(' package breakdown:');
for (var item in packageInfo.elements.toList()) {
- var percent =
- (item.size * 100 / packageInfo.totalSize).toStringAsFixed(2);
+ var percent = (item.size * 100 / packageInfo.totalSize).toStringAsFixed(
+ 2,
+ );
var name = qualifiedName(item);
var used = coverage.contains(name);
var usedTick = used ? '+' : '-';
var mainUnitTick = item.outputUnit!.name == 'main' ? 'M' : 'D';
- _leftPadded(' [$usedTick$mainUnitTick] ${qualifiedName(item)}:',
- '${item.size} bytes ($percent% of package)');
+ _leftPadded(
+ ' [$usedTick$mainUnitTick] ${qualifiedName(item)}:',
+ '${item.size} bytes ($percent% of package)',
+ );
}
print('');
@@ -270,15 +282,18 @@
/// Generates a report filtered by class.
Future<void> _reportWithClassFilter(
- String infoFile, String coverageFile, String filterFile,
- {bool showUncategorizedClasses = false}) async {
+ String infoFile,
+ String coverageFile,
+ String filterFile, {
+ bool showUncategorizedClasses = false,
+}) async {
final info = await infoFromFile(infoFile);
final coverageRaw = jsonDecode(File(coverageFile).readAsStringSync());
// The value associated with each coverage item isn't used for now.
Set<String> coverage = coverageRaw.keys.toSet();
final classFilterData = {
- for (final info in runtimeInfoFromAngularInfo(filterFile)) info.key: info
+ for (final info in runtimeInfoFromAngularInfo(filterFile)) info.key: info,
};
// Ensure that a used class's super, mixed in, and implemented classes are
@@ -311,8 +326,10 @@
void processInfoForClass(ClassInfo info) {
final name = qualifiedName(info);
final used = coverage.contains(name);
- final nameWithoutPrefix =
- name.substring(name.indexOf(':') + 1, name.length);
+ final nameWithoutPrefix = name.substring(
+ name.indexOf(':') + 1,
+ name.length,
+ );
final runtimeClassInfo = classFilterData[nameWithoutPrefix];
if (runtimeClassInfo == null) {
@@ -376,13 +393,18 @@
_section('Runtime Coverage Breakdown (filtered)', size: unusedTotal);
print('Filtered Breakdown:');
print('Total (count): ${categorizedClasses.length}');
- print('Used (count): $usedProcessedCode '
- '(${usedProcessedCode / categorizedClasses.length * 100}%)');
+ print(
+ 'Used (count): $usedProcessedCode '
+ '(${usedProcessedCode / categorizedClasses.length * 100}%)',
+ );
print('Total (bytes): $filterTotalCode');
- print('Used (bytes): $filterUsedCode '
- '(${filterUsedCode / filterTotalCode * 100}%)');
- for (final runtimeClassInfo in classFilterData.values
- .sortedBy((v) => v.annotated ? (v.used ? v.size : -v.size) : 0)) {
+ print(
+ 'Used (bytes): $filterUsedCode '
+ '(${filterUsedCode / filterTotalCode * 100}%)',
+ );
+ for (final runtimeClassInfo in classFilterData.values.sortedBy(
+ (v) => v.annotated ? (v.used ? v.size : -v.size) : 0,
+ )) {
if (!runtimeClassInfo.annotated) continue;
final classInfo = runtimeClassInfo.info;
final percent = (classInfo.size * 100 / filterTotalCode).toStringAsFixed(2);
@@ -390,14 +412,17 @@
final used = coverage.contains(name);
final usedTick = used ? '+' : '-';
final mainUnitTick = classInfo.outputUnit?.name == 'main' ? 'M' : 'D';
- _leftPadded(' [$usedTick$mainUnitTick] ${qualifiedName(classInfo)}:',
- '${classInfo.size} bytes ($percent% of filtered items)');
+ _leftPadded(
+ ' [$usedTick$mainUnitTick] ${qualifiedName(classInfo)}:',
+ '${classInfo.size} bytes ($percent% of filtered items)',
+ );
}
print('');
print('Unaccounted classes in filter:');
- for (final runtimeClassInfo
- in classFilterData.values.where((v) => !v.annotated)) {
+ for (final runtimeClassInfo in classFilterData.values.where(
+ (v) => !v.annotated,
+ )) {
print(' ${runtimeClassInfo.key}');
}
@@ -413,8 +438,10 @@
final used = coverage.contains(name);
final usedTick = used ? '+' : '-';
final mainUnitTick = info.outputUnit?.name == 'main' ? 'M' : 'D';
- _leftPadded(' [$usedTick$mainUnitTick] $name:',
- '${info.size} bytes ($percent% of program)');
+ _leftPadded(
+ ' [$usedTick$mainUnitTick] $name:',
+ '${info.size} bytes ($percent% of program)',
+ );
}
}
diff --git a/pkg/dart2js_info/bin/src/show_inferred_types.dart b/pkg/dart2js_info/bin/src/show_inferred_types.dart
index f1052c3..b776ccb 100644
--- a/pkg/dart2js_info/bin/src/show_inferred_types.dart
+++ b/pkg/dart2js_info/bin/src/show_inferred_types.dart
@@ -20,8 +20,12 @@
final String description = "Show data inferred by dart2js global inference";
ShowInferredTypesCommand() {
- argParser.addFlag('long-names',
- abbr: 'l', negatable: false, help: 'Show long qualified names.');
+ argParser.addFlag(
+ 'long-names',
+ abbr: 'l',
+ negatable: false,
+ help: 'Show long qualified names.',
+ );
}
@override
@@ -30,14 +34,18 @@
var args = argRes.rest;
if (args.length < 2) {
usageException(
- 'Missing arguments, expected: info.data <function-name-regex>');
+ 'Missing arguments, expected: info.data <function-name-regex>',
+ );
}
await _showInferredTypes(args[0], args[1], argRes['long-names']);
}
}
Future<void> _showInferredTypes(
- String infoFile, String pattern, bool showLongName) async {
+ String infoFile,
+ String pattern,
+ bool showLongName,
+) async {
var info = await infoFromFile(infoFile);
var nameRegExp = RegExp(pattern);
bool matches(e) => nameRegExp.hasMatch(longName(e));
diff --git a/pkg/dart2js_info/bin/src/text_print.dart b/pkg/dart2js_info/bin/src/text_print.dart
index ad6158b..7a13426 100644
--- a/pkg/dart2js_info/bin/src/text_print.dart
+++ b/pkg/dart2js_info/bin/src/text_print.dart
@@ -20,14 +20,20 @@
final String description = "Show a text representation of the info file.";
ShowCommand() {
- argParser.addOption('out',
- abbr: 'o', help: 'Output file (defauts to stdout)');
+ argParser.addOption(
+ 'out',
+ abbr: 'o',
+ help: 'Output file (defauts to stdout)',
+ );
- argParser.addFlag('inject-text',
- negatable: false,
- help: 'Whether to inject output code snippets.\n\n'
- 'By default dart2js produces code spans, but excludes the text. This\n'
- 'option can be used to embed the text directly in the output.');
+ argParser.addFlag(
+ 'inject-text',
+ negatable: false,
+ help:
+ 'Whether to inject output code snippets.\n\n'
+ 'By default dart2js produces code spans, but excludes the text. This\n'
+ 'option can be used to embed the text directly in the output.',
+ );
}
@override
@@ -119,13 +125,17 @@
void visitLibrary(LibraryInfo info) {
_writeBlock('${info.uri}: ${_size(info.size)}', () {
if (info.topLevelFunctions.isNotEmpty) {
- _writeBlock('Top-level functions',
- () => info.topLevelFunctions.forEach(visitFunction));
+ _writeBlock(
+ 'Top-level functions',
+ () => info.topLevelFunctions.forEach(visitFunction),
+ );
buffer.writeln();
}
if (info.topLevelVariables.isNotEmpty) {
- _writeBlock('Top-level variables',
- () => info.topLevelVariables.forEach(visitField));
+ _writeBlock(
+ 'Top-level variables',
+ () => info.topLevelVariables.forEach(visitField),
+ );
buffer.writeln();
}
if (info.classes.isNotEmpty) {
@@ -145,22 +155,27 @@
@override
void visitClass(ClassInfo info) {
_writeBlock(
- '${info.name}: ${_size(info.size)} [${info.outputUnit?.filename}]', () {
- if (info.functions.isNotEmpty) {
- _writeBlock('Methods:', () => info.functions.forEach(visitFunction));
- }
- if (info.fields.isNotEmpty) {
- _writeBlock('Fields:', () => info.fields.forEach(visitField));
- }
- if (info.functions.isNotEmpty || info.fields.isNotEmpty) buffer.writeln();
- });
+ '${info.name}: ${_size(info.size)} [${info.outputUnit?.filename}]',
+ () {
+ if (info.functions.isNotEmpty) {
+ _writeBlock('Methods:', () => info.functions.forEach(visitFunction));
+ }
+ if (info.fields.isNotEmpty) {
+ _writeBlock('Fields:', () => info.fields.forEach(visitField));
+ }
+ if (info.functions.isNotEmpty || info.fields.isNotEmpty) {
+ buffer.writeln();
+ }
+ },
+ );
}
@override
void visitClassType(ClassTypeInfo info) {
_writeBlock(
- '${info.name}: ${_size(info.size)} [${info.outputUnit?.filename}]',
- () {});
+ '${info.name}: ${_size(info.size)} [${info.outputUnit?.filename}]',
+ () {},
+ );
}
@override
@@ -183,24 +198,27 @@
if (info.functionKind == FunctionInfo.TOP_LEVEL_FUNCTION_KIND) {
outputUnitFile = ' [${info.outputUnit?.filename}]';
}
- String params =
- info.parameters.map((p) => "${p.declaredType} ${p.name}").join(', ');
+ String params = info.parameters
+ .map((p) => "${p.declaredType} ${p.name}")
+ .join(', ');
_writeBlock(
- '${info.returnType} ${info.name}($params): ${_size(info.size)}$outputUnitFile',
- () {
- String params = info.parameters.map((p) => p.type).join(', ');
- _writeIndented('declared type: ${info.type}');
- _writeIndented(
- 'inferred type: ${info.inferredReturnType} Function($params)');
- _writeIndented('side effects: ${info.sideEffects}');
- if (injectText) _writeBlock("code:", () => _writeCode(info.code));
- if (info.closures.isNotEmpty) {
- _writeBlock('Closures:', () => info.closures.forEach(visitClosure));
- }
- if (info.uses.isNotEmpty) {
- _writeBlock('Dependencies:', () => info.uses.forEach(showDependency));
- }
- });
+ '${info.returnType} ${info.name}($params): ${_size(info.size)}$outputUnitFile',
+ () {
+ String params = info.parameters.map((p) => p.type).join(', ');
+ _writeIndented('declared type: ${info.type}');
+ _writeIndented(
+ 'inferred type: ${info.inferredReturnType} Function($params)',
+ );
+ _writeIndented('side effects: ${info.sideEffects}');
+ if (injectText) _writeBlock("code:", () => _writeCode(info.code));
+ if (info.closures.isNotEmpty) {
+ _writeBlock('Closures:', () => info.closures.forEach(visitClosure));
+ }
+ if (info.uses.isNotEmpty) {
+ _writeBlock('Dependencies:', () => info.uses.forEach(showDependency));
+ }
+ },
+ );
}
void showDependency(DependencyInfo info) {
diff --git a/pkg/dart2js_info/bin/src/to_devtools_format.dart b/pkg/dart2js_info/bin/src/to_devtools_format.dart
index c538187..4330d1a 100644
--- a/pkg/dart2js_info/bin/src/to_devtools_format.dart
+++ b/pkg/dart2js_info/bin/src/to_devtools_format.dart
@@ -26,8 +26,11 @@
"app size analysis panel.";
DevtoolsFormatCommand() {
- argParser.addOption('out',
- abbr: 'o', help: 'Output treemap.json file (defaults to stdout');
+ argParser.addOption(
+ 'out',
+ abbr: 'o',
+ help: 'Output treemap.json file (defaults to stdout',
+ );
}
@override
@@ -73,8 +76,10 @@
}
if (outputUnits.length == 1) {
- vm.ProgramInfo programInfoTree =
- builder.build(allInfo, outputUnits.keys.first);
+ vm.ProgramInfo programInfoTree = builder.build(
+ allInfo,
+ outputUnits.keys.first,
+ );
Map<String, dynamic> treeMap = treemapFromInfo(programInfoTree);
output = treeMap;
output['n'] = 'Root';
@@ -162,20 +167,26 @@
vm.ProgramInfoNode? packageInfoNode = infoNodesByName[compositePackageName];
if (packageInfoNode == null) {
vm.ProgramInfoNode newPackage = outputUnit.makeNode(
- name: packageName,
- parent: outputUnit.root,
- type: vm.NodeType.packageNode);
+ name: packageName,
+ parent: outputUnit.root,
+ type: vm.NodeType.packageNode,
+ );
newPackage.size = 0;
outputUnit.root.children[compositePackageName] = newPackage;
var packageNode = infoNodesByName[compositePackageName];
- assert(packageNode == null,
- "encountered package with duplicated name: $compositePackageName");
+ assert(
+ packageNode == null,
+ "encountered package with duplicated name: $compositePackageName",
+ );
infoNodesByName[compositePackageName] = newPackage;
/// Add the corresponding [PackageInfo] node in the [AllInfo] tree.
OutputUnitInfo packageUnit = outputUnitInfos[outputUnitName]!;
- PackageInfo newPackageInfo =
- PackageInfo(packageName, packageUnit, newPackage.size!);
+ PackageInfo newPackageInfo = PackageInfo(
+ packageName,
+ packageUnit,
+ newPackage.size!,
+ );
newPackageInfo.libraries.add(libraryInfo);
info.packages.add(newPackageInfo);
}
@@ -184,7 +195,9 @@
/// Aggregates the size of a library [vm.ProgramInfoNode] from the sizes of
/// its top level children in the same output unit.
int collectSizesForOutputUnit(
- Iterable<BasicInfo> infos, String outputUnitName) {
+ Iterable<BasicInfo> infos,
+ String outputUnitName,
+ ) {
int sizes = 0;
for (var info in infos) {
if (info.outputUnit!.filename == outputUnitName) {
@@ -206,21 +219,31 @@
vm.ProgramInfoNode parentNode = infoNodesByName[compositePackageName]!;
String compositeLibraryName = compositeName(libraryName, outputUnitName);
vm.ProgramInfoNode newLibrary = outputUnit.makeNode(
- name: libraryName, parent: parentNode, type: vm.NodeType.libraryNode);
+ name: libraryName,
+ parent: parentNode,
+ type: vm.NodeType.libraryNode,
+ );
newLibrary.size = 0;
- newLibrary.size = (newLibrary.size ?? 0) +
+ newLibrary.size =
+ (newLibrary.size ?? 0) +
collectSizesForOutputUnit(
- libraryInfo.topLevelFunctions, outputUnitName) +
+ libraryInfo.topLevelFunctions,
+ outputUnitName,
+ ) +
collectSizesForOutputUnit(
- libraryInfo.topLevelVariables, outputUnitName) +
+ libraryInfo.topLevelVariables,
+ outputUnitName,
+ ) +
collectSizesForOutputUnit(libraryInfo.classes, outputUnitName) +
collectSizesForOutputUnit(libraryInfo.classTypes, outputUnitName) +
collectSizesForOutputUnit(libraryInfo.typedefs, outputUnitName);
parentNode.children[newLibrary.name] = newLibrary;
parentNode.size = (parentNode.size ?? 0) + newLibrary.size!;
vm.ProgramInfoNode? libraryNode = infoNodesByName[compositeLibraryName];
- assert(libraryNode == null,
- "encountered library with duplicated name: $compositeLibraryName");
+ assert(
+ libraryNode == null,
+ "encountered library with duplicated name: $compositeLibraryName",
+ );
infoNodesByName[compositeLibraryName] = newLibrary;
}
@@ -233,8 +256,10 @@
vm.ProgramInfoNode parentNode;
if (parent.kind == kindFromString('library')) {
if (parent.name == "<unnamed>") {
- var tempName =
- compositeName(unnamedLibraries[parent]!, outputUnitName);
+ var tempName = compositeName(
+ unnamedLibraries[parent]!,
+ outputUnitName,
+ );
parentNode = infoNodesByName[tempName]!;
} else {
parentNode =
@@ -244,14 +269,17 @@
parentNode = infoNodesByName[parent.name]!;
}
vm.ProgramInfoNode newFunction = outputUnit.makeNode(
- name: functionInfo.name,
- parent: parentNode,
- type: vm.NodeType.functionNode);
+ name: functionInfo.name,
+ parent: parentNode,
+ type: vm.NodeType.functionNode,
+ );
newFunction.size = functionInfo.size;
parentNode.children[newFunction.name] = newFunction;
vm.ProgramInfoNode? functionNode = infoNodesByName[newFunction.name];
- assert(functionNode == null,
- "encountered function with duplicated name: $newFunction.name");
+ assert(
+ functionNode == null,
+ "encountered function with duplicated name: $newFunction.name",
+ );
infoNodesByName[newFunction.name] = newFunction;
}
}
@@ -264,8 +292,10 @@
vm.ProgramInfoNode parentNode;
if (parent.kind == kindFromString('library')) {
if (parent.name == "<unnamed>") {
- var tempName =
- compositeName(unnamedLibraries[parent]!, outputUnitName);
+ var tempName = compositeName(
+ unnamedLibraries[parent]!,
+ outputUnitName,
+ );
parentNode = infoNodesByName[tempName]!;
} else {
parentNode =
@@ -275,14 +305,17 @@
parentNode = infoNodesByName[parent.name]!;
}
vm.ProgramInfoNode newClass = outputUnit.makeNode(
- name: classInfo.name,
- parent: parentNode,
- type: vm.NodeType.classNode);
+ name: classInfo.name,
+ parent: parentNode,
+ type: vm.NodeType.classNode,
+ );
newClass.size = classInfo.size;
parentNode.children[newClass.name] = newClass;
vm.ProgramInfoNode? classNode = infoNodesByName[newClass.name];
- assert(classNode == null,
- "encountered class with duplicated name: $newClass.name");
+ assert(
+ classNode == null,
+ "encountered class with duplicated name: $newClass.name",
+ );
infoNodesByName[newClass.name] = newClass;
}
}
@@ -300,8 +333,10 @@
vm.ProgramInfoNode parentNode;
if (parent.kind == kindFromString('library')) {
if (parent.name == "<unnamed>") {
- var tempName =
- compositeName(unnamedLibraries[parent]!, outputUnitName);
+ var tempName = compositeName(
+ unnamedLibraries[parent]!,
+ outputUnitName,
+ );
parentNode = infoNodesByName[tempName]!;
} else {
parentNode =
@@ -311,28 +346,39 @@
parentNode = infoNodesByName[parent.name]!;
}
vm.ProgramInfoNode newField = outputUnit.makeNode(
- name: fieldInfo.name, parent: parentNode, type: vm.NodeType.other);
+ name: fieldInfo.name,
+ parent: parentNode,
+ type: vm.NodeType.other,
+ );
newField.size = fieldInfo.size;
parentNode.children[newField.name] = newField;
vm.ProgramInfoNode? fieldNode = infoNodesByName[newField.name];
- assert(fieldNode == null,
- "encountered field with duplicated name: $newField.name");
+ assert(
+ fieldNode == null,
+ "encountered field with duplicated name: $newField.name",
+ );
infoNodesByName[newField.name] = newField;
}
}
void makeConstant(ConstantInfo constantInfo) {
- String? constantName = constantInfo.code.first.text ??
+ String? constantName =
+ constantInfo.code.first.text ??
"${constantInfo.code.first.start}/${constantInfo.code.first.end}";
String outputUnitName = constantInfo.outputUnit!.filename;
vm.ProgramInfo? outputUnit = outputUnits[outputUnitName];
vm.ProgramInfoNode newConstant = outputUnit!.makeNode(
- name: constantName, parent: outputUnit.root, type: vm.NodeType.other);
+ name: constantName,
+ parent: outputUnit.root,
+ type: vm.NodeType.other,
+ );
newConstant.size = constantInfo.size;
outputUnit.root.children[newConstant.name] = newConstant;
vm.ProgramInfoNode? constantNode = infoNodesByName[newConstant.name];
- assert(constantNode == null,
- "encountered constant with duplicated name: $newConstant.name");
+ assert(
+ constantNode == null,
+ "encountered constant with duplicated name: $newConstant.name",
+ );
infoNodesByName[newConstant.name] = newConstant;
}
@@ -340,13 +386,16 @@
String outputUnitName = typedefInfo.outputUnit!.filename;
vm.ProgramInfo? outputUnit = outputUnits[outputUnitName];
vm.ProgramInfoNode newTypedef = outputUnit!.makeNode(
- name: typedefInfo.name,
- parent: outputUnit.root,
- type: vm.NodeType.other);
+ name: typedefInfo.name,
+ parent: outputUnit.root,
+ type: vm.NodeType.other,
+ );
newTypedef.size = typedefInfo.size;
vm.ProgramInfoNode? typedefNode = infoNodesByName[newTypedef.name];
- assert(typedefNode == null,
- "encountered constant with duplicated name: $newTypedef.name");
+ assert(
+ typedefNode == null,
+ "encountered constant with duplicated name: $newTypedef.name",
+ );
}
void makeClassType(ClassTypeInfo classTypeInfo) {
@@ -364,13 +413,16 @@
infoNodesByName[compositeName(parent.name, outputUnitName)]!;
}
vm.ProgramInfoNode newClassType = outputUnit.makeNode(
- name: classTypeInfo.name,
- parent: parentNode,
- type: vm.NodeType.other);
+ name: classTypeInfo.name,
+ parent: parentNode,
+ type: vm.NodeType.other,
+ );
newClassType.size = classTypeInfo.size;
vm.ProgramInfoNode? classTypeNode = infoNodesByName[newClassType.name];
- assert(classTypeNode == null,
- "encountered classType with duplicated name: $newClassType.name");
+ assert(
+ classTypeNode == null,
+ "encountered classType with duplicated name: $newClassType.name",
+ );
infoNodesByName[newClassType.name] = newClassType;
}
}
@@ -383,8 +435,10 @@
vm.ProgramInfoNode parentNode;
if (parent.kind == kindFromString('library')) {
if (parent.name == "<unnamed>") {
- var tempName =
- compositeName(unnamedLibraries[parent]!, outputUnitName);
+ var tempName = compositeName(
+ unnamedLibraries[parent]!,
+ outputUnitName,
+ );
parentNode = infoNodesByName[tempName]!;
} else {
parentNode =
@@ -394,15 +448,18 @@
parentNode = infoNodesByName[parent.name]!;
}
vm.ProgramInfoNode newClosure = outputUnit.makeNode(
- name: closureInfo.name,
- parent: parentNode,
- // ProgramInfo trees consider closures and functions to both be of the functionNode type.
- type: vm.NodeType.functionNode);
+ name: closureInfo.name,
+ parent: parentNode,
+ // ProgramInfo trees consider closures and functions to both be of the functionNode type.
+ type: vm.NodeType.functionNode,
+ );
newClosure.size = closureInfo.size;
parentNode.children[newClosure.name] = newClosure;
vm.ProgramInfoNode? closureNode = infoNodesByName[newClosure.name];
- assert(closureNode == null,
- "encountered closure with duplicated name: $newClosure.name");
+ assert(
+ closureNode == null,
+ "encountered closure with duplicated name: $newClosure.name",
+ );
infoNodesByName[newClosure.name] = newClosure;
}
}
@@ -456,8 +513,10 @@
info.typedefs.forEach(visitTypedef);
vm.ProgramInfoNode currentLibrary =
infoNodesByName[compositeName(info.name, outputUnitName)] ??
- infoNodesByName[
- compositeName(unnamedLibraries[info]!, outputUnitName)]!;
+ infoNodesByName[compositeName(
+ unnamedLibraries[info]!,
+ outputUnitName,
+ )]!;
return currentLibrary;
}
diff --git a/pkg/dart2js_info/bin/src/to_json.dart b/pkg/dart2js_info/bin/src/to_json.dart
index 1cfb554..a4f1155 100644
--- a/pkg/dart2js_info/bin/src/to_json.dart
+++ b/pkg/dart2js_info/bin/src/to_json.dart
@@ -21,13 +21,16 @@
final String description = "Convert any info file to JSON format.";
ToJsonCommand() {
- argParser.addFlag('compat-mode',
- negatable: false,
- help: 'Whether to generate an older version of the JSON format.\n\n'
- 'By default files are converted to the latest JSON format.\n'
- 'This option enables `--inject-text` as well, but note that\n'
- 'files produced in this mode do not contain all the data\n'
- 'available in the input file.');
+ argParser.addFlag(
+ 'compat-mode',
+ negatable: false,
+ help:
+ 'Whether to generate an older version of the JSON format.\n\n'
+ 'By default files are converted to the latest JSON format.\n'
+ 'This option enables `--inject-text` as well, but note that\n'
+ 'files produced in this mode do not contain all the data\n'
+ 'available in the input file.',
+ );
}
@override
@@ -45,12 +48,14 @@
injectText(info);
}
- var json = AllInfoJsonCodec(isBackwardCompatible: isBackwardCompatible)
- .encode(info);
+ var json = AllInfoJsonCodec(
+ isBackwardCompatible: isBackwardCompatible,
+ ).encode(info);
String outputFilename = args['out'] ?? '$filename.json';
final sink = File(outputFilename).openWrite();
- final converterSink = const JsonEncoder.withIndent(" ")
- .startChunkedConversion(_BufferedStringOutputSink(sink));
+ final converterSink = const JsonEncoder.withIndent(
+ " ",
+ ).startChunkedConversion(_BufferedStringOutputSink(sink));
converterSink.add(json);
converterSink.close();
await sink.close();
diff --git a/pkg/dart2js_info/bin/src/usage_exception.dart b/pkg/dart2js_info/bin/src/usage_exception.dart
index 3222ef4..52696fa 100644
--- a/pkg/dart2js_info/bin/src/usage_exception.dart
+++ b/pkg/dart2js_info/bin/src/usage_exception.dart
@@ -5,7 +5,7 @@
import 'dart:io';
import 'package:args/command_runner.dart';
-abstract class PrintUsageException implements Command<void> {
+mixin PrintUsageException implements Command<void> {
@override
Never usageException(String message) {
print(message);
diff --git a/pkg/dart2js_info/bin/tools.dart b/pkg/dart2js_info/bin/tools.dart
index 75c8b56..15f575a 100644
--- a/pkg/dart2js_info/bin/tools.dart
+++ b/pkg/dart2js_info/bin/tools.dart
@@ -23,23 +23,26 @@
/// Entrypoint to run all dart2js_info tools.
void main(args) {
- var commandRunner = CommandRunner("dart2js_info",
- "collection of tools to digest the output of dart2js's --dump-info")
- ..addCommand(CodeDepsCommand())
- ..addCommand(CommonCommand())
- ..addCommand(CoverageLogServerCommand())
- ..addCommand(DebugCommand())
- ..addCommand(DiffCommand())
- ..addCommand(DeferredLibraryCheck())
- ..addCommand(DeferredLibrarySize())
- ..addCommand(DeferredLibraryLayout())
- ..addCommand(ConvertCommand())
- ..addCommand(FunctionSizeCommand())
- ..addCommand(LibrarySizeCommand())
- ..addCommand(LiveCodeAnalysisCommand())
- ..addCommand(RuntimeCoverageAnalysisCommand())
- ..addCommand(ShowInferredTypesCommand())
- ..addCommand(ShowCommand())
- ..addCommand(DevtoolsFormatCommand());
+ var commandRunner =
+ CommandRunner(
+ "dart2js_info",
+ "collection of tools to digest the output of dart2js's --dump-info",
+ )
+ ..addCommand(CodeDepsCommand())
+ ..addCommand(CommonCommand())
+ ..addCommand(CoverageLogServerCommand())
+ ..addCommand(DebugCommand())
+ ..addCommand(DiffCommand())
+ ..addCommand(DeferredLibraryCheck())
+ ..addCommand(DeferredLibrarySize())
+ ..addCommand(DeferredLibraryLayout())
+ ..addCommand(ConvertCommand())
+ ..addCommand(FunctionSizeCommand())
+ ..addCommand(LibrarySizeCommand())
+ ..addCommand(LiveCodeAnalysisCommand())
+ ..addCommand(RuntimeCoverageAnalysisCommand())
+ ..addCommand(ShowInferredTypesCommand())
+ ..addCommand(ShowCommand())
+ ..addCommand(DevtoolsFormatCommand());
commandRunner.run(args);
}
diff --git a/pkg/dart2js_info/lib/binary_serialization.dart b/pkg/dart2js_info/lib/binary_serialization.dart
index 8f682d1..1d2fda2 100644
--- a/pkg/dart2js_info/lib/binary_serialization.dart
+++ b/pkg/dart2js_info/lib/binary_serialization.dart
@@ -269,8 +269,10 @@
case InfoKind.closure:
return readClosure();
case InfoKind.package:
- throw StateError('Binary serialization is not supported for '
- 'PackageInfo');
+ throw StateError(
+ 'Binary serialization is not supported for '
+ 'PackageInfo',
+ );
}
}
@@ -279,9 +281,11 @@
int version = source.readInt();
int minorVersion = source.readInt();
if (info.version != version || info.minorVersion != minorVersion) {
- print("warning: data was encoded with format version "
- "$version.$minorVersion, but decoded with "
- "${info.version}.${info.minorVersion}");
+ print(
+ "warning: data was encoded with format version "
+ "$version.$minorVersion, but decoded with "
+ "${info.version}.${info.minorVersion}",
+ );
}
info.libraries.addAll(source.readList(readLibrary));
info.classes.addAll(source.readList(readClass));
@@ -344,20 +348,21 @@
final isMirrorsUsed = source.readBool();
final minified = source.readBool();
return ProgramInfo(
- entrypoint: entrypoint,
- size: size,
- ramUsage: ramUsage,
- dart2jsVersion: dart2jsVersion,
- compilationMoment: compilationMoment,
- compilationDuration: compilationDuration,
- toJsonDuration: toJsonDuration,
- dumpInfoDuration: dumpInfoDuration,
- noSuchMethodEnabled: noSuchMethodEnabled,
- isRuntimeTypeUsed: isRuntimeTypeUsed,
- isIsolateInUse: isIsolateInUse,
- isFunctionApplyUsed: isFunctionApplyUsed,
- isMirrorsUsed: isMirrorsUsed,
- minified: minified);
+ entrypoint: entrypoint,
+ size: size,
+ ramUsage: ramUsage,
+ dart2jsVersion: dart2jsVersion,
+ compilationMoment: compilationMoment,
+ compilationDuration: compilationDuration,
+ toJsonDuration: toJsonDuration,
+ dumpInfoDuration: dumpInfoDuration,
+ noSuchMethodEnabled: noSuchMethodEnabled,
+ isRuntimeTypeUsed: isRuntimeTypeUsed,
+ isIsolateInUse: isIsolateInUse,
+ isFunctionApplyUsed: isFunctionApplyUsed,
+ isMirrorsUsed: isMirrorsUsed,
+ minified: minified,
+ );
}
void _readBasicInfo(BasicInfo info) {
@@ -369,60 +374,60 @@
}
LibraryInfo readLibrary() => source.readCached<LibraryInfo>(() {
- LibraryInfo info = LibraryInfo.internal();
- info.uri = source.readUri();
- _readBasicInfo(info);
- info.topLevelFunctions.addAll(source.readList(readFunction));
- info.topLevelVariables.addAll(source.readList(readField));
- info.classes.addAll(source.readList(readClass));
- info.classTypes.addAll(source.readList(readClassType));
- info.typedefs.addAll(source.readList(readTypedef));
+ LibraryInfo info = LibraryInfo.internal();
+ info.uri = source.readUri();
+ _readBasicInfo(info);
+ info.topLevelFunctions.addAll(source.readList(readFunction));
+ info.topLevelVariables.addAll(source.readList(readField));
+ info.classes.addAll(source.readList(readClass));
+ info.classTypes.addAll(source.readList(readClassType));
+ info.typedefs.addAll(source.readList(readTypedef));
- LibraryInfo setParent(BasicInfo child) => child.parent = info;
- info.topLevelFunctions.forEach(setParent);
- info.topLevelVariables.forEach(setParent);
- info.classes.forEach(setParent);
- info.classTypes.forEach(setParent);
- info.typedefs.forEach(setParent);
- return info;
- });
+ LibraryInfo setParent(BasicInfo child) => child.parent = info;
+ info.topLevelFunctions.forEach(setParent);
+ info.topLevelVariables.forEach(setParent);
+ info.classes.forEach(setParent);
+ info.classTypes.forEach(setParent);
+ info.typedefs.forEach(setParent);
+ return info;
+ });
ClassInfo readClass() => source.readCached<ClassInfo>(() {
- ClassInfo info = ClassInfo.internal();
- _readBasicInfo(info);
- info.isAbstract = source.readBool();
- info.fields.addAll(source.readList(readField));
- info.functions.addAll(source.readList(readFunction));
- info.supers.addAll(source.readList(readClass));
+ ClassInfo info = ClassInfo.internal();
+ _readBasicInfo(info);
+ info.isAbstract = source.readBool();
+ info.fields.addAll(source.readList(readField));
+ info.functions.addAll(source.readList(readFunction));
+ info.supers.addAll(source.readList(readClass));
- ClassInfo setParent(BasicInfo child) => child.parent = info;
- info.fields.forEach(setParent);
- info.functions.forEach(setParent);
- return info;
- });
+ ClassInfo setParent(BasicInfo child) => child.parent = info;
+ info.fields.forEach(setParent);
+ info.functions.forEach(setParent);
+ return info;
+ });
ClassTypeInfo readClassType() => source.readCached<ClassTypeInfo>(() {
- var info = ClassTypeInfo.internal();
- _readBasicInfo(info);
- return info;
- });
+ var info = ClassTypeInfo.internal();
+ _readBasicInfo(info);
+ return info;
+ });
FieldInfo readField() => source.readCached<FieldInfo>(() {
- FieldInfo info = FieldInfo.internal();
- _readBasicInfo(info);
- info.closures = source.readList(readClosure);
- info.inferredType = source.readString();
- info.code = source.readList(_readCodeSpan);
- info.type = source.readString();
- info.isConst = source.readBool();
- if (info.isConst) {
- info.initializer = _readConstantOrNull();
- }
- for (var c in info.closures) {
- c.parent = info;
- }
- return info;
- });
+ FieldInfo info = FieldInfo.internal();
+ _readBasicInfo(info);
+ info.closures = source.readList(readClosure);
+ info.inferredType = source.readString();
+ info.code = source.readList(_readCodeSpan);
+ info.type = source.readString();
+ info.isConst = source.readBool();
+ if (info.isConst) {
+ info.initializer = _readConstantOrNull();
+ }
+ for (var c in info.closures) {
+ c.parent = info;
+ }
+ return info;
+ });
CodeSpan _readCodeSpan() {
final start = source.readIntOrNull();
@@ -438,62 +443,66 @@
}
ConstantInfo readConstant() => source.readCached<ConstantInfo>(() {
- ConstantInfo info = ConstantInfo.internal();
- _readBasicInfo(info);
- info.code = source.readList(_readCodeSpan);
- return info;
- });
+ ConstantInfo info = ConstantInfo.internal();
+ _readBasicInfo(info);
+ info.code = source.readList(_readCodeSpan);
+ return info;
+ });
FunctionModifiers _readFunctionModifiers() {
int value = source.readInt();
return FunctionModifiers(
- isStatic: value & _staticMask != 0,
- isConst: value & _constMask != 0,
- isFactory: value & _factoryMask != 0,
- isExternal: value & _externalMask != 0);
+ isStatic: value & _staticMask != 0,
+ isConst: value & _constMask != 0,
+ isFactory: value & _factoryMask != 0,
+ isExternal: value & _externalMask != 0,
+ );
}
ParameterInfo _readParameterInfo() {
return ParameterInfo(
- source.readString(), source.readString(), source.readString());
+ source.readString(),
+ source.readString(),
+ source.readString(),
+ );
}
FunctionInfo readFunction() => source.readCached<FunctionInfo>(() {
- FunctionInfo info = FunctionInfo.internal();
- _readBasicInfo(info);
- info.functionKind = source.readInt();
- info.closures = source.readList(readClosure);
- info.modifiers = _readFunctionModifiers();
- info.returnType = source.readString();
- info.inferredReturnType = source.readString();
- info.parameters = source.readList(_readParameterInfo);
- info.sideEffects = source.readString();
- info.inlinedCount = source.readIntOrNull();
- info.code = source.readList(_readCodeSpan);
- info.type = source.readString();
- for (var c in info.closures) {
- c.parent = info;
- }
- return info;
- });
+ FunctionInfo info = FunctionInfo.internal();
+ _readBasicInfo(info);
+ info.functionKind = source.readInt();
+ info.closures = source.readList(readClosure);
+ info.modifiers = _readFunctionModifiers();
+ info.returnType = source.readString();
+ info.inferredReturnType = source.readString();
+ info.parameters = source.readList(_readParameterInfo);
+ info.sideEffects = source.readString();
+ info.inlinedCount = source.readIntOrNull();
+ info.code = source.readList(_readCodeSpan);
+ info.type = source.readString();
+ for (var c in info.closures) {
+ c.parent = info;
+ }
+ return info;
+ });
DependencyInfo _readDependencyInfo() =>
DependencyInfo(readInfoWithKind(), source.readStringOrNull());
ClosureInfo readClosure() => source.readCached<ClosureInfo>(() {
- ClosureInfo info = ClosureInfo.internal();
- _readBasicInfo(info);
- info.function = readFunction();
- info.function.parent = info;
- return info;
- });
+ ClosureInfo info = ClosureInfo.internal();
+ _readBasicInfo(info);
+ info.function = readFunction();
+ info.function.parent = info;
+ return info;
+ });
TypedefInfo readTypedef() => source.readCached<TypedefInfo>(() {
- TypedefInfo info = TypedefInfo.internal();
- _readBasicInfo(info);
- info.type = source.readString();
- return info;
- });
+ TypedefInfo info = TypedefInfo.internal();
+ _readBasicInfo(info);
+ info.type = source.readString();
+ return info;
+ });
OutputUnitInfo? _readOutputOrNull() {
bool hasOutput = source.readBool();
@@ -502,12 +511,12 @@
}
OutputUnitInfo readOutput() => source.readCached<OutputUnitInfo>(() {
- OutputUnitInfo info = OutputUnitInfo.internal();
- _readBasicInfo(info);
- info.filename = source.readString();
- info.imports.addAll(source.readList(source.readString));
- return info;
- });
+ OutputUnitInfo info = OutputUnitInfo.internal();
+ _readBasicInfo(info);
+ info.filename = source.readString();
+ info.imports.addAll(source.readList(source.readString));
+ return info;
+ });
}
const int _staticMask = 1 << 3;
diff --git a/pkg/dart2js_info/lib/deferred_library_check.dart b/pkg/dart2js_info/lib/deferred_library_check.dart
index 1f4aa40..006e6c3 100644
--- a/pkg/dart2js_info/lib/deferred_library_check.dart
+++ b/pkg/dart2js_info/lib/deferred_library_check.dart
@@ -41,7 +41,9 @@
import 'info.dart';
List<ManifestComplianceFailure> checkDeferredLibraryManifest(
- AllInfo info, Map manifest) {
+ AllInfo info,
+ Map manifest,
+) {
var includedPackages = <String, Set<String>>{};
var excludedPackages = <String, Set<String>>{};
for (var part in manifest.keys) {
@@ -65,11 +67,11 @@
'main',
...info.outputUnits
.where((unit) => unit.imports.length == 1)
- .map((unit) => unit.imports.single)
+ .map((unit) => unit.imports.single),
];
List<String> mentionedParts = [
...includedPackages.keys,
- ...excludedPackages.keys
+ ...excludedPackages.keys,
];
var partNameFailures = <_InvalidPartName>[];
for (var part in mentionedParts) {
@@ -83,7 +85,7 @@
var mentionedPackages = {
for (var values in includedPackages.values) ...values,
- for (var values in excludedPackages.values) ...values
+ for (var values in excludedPackages.values) ...values,
};
var actualIncludedPackages = <String, Set<String>>{};
diff --git a/pkg/dart2js_info/lib/info.dart b/pkg/dart2js_info/lib/info.dart
index a5f98b9..aadd2cb 100644
--- a/pkg/dart2js_info/lib/info.dart
+++ b/pkg/dart2js_info/lib/info.dart
@@ -68,7 +68,7 @@
/// Info associated with elements containing executable code (like fields and
/// methods)
-abstract class CodeInfo implements Info {
+mixin CodeInfo implements Info {
/// How does this function or field depend on others.
List<DependencyInfo> uses = [];
}
@@ -169,21 +169,22 @@
final bool minified;
- ProgramInfo(
- {required this.entrypoint,
- required this.ramUsage,
- required this.size,
- required this.dart2jsVersion,
- required this.compilationMoment,
- required this.compilationDuration,
- required this.toJsonDuration,
- required this.dumpInfoDuration,
- required this.noSuchMethodEnabled,
- required this.isRuntimeTypeUsed,
- required this.isIsolateInUse,
- required this.isFunctionApplyUsed,
- this.isMirrorsUsed = false,
- required this.minified});
+ ProgramInfo({
+ required this.entrypoint,
+ required this.ramUsage,
+ required this.size,
+ required this.dart2jsVersion,
+ required this.compilationMoment,
+ required this.compilationDuration,
+ required this.toJsonDuration,
+ required this.dumpInfoDuration,
+ required this.noSuchMethodEnabled,
+ required this.isRuntimeTypeUsed,
+ required this.isIsolateInUse,
+ required this.isFunctionApplyUsed,
+ this.isMirrorsUsed = false,
+ required this.minified,
+ });
T accept<T>(InfoVisitor<T> visitor) => visitor.visitProgram(this);
}
@@ -197,7 +198,7 @@
List<LibraryInfo> libraries = <LibraryInfo>[];
PackageInfo(String name, OutputUnitInfo outputUnit, int size)
- : super(InfoKind.package, name, outputUnit, size, null);
+ : super(InfoKind.package, name, outputUnit, size, null);
@override
T accept<T>(InfoVisitor<T> visitor) =>
@@ -236,7 +237,7 @@
classTypes.isEmpty;
LibraryInfo(String name, this.uri, OutputUnitInfo? outputUnit, int size)
- : super(InfoKind.library, name, outputUnit, size, null);
+ : super(InfoKind.library, name, outputUnit, size, null);
LibraryInfo.internal() : super.internal(InfoKind.library);
@@ -254,7 +255,7 @@
final List<String> imports = <String>[];
OutputUnitInfo(this.filename, String name, int size)
- : super(InfoKind.outputUnit, name, null, size, null);
+ : super(InfoKind.outputUnit, name, null, size, null);
OutputUnitInfo.internal() : super.internal(InfoKind.outputUnit);
@@ -279,17 +280,19 @@
/// Classes in the supertype hierarchy for this class.
List<ClassInfo> supers = <ClassInfo>[];
- ClassInfo(
- {required String name,
- required this.isAbstract,
- required this.supers,
- OutputUnitInfo? outputUnit,
- int size = 0})
- : super(InfoKind.clazz, name, outputUnit, size, null);
+ ClassInfo({
+ required String name,
+ required this.isAbstract,
+ required this.supers,
+ OutputUnitInfo? outputUnit,
+ int size = 0,
+ }) : super(InfoKind.clazz, name, outputUnit, size, null);
- ClassInfo.fromKernel(
- {required String name, required this.isAbstract, required this.supers})
- : super(InfoKind.clazz, name, null, 0, null);
+ ClassInfo.fromKernel({
+ required String name,
+ required this.isAbstract,
+ required this.supers,
+ }) : super(InfoKind.clazz, name, null, 0, null);
ClassInfo.internal() : super.internal(InfoKind.clazz);
@@ -301,9 +304,11 @@
/// [ClassInfo] because a class and its type may end up in different output
/// units.
class ClassTypeInfo extends BasicInfo {
- ClassTypeInfo(
- {required String name, OutputUnitInfo? outputUnit, int size = 0})
- : super(InfoKind.classType, name, outputUnit, size, null);
+ ClassTypeInfo({
+ required String name,
+ OutputUnitInfo? outputUnit,
+ int size = 0,
+ }) : super(InfoKind.classType, name, outputUnit, size, null);
ClassTypeInfo.internal() : super.internal(InfoKind.classType);
@@ -336,7 +341,7 @@
// TODO(sigmund): Add coverage support to constants?
ConstantInfo({int size = 0, required this.code, OutputUnitInfo? outputUnit})
- : super(InfoKind.constant, '', outputUnit, size, null);
+ : super(InfoKind.constant, '', outputUnit, size, null);
ConstantInfo.internal() : super.internal(InfoKind.constant);
@@ -364,23 +369,23 @@
/// When [isConst] is true, the constant initializer expression.
ConstantInfo? initializer;
- FieldInfo(
- {required String name,
- String? coverageId,
- int size = 0,
- required this.type,
- required this.inferredType,
- required this.code,
- OutputUnitInfo? outputUnit,
- required this.isConst})
- : super(InfoKind.field, name, outputUnit, size, coverageId);
+ FieldInfo({
+ required String name,
+ String? coverageId,
+ int size = 0,
+ required this.type,
+ required this.inferredType,
+ required this.code,
+ OutputUnitInfo? outputUnit,
+ required this.isConst,
+ }) : super(InfoKind.field, name, outputUnit, size, coverageId);
- FieldInfo.fromKernel(
- {required String name,
- String? coverageId,
- required this.type,
- required this.isConst})
- : super(InfoKind.field, name, null, 0, coverageId);
+ FieldInfo.fromKernel({
+ required String name,
+ String? coverageId,
+ required this.type,
+ required this.isConst,
+ }) : super(InfoKind.field, name, null, 0, coverageId);
FieldInfo.internal() : super.internal(InfoKind.field);
@@ -394,7 +399,7 @@
late final String type;
TypedefInfo(String name, this.type, OutputUnitInfo outputUnit)
- : super(InfoKind.typedef, name, outputUnit, 0, null);
+ : super(InfoKind.typedef, name, outputUnit, 0, null);
TypedefInfo.internal() : super.internal(InfoKind.typedef);
@@ -440,30 +445,30 @@
/// The actual generated code.
late final List<CodeSpan> code;
- FunctionInfo(
- {required String name,
- String? coverageId,
- OutputUnitInfo? outputUnit,
- int size = 0,
- required this.functionKind,
- required this.modifiers,
- required this.type,
- required this.returnType,
- required this.inferredReturnType,
- required this.parameters,
- required this.sideEffects,
- required this.inlinedCount,
- required this.code})
- : super(InfoKind.function, name, outputUnit, size, coverageId);
+ FunctionInfo({
+ required String name,
+ String? coverageId,
+ OutputUnitInfo? outputUnit,
+ int size = 0,
+ required this.functionKind,
+ required this.modifiers,
+ required this.type,
+ required this.returnType,
+ required this.inferredReturnType,
+ required this.parameters,
+ required this.sideEffects,
+ required this.inlinedCount,
+ required this.code,
+ }) : super(InfoKind.function, name, outputUnit, size, coverageId);
- FunctionInfo.fromKernel(
- {required String name,
- String? coverageId,
- required this.functionKind,
- required this.modifiers,
- required this.type,
- required this.returnType})
- : super(InfoKind.function, name, null, 0, coverageId);
+ FunctionInfo.fromKernel({
+ required String name,
+ String? coverageId,
+ required this.functionKind,
+ required this.modifiers,
+ required this.type,
+ required this.returnType,
+ }) : super(InfoKind.function, name, null, 0, coverageId);
FunctionInfo.internal() : super.internal(InfoKind.function);
@@ -477,10 +482,10 @@
late final FunctionInfo function;
ClosureInfo({required String name, OutputUnitInfo? outputUnit, int size = 0})
- : super(InfoKind.closure, name, outputUnit, size, null);
+ : super(InfoKind.closure, name, outputUnit, size, null);
ClosureInfo.fromKernel({required String name})
- : super(InfoKind.closure, name, null, 0, null);
+ : super(InfoKind.closure, name, null, 0, null);
ClosureInfo.internal() : super.internal(InfoKind.closure);
@@ -645,7 +650,8 @@
void visitPackage(PackageInfo info) {
throw Exception(
- "PackageInfo objects are only defined for the VM Devtools format.");
+ "PackageInfo objects are only defined for the VM Devtools format.",
+ );
}
@override
diff --git a/pkg/dart2js_info/lib/json_info_codec.dart b/pkg/dart2js_info/lib/json_info_codec.dart
index 3e2225b..bfe94f0 100644
--- a/pkg/dart2js_info/lib/json_info_codec.dart
+++ b/pkg/dart2js_info/lib/json_info_codec.dart
@@ -31,25 +31,33 @@
//
// .addAll(elements['library'].values.cast<Map>().map(parseLibrary));
result.libraries.addAll(
- (elements['library'] as Map).values.map((l) => parseLibrary(l)));
- result.classes
- .addAll((elements['class'] as Map).values.map((c) => parseClass(c)));
+ (elements['library'] as Map).values.map((l) => parseLibrary(l)),
+ );
+ result.classes.addAll(
+ (elements['class'] as Map).values.map((c) => parseClass(c)),
+ );
result.classTypes.addAll(
- (elements['classType'] as Map).values.map((c) => parseClassType(c)));
+ (elements['classType'] as Map).values.map((c) => parseClassType(c)),
+ );
result.functions.addAll(
- (elements['function'] as Map).values.map((f) => parseFunction(f)));
+ (elements['function'] as Map).values.map((f) => parseFunction(f)),
+ );
// TODO(het): Revert this when the dart2js with the new codec is in stable
if (elements['closure'] != null) {
result.closures.addAll(
- (elements['closure'] as Map).values.map((c) => parseClosure(c)));
+ (elements['closure'] as Map).values.map((c) => parseClosure(c)),
+ );
}
- result.fields
- .addAll((elements['field'] as Map).values.map((f) => parseField(f)));
+ result.fields.addAll(
+ (elements['field'] as Map).values.map((f) => parseField(f)),
+ );
result.typedefs.addAll(
- (elements['typedef'] as Map).values.map((t) => parseTypedef(t)));
+ (elements['typedef'] as Map).values.map((t) => parseTypedef(t)),
+ );
result.constants.addAll(
- (elements['constant'] as Map).values.map((c) => parseConstant(c)));
+ (elements['constant'] as Map).values.map((c) => parseConstant(c)),
+ );
input['holding'].forEach((k, deps) {
final src = registry[k] as CodeInfo;
@@ -65,8 +73,9 @@
deps.map((d) => registry[d]!).toList();
});
- result.outputUnits
- .addAll((input['outputUnits'] as List).map((o) => parseOutputUnit(o)));
+ result.outputUnits.addAll(
+ (input['outputUnits'] as List).map((o) => parseOutputUnit(o)),
+ );
result.program = parseProgram(input['program']);
@@ -144,7 +153,8 @@
}
}
result.supers.addAll(
- json['supers'].map<ClassInfo>((id) => parseId(id) as ClassInfo));
+ json['supers'].map<ClassInfo>((id) => parseId(id) as ClassInfo),
+ );
return result;
}
@@ -171,9 +181,10 @@
..code = parseCode(json['code'])
..isConst = json['const'] ?? false
..initializer = parseId(json['initializer']) as ConstantInfo?
- ..closures = (json['children'] as List)
- .map<ClosureInfo>((c) => parseId(c) as ClosureInfo)
- .toList();
+ ..closures =
+ (json['children'] as List)
+ .map<ClosureInfo>((c) => parseId(c) as ClosureInfo)
+ .toList();
}
ConstantInfo parseConstant(Map json) {
@@ -197,35 +208,39 @@
ProgramInfo parseProgram(Map json) {
// TODO(het): Revert this when the dart2js with the new codec is in stable
final compilationDuration = json['compilationDuration'];
- final compilationDurationParsed = compilationDuration is String
- ? _parseDuration(compilationDuration)
- : Duration(microseconds: compilationDuration as int);
+ final compilationDurationParsed =
+ compilationDuration is String
+ ? _parseDuration(compilationDuration)
+ : Duration(microseconds: compilationDuration as int);
final toJsonDuration = json['toJsonDuration'];
- final toJsonDurationParsed = toJsonDuration is String
- ? _parseDuration(toJsonDuration)
- : Duration(microseconds: toJsonDuration as int);
+ final toJsonDurationParsed =
+ toJsonDuration is String
+ ? _parseDuration(toJsonDuration)
+ : Duration(microseconds: toJsonDuration as int);
final dumpInfoDuration = json['dumpInfoDuration'];
- final dumpInfoDurationParsed = dumpInfoDuration is String
- ? _parseDuration(dumpInfoDuration)
- : Duration(microseconds: dumpInfoDuration as int);
+ final dumpInfoDurationParsed =
+ dumpInfoDuration is String
+ ? _parseDuration(dumpInfoDuration)
+ : Duration(microseconds: dumpInfoDuration as int);
final programInfo = ProgramInfo(
- entrypoint: parseId(json['entrypoint']) as FunctionInfo,
- size: json['size'],
- ramUsage: json['ramUsage'],
- compilationMoment: DateTime.parse(json['compilationMoment']),
- dart2jsVersion: json['dart2jsVersion'],
- noSuchMethodEnabled: json['noSuchMethodEnabled'],
- isRuntimeTypeUsed: json['isRuntimeTypeUsed'],
- isIsolateInUse: json['isIsolateInUse'],
- isFunctionApplyUsed: json['isFunctionApplyUsed'],
- isMirrorsUsed: json['isMirrorsUsed'],
- minified: json['minified'],
- compilationDuration: compilationDurationParsed,
- toJsonDuration: toJsonDurationParsed,
- dumpInfoDuration: dumpInfoDurationParsed);
+ entrypoint: parseId(json['entrypoint']) as FunctionInfo,
+ size: json['size'],
+ ramUsage: json['ramUsage'],
+ compilationMoment: DateTime.parse(json['compilationMoment']),
+ dart2jsVersion: json['dart2jsVersion'],
+ noSuchMethodEnabled: json['noSuchMethodEnabled'],
+ isRuntimeTypeUsed: json['isRuntimeTypeUsed'],
+ isIsolateInUse: json['isIsolateInUse'],
+ isFunctionApplyUsed: json['isFunctionApplyUsed'],
+ isMirrorsUsed: json['isMirrorsUsed'],
+ minified: json['minified'],
+ compilationDuration: compilationDurationParsed,
+ toJsonDuration: toJsonDurationParsed,
+ dumpInfoDuration: dumpInfoDurationParsed,
+ );
return programInfo;
}
@@ -242,7 +257,8 @@
const secondsInMillis = 1000;
const minutesInMillis = 60 * secondsInMillis;
const hoursInMillis = 60 * minutesInMillis;
- var totalMillis = secondsInMillis * seconds +
+ var totalMillis =
+ secondsInMillis * seconds +
minutesInMillis * minutes +
hoursInMillis * hours;
return Duration(milliseconds: totalMillis.round());
@@ -266,9 +282,10 @@
..sideEffects = json['sideEffects']
..inlinedCount = json['inlinedCount']
..modifiers = parseModifiers(Map<String, bool>.from(json['modifiers']))
- ..closures = (json['children'] as List)
- .map<ClosureInfo>((c) => parseId(c) as ClosureInfo)
- .toList();
+ ..closures =
+ (json['children'] as List)
+ .map<ClosureInfo>((c) => parseId(c) as ClosureInfo)
+ .toList();
}
ParameterInfo parseParameter(Map json) =>
@@ -276,10 +293,11 @@
FunctionModifiers parseModifiers(Map<String, bool> json) {
return FunctionModifiers(
- isStatic: json['static'] == true,
- isConst: json['const'] == true,
- isFactory: json['factory'] == true,
- isExternal: json['external'] == true);
+ isStatic: json['static'] == true,
+ isConst: json['const'] == true,
+ isFactory: json['factory'] == true,
+ isExternal: json['external'] == true,
+ );
}
ClosureInfo parseClosure(Map json) {
@@ -330,9 +348,10 @@
return json.map((dynamic value) {
Map<String, dynamic> jsonCode = value;
return CodeSpan(
- start: jsonCode['start'],
- end: jsonCode['end'],
- text: jsonCode['text']);
+ start: jsonCode['start'],
+ end: jsonCode['end'],
+ text: jsonCode['text'],
+ );
}).toList();
}
@@ -355,12 +374,13 @@
if (serializedId != null) return serializedId;
assert(
- info is LibraryInfo ||
- info is ConstantInfo ||
- info is OutputUnitInfo ||
- info is ClassInfo ||
- info.parent != null,
- "$info");
+ info is LibraryInfo ||
+ info is ConstantInfo ||
+ info is OutputUnitInfo ||
+ info is ClassInfo ||
+ info.parent != null,
+ "$info",
+ );
String name;
if (info is ConstantInfo) {
@@ -376,8 +396,11 @@
// longName isn't guaranteed to create unique serializedIds for some info
// constructs (such as closures), so we disambiguate here.
Id id = Id(info.kind, name);
- final count =
- idCounter.update(id.serializedId, (v) => v + 1, ifAbsent: () => 0);
+ final count = idCounter.update(
+ id.serializedId,
+ (v) => v + 1,
+ ifAbsent: () => 0,
+ );
if (count > 0) {
id = Id(info.kind, '$name%${count - 1}');
}
@@ -418,29 +441,28 @@
}
Map visitDependencyInfo(DependencyInfo info) => {
- 'id': idFor(info.target).serializedId,
- if (info.mask != null) 'mask': info.mask,
- };
+ 'id': idFor(info.target).serializedId,
+ if (info.mask != null) 'mask': info.mask,
+ };
Map _visitAllInfoHolding(AllInfo allInfo) {
var map = SplayTreeMap<String, List>(compareNatural);
void helper(CodeInfo info) {
if (info.uses.isEmpty) return;
map[idFor(info).serializedId] =
- info.uses.map(visitDependencyInfo).toList()
- ..sort((a, b) {
- final value = a['id'].compareTo(b['id']);
- if (value != 0) return value;
- final aMask = a['mask'] as String?;
- final bMask = b['mask'] as String?;
- if (aMask == null) {
- return bMask == null ? 0 : 1;
- }
- if (bMask == null) {
- return -1;
- }
- return aMask.compareTo(bMask);
- });
+ info.uses.map(visitDependencyInfo).toList()..sort((a, b) {
+ final value = a['id'].compareTo(b['id']);
+ if (value != 0) return value;
+ final aMask = a['mask'] as String?;
+ final bMask = b['mask'] as String?;
+ if (aMask == null) {
+ return bMask == null ? 0 : 1;
+ }
+ if (bMask == null) {
+ return -1;
+ }
+ return aMask.compareTo(bMask);
+ });
}
allInfo.functions.forEach(helper);
@@ -512,29 +534,29 @@
@override
Map visitLibrary(LibraryInfo info) {
- return _visitBasicInfo(info)
- ..addAll(<String, Object>{
- 'children': _toSortedSerializedIds([
- ...info.topLevelFunctions,
- ...info.topLevelVariables,
- ...info.classes,
- ...info.classTypes,
- ...info.typedefs
- ], idFor),
- 'canonicalUri': '${info.uri}',
- });
+ return _visitBasicInfo(info)..addAll(<String, Object>{
+ 'children': _toSortedSerializedIds([
+ ...info.topLevelFunctions,
+ ...info.topLevelVariables,
+ ...info.classes,
+ ...info.classTypes,
+ ...info.typedefs,
+ ], idFor),
+ 'canonicalUri': '${info.uri}',
+ });
}
@override
Map visitClass(ClassInfo info) {
- return _visitBasicInfo(info)
- ..addAll(<String, Object>{
- // TODO(sigmund): change format, include only when abstract is true.
- 'modifiers': {'abstract': info.isAbstract},
- 'children':
- _toSortedSerializedIds([...info.fields, ...info.functions], idFor),
- 'supers': _toSortedSerializedIds(info.supers, idFor)
- });
+ return _visitBasicInfo(info)..addAll(<String, Object>{
+ // TODO(sigmund): change format, include only when abstract is true.
+ 'modifiers': {'abstract': info.isAbstract},
+ 'children': _toSortedSerializedIds([
+ ...info.fields,
+ ...info.functions,
+ ], idFor),
+ 'supers': _toSortedSerializedIds(info.supers, idFor),
+ });
}
@override
@@ -544,13 +566,12 @@
@override
Map visitField(FieldInfo info) {
- var result = _visitBasicInfo(info)
- ..addAll(<String, Object>{
- 'children': _toSortedSerializedIds(info.closures, idFor),
- 'inferredType': info.inferredType,
- 'code': _serializeCode(info.code),
- 'type': info.type,
- });
+ var result = _visitBasicInfo(info)..addAll(<String, Object>{
+ 'children': _toSortedSerializedIds(info.closures, idFor),
+ 'inferredType': info.inferredType,
+ 'code': _serializeCode(info.code),
+ 'type': info.type,
+ });
if (info.isConst) {
result['const'] = true;
if (info.initializer != null) {
@@ -561,8 +582,9 @@
}
@override
- Map visitConstant(ConstantInfo info) => _visitBasicInfo(info)
- ..addAll(<String, Object>{'code': _serializeCode(info.code)});
+ Map visitConstant(ConstantInfo info) =>
+ _visitBasicInfo(info)
+ ..addAll(<String, Object>{'code': _serializeCode(info.code)});
// TODO(sigmund): exclude false values (requires bumping the format version):
// var res = <String, bool>{};
@@ -572,33 +594,34 @@
// if (isExternal) res['external'] = true;
// return res;
Map _visitFunctionModifiers(FunctionModifiers mods) => {
- 'static': mods.isStatic,
- 'const': mods.isConst,
- 'factory': mods.isFactory,
- 'external': mods.isExternal,
- };
+ 'static': mods.isStatic,
+ 'const': mods.isConst,
+ 'factory': mods.isFactory,
+ 'external': mods.isExternal,
+ };
- Map _visitParameterInfo(ParameterInfo info) =>
- {'name': info.name, 'type': info.type, 'declaredType': info.declaredType};
+ Map _visitParameterInfo(ParameterInfo info) => {
+ 'name': info.name,
+ 'type': info.type,
+ 'declaredType': info.declaredType,
+ };
@override
Map visitFunction(FunctionInfo info) {
- return _visitBasicInfo(info)
- ..addAll(<String, Object?>{
- 'children': _toSortedSerializedIds(info.closures, idFor),
- 'modifiers': _visitFunctionModifiers(info.modifiers),
- 'returnType': info.returnType,
- 'inferredReturnType': info.inferredReturnType,
- 'parameters':
- info.parameters.map((p) => _visitParameterInfo(p)).toList(),
- 'sideEffects': info.sideEffects,
- 'inlinedCount': info.inlinedCount,
- 'code': _serializeCode(info.code),
- 'type': info.type,
- 'functionKind': info.functionKind,
- // Note: version 3.2 of dump-info serializes `uses` in a section called
- // `holding` at the top-level.
- });
+ return _visitBasicInfo(info)..addAll(<String, Object?>{
+ 'children': _toSortedSerializedIds(info.closures, idFor),
+ 'modifiers': _visitFunctionModifiers(info.modifiers),
+ 'returnType': info.returnType,
+ 'inferredReturnType': info.inferredReturnType,
+ 'parameters': info.parameters.map((p) => _visitParameterInfo(p)).toList(),
+ 'sideEffects': info.sideEffects,
+ 'inlinedCount': info.inlinedCount,
+ 'code': _serializeCode(info.code),
+ 'type': info.type,
+ 'functionKind': info.functionKind,
+ // Note: version 3.2 of dump-info serializes `uses` in a section called
+ // `holding` at the top-level.
+ });
}
@override
@@ -612,26 +635,24 @@
_visitBasicInfo(info)..['type'] = info.type;
@override
- Map visitOutput(OutputUnitInfo info) => _visitBasicInfo(info)
- ..['filename'] = info.filename
- ..['imports'] = info.imports;
+ Map visitOutput(OutputUnitInfo info) =>
+ _visitBasicInfo(info)
+ ..['filename'] = info.filename
+ ..['imports'] = info.imports;
Object _serializeCode(List<CodeSpan> code) {
if (isBackwardCompatible) {
return code.map((c) => c.text).join('\n');
}
return code
- .map<Object>((c) => {
- 'start': c.start,
- 'end': c.end,
- 'text': c.text,
- })
+ .map<Object>((c) => {'start': c.start, 'end': c.end, 'text': c.text})
.toList();
}
List<String> _toSortedSerializedIds(
- Iterable<Info> infos, Id Function(Info) getId) =>
- infos.map((i) => getId(i).serializedId).toList()..sort(compareNatural);
+ Iterable<Info> infos,
+ Id Function(Info) getId,
+ ) => infos.map((i) => getId(i).serializedId).toList()..sort(compareNatural);
}
class AllInfoJsonCodec extends Codec<AllInfo, Map> {
@@ -641,8 +662,9 @@
final Converter<Map, AllInfo> decoder = JsonToAllInfoConverter();
AllInfoJsonCodec({bool isBackwardCompatible = false})
- : encoder =
- AllInfoToJsonConverter(isBackwardCompatible: isBackwardCompatible);
+ : encoder = AllInfoToJsonConverter(
+ isBackwardCompatible: isBackwardCompatible,
+ );
}
class Id {
diff --git a/pkg/dart2js_info/lib/proto_info_codec.dart b/pkg/dart2js_info/lib/proto_info_codec.dart
index 3b9f3ea..3e84471 100644
--- a/pkg/dart2js_info/lib/proto_info_codec.dart
+++ b/pkg/dart2js_info/lib/proto_info_codec.dart
@@ -34,11 +34,13 @@
var serializedId = ids[info];
if (serializedId != null) return serializedId;
- assert(info is LibraryInfo ||
- info is ConstantInfo ||
- info is OutputUnitInfo ||
- info is ClassInfo ||
- info.parent != null);
+ assert(
+ info is LibraryInfo ||
+ info is ConstantInfo ||
+ info is OutputUnitInfo ||
+ info is ClassInfo ||
+ info.parent != null,
+ );
int id;
if (info is ConstantInfo) {
@@ -80,16 +82,21 @@
LibraryInfoPB _convertToLibraryInfoPB(LibraryInfo info) {
final proto = LibraryInfoPB()..uri = info.uri.toString();
- proto.childrenIds
- .addAll(info.topLevelFunctions.map((func) => idFor(func).serializedId));
proto.childrenIds.addAll(
- info.topLevelVariables.map((field) => idFor(field).serializedId));
- proto.childrenIds
- .addAll(info.classes.map((clazz) => idFor(clazz).serializedId));
+ info.topLevelFunctions.map((func) => idFor(func).serializedId),
+ );
proto.childrenIds.addAll(
- info.classTypes.map((classType) => idFor(classType).serializedId));
- proto.childrenIds
- .addAll(info.typedefs.map((def) => idFor(def).serializedId));
+ info.topLevelVariables.map((field) => idFor(field).serializedId),
+ );
+ proto.childrenIds.addAll(
+ info.classes.map((clazz) => idFor(clazz).serializedId),
+ );
+ proto.childrenIds.addAll(
+ info.classTypes.map((classType) => idFor(classType).serializedId),
+ );
+ proto.childrenIds.addAll(
+ info.typedefs.map((def) => idFor(def).serializedId),
+ );
return proto;
}
@@ -97,10 +104,12 @@
ClassInfoPB _convertToClassInfoPB(ClassInfo info) {
final proto = ClassInfoPB()..isAbstract = info.isAbstract;
- proto.childrenIds
- .addAll(info.functions.map((func) => idFor(func).serializedId));
- proto.childrenIds
- .addAll(info.fields.map((field) => idFor(field).serializedId));
+ proto.childrenIds.addAll(
+ info.functions.map((func) => idFor(func).serializedId),
+ );
+ proto.childrenIds.addAll(
+ info.fields.map((field) => idFor(field).serializedId),
+ );
return proto;
}
@@ -110,7 +119,8 @@
}
static FunctionModifiersPB _convertToFunctionModifiers(
- FunctionModifiers modifiers) {
+ FunctionModifiers modifiers,
+ ) {
return FunctionModifiersPB()
..isStatic = modifiers.isStatic
..isConst = modifiers.isConst
@@ -119,9 +129,10 @@
}
FunctionInfoPB _convertToFunctionInfoPB(FunctionInfo info) {
- final proto = FunctionInfoPB()
- ..functionModifiers = _convertToFunctionModifiers(info.modifiers)
- ..inlinedCount = info.inlinedCount ?? 0;
+ final proto =
+ FunctionInfoPB()
+ ..functionModifiers = _convertToFunctionModifiers(info.modifiers)
+ ..inlinedCount = info.inlinedCount ?? 0;
proto.returnType = info.returnType;
@@ -131,18 +142,20 @@
proto.sideEffects = info.sideEffects;
- proto.childrenIds
- .addAll(info.closures.map(((closure) => idFor(closure).serializedId)));
+ proto.childrenIds.addAll(
+ info.closures.map(((closure) => idFor(closure).serializedId)),
+ );
proto.parameters.addAll(info.parameters.map(_convertToParameterInfoPB));
return proto;
}
FieldInfoPB _convertToFieldInfoPB(FieldInfo info) {
- final proto = FieldInfoPB()
- ..type = info.type
- ..inferredType = info.inferredType
- ..isConst = info.isConst;
+ final proto =
+ FieldInfoPB()
+ ..type = info.type
+ ..inferredType = info.inferredType
+ ..isConst = info.isConst;
proto.code = info.code.map((c) => c.text).join('\n');
@@ -150,8 +163,9 @@
proto.initializerId = idFor(info.initializer!).serializedId;
}
- proto.childrenIds
- .addAll(info.closures.map((closure) => idFor(closure).serializedId));
+ proto.childrenIds.addAll(
+ info.closures.map((closure) => idFor(closure).serializedId),
+ );
return proto;
}
@@ -175,10 +189,11 @@
}
InfoPB _convertToInfoPB(Info info) {
- final proto = InfoPB()
- ..id = idFor(info).id
- ..serializedId = idFor(info).serializedId
- ..size = info.size;
+ final proto =
+ InfoPB()
+ ..id = idFor(info).id
+ ..serializedId = idFor(info).serializedId
+ ..size = info.size;
proto.name = info.name;
@@ -225,19 +240,22 @@
}
ProgramInfoPB _convertToProgramInfoPB(ProgramInfo info) {
- var result = ProgramInfoPB()
- ..entrypointId = idFor(info.entrypoint).serializedId
- ..size = info.size
- ..compilationMoment = Int64(info.compilationMoment.microsecondsSinceEpoch)
- ..compilationDuration = Int64(info.compilationDuration.inMicroseconds)
- ..toProtoDuration = Int64(info.toJsonDuration.inMicroseconds)
- ..dumpInfoDuration = Int64(info.dumpInfoDuration.inMicroseconds)
- ..noSuchMethodEnabled = info.noSuchMethodEnabled
- ..isRuntimeTypeUsed = info.isRuntimeTypeUsed
- ..isIsolateUsed = info.isIsolateInUse
- ..isFunctionApplyUsed = info.isFunctionApplyUsed
- ..isMirrorsUsed = info.isMirrorsUsed
- ..minified = info.minified;
+ var result =
+ ProgramInfoPB()
+ ..entrypointId = idFor(info.entrypoint).serializedId
+ ..size = info.size
+ ..compilationMoment = Int64(
+ info.compilationMoment.microsecondsSinceEpoch,
+ )
+ ..compilationDuration = Int64(info.compilationDuration.inMicroseconds)
+ ..toProtoDuration = Int64(info.toJsonDuration.inMicroseconds)
+ ..dumpInfoDuration = Int64(info.dumpInfoDuration.inMicroseconds)
+ ..noSuchMethodEnabled = info.noSuchMethodEnabled
+ ..isRuntimeTypeUsed = info.isRuntimeTypeUsed
+ ..isIsolateUsed = info.isIsolateInUse
+ ..isFunctionApplyUsed = info.isFunctionApplyUsed
+ ..isMirrorsUsed = info.isMirrorsUsed
+ ..minified = info.minified;
if (info.dart2jsVersion != null) {
result.dart2jsVersion = info.dart2jsVersion!;
@@ -246,7 +264,8 @@
}
Iterable<MapEntry<String, InfoPB>> _convertToAllInfosEntries<T extends Info>(
- Iterable<T> infos) sync* {
+ Iterable<T> infos,
+ ) sync* {
for (final info in infos) {
final infoProto = _convertToInfoPB(info);
final entry = MapEntry<String, InfoPB>(infoProto.serializedId, infoProto);
@@ -255,10 +274,13 @@
}
static LibraryDeferredImportsPB _convertToLibraryDeferredImportsPB(
- String libraryUri, Map<String, dynamic> fields) {
- final proto = LibraryDeferredImportsPB()
- ..libraryUri = libraryUri
- ..libraryName = fields['name'] ?? '<unnamed>';
+ String libraryUri,
+ Map<String, dynamic> fields,
+ ) {
+ final proto =
+ LibraryDeferredImportsPB()
+ ..libraryUri = libraryUri
+ ..libraryName = fields['name'] ?? '<unnamed>';
Map<String, List<String>> imports = fields['imports'];
imports.forEach((prefix, files) {
@@ -284,8 +306,9 @@
proto.allInfos.addEntries(_convertToAllInfosEntries(info.closures));
info.deferredFiles?.forEach((libraryUri, fields) {
- proto.deferredImports
- .add(_convertToLibraryDeferredImportsPB(libraryUri, fields));
+ proto.deferredImports.add(
+ _convertToLibraryDeferredImportsPB(libraryUri, fields),
+ );
});
return proto;
diff --git a/pkg/dart2js_info/lib/src/binary/sink.dart b/pkg/dart2js_info/lib/src/binary/sink.dart
index a4f6278..a744076 100644
--- a/pkg/dart2js_info/lib/src/binary/sink.dart
+++ b/pkg/dart2js_info/lib/src/binary/sink.dart
@@ -34,8 +34,11 @@
///
/// This is a convenience method to be used together with
/// [DataSource.readList].
- void writeList<E>(Iterable<E> values, void Function(E value) f,
- {bool allowNull = false});
+ void writeList<E>(
+ Iterable<E> values,
+ void Function(E value) f, {
+ bool allowNull = false,
+ });
/// Writes the boolean [value] to this data sink.
void writeBool(bool value);
@@ -71,8 +74,11 @@
///
/// This is a convenience method to be used together with
/// [DataSource.readStringMap].
- void writeStringMap<V>(Map<String, V> map, void Function(V value) f,
- {bool allowNull = false});
+ void writeStringMap<V>(
+ Map<String, V> map,
+ void Function(V value) f, {
+ bool allowNull = false,
+ });
/// Writes the enum value [value] to this data sink.
void writeEnum<E extends Enum>(E value);
@@ -113,8 +119,11 @@
}
@override
- void writeStringMap<V>(Map<String, V>? map, void Function(V value) f,
- {bool allowNull = false}) {
+ void writeStringMap<V>(
+ Map<String, V>? map,
+ void Function(V value) f, {
+ bool allowNull = false,
+ }) {
if (map == null) {
assert(allowNull);
writeInt(0);
@@ -128,8 +137,11 @@
}
@override
- void writeList<E>(Iterable<E>? values, void Function(E value) f,
- {bool allowNull = false}) {
+ void writeList<E>(
+ Iterable<E>? values,
+ void Function(E value) f, {
+ bool allowNull = false,
+ }) {
if (values == null) {
assert(allowNull);
writeInt(0);
@@ -272,8 +284,12 @@
_bufferedSink!.addByte2((value >> 8) | 0x80, value & 0xFF);
_length += 2;
} else {
- _bufferedSink!.addByte4((value >> 24) | 0xC0, (value >> 16) & 0xFF,
- (value >> 8) & 0xFF, value & 0xFF);
+ _bufferedSink!.addByte4(
+ (value >> 24) | 0xC0,
+ (value >> 16) & 0xFF,
+ (value >> 8) & 0xFF,
+ value & 0xFF,
+ );
_length += 4;
}
}
@@ -318,10 +334,18 @@
final doubleBufferUint8 =
_doubleBufferUint8 ??= _doubleBuffer.buffer.asUint8List();
_doubleBuffer[0] = d;
- addByte4(doubleBufferUint8[0], doubleBufferUint8[1], doubleBufferUint8[2],
- doubleBufferUint8[3]);
- addByte4(doubleBufferUint8[4], doubleBufferUint8[5], doubleBufferUint8[6],
- doubleBufferUint8[7]);
+ addByte4(
+ doubleBufferUint8[0],
+ doubleBufferUint8[1],
+ doubleBufferUint8[2],
+ doubleBufferUint8[3],
+ );
+ addByte4(
+ doubleBufferUint8[4],
+ doubleBufferUint8[5],
+ doubleBufferUint8[6],
+ doubleBufferUint8[7],
+ );
}
void addByte(int byte) {
diff --git a/pkg/dart2js_info/lib/src/binary/source.dart b/pkg/dart2js_info/lib/src/binary/source.dart
index dd91b5c..a986bfb 100644
--- a/pkg/dart2js_info/lib/src/binary/source.dart
+++ b/pkg/dart2js_info/lib/src/binary/source.dart
@@ -278,9 +278,10 @@
E _readEnumInternal<E>(List<E> values) {
int index = _readIntInternal();
assert(
- 0 <= index && index < values.length,
- "Invalid data kind index. "
- "Expected one of $values, found index $index.");
+ 0 <= index && index < values.length,
+ "Invalid data kind index. "
+ "Expected one of $values, found index $index.",
+ );
return values[index];
}
}
diff --git a/pkg/dart2js_info/lib/src/common_element.dart b/pkg/dart2js_info/lib/src/common_element.dart
index 1d6eac0..fdabf00 100644
--- a/pkg/dart2js_info/lib/src/common_element.dart
+++ b/pkg/dart2js_info/lib/src/common_element.dart
@@ -10,8 +10,11 @@
String get name => longName(oldInfo, useLibraryUri: true);
}
-List<CommonElement> findCommonalities(AllInfo oldInfo, AllInfo newInfo,
- {bool mainOnly = false}) {
+List<CommonElement> findCommonalities(
+ AllInfo oldInfo,
+ AllInfo newInfo, {
+ bool mainOnly = false,
+}) {
var finder = _InfoCommonElementFinder(oldInfo, newInfo, mainOnly: mainOnly);
finder.run();
return finder.commonElements;
diff --git a/pkg/dart2js_info/lib/src/diff.dart b/pkg/dart2js_info/lib/src/diff.dart
index ce2024d..c4a8c53 100644
--- a/pkg/dart2js_info/lib/src/diff.dart
+++ b/pkg/dart2js_info/lib/src/diff.dart
@@ -25,7 +25,7 @@
class DeferredStatusDiff extends Diff {
final bool wasDeferredBefore;
DeferredStatusDiff(BasicInfo info, this.wasDeferredBefore)
- : super(info, DiffKind.deferred);
+ : super(info, DiffKind.deferred);
}
List<Diff> diff(AllInfo oldInfo, AllInfo newInfo) {
diff --git a/pkg/dart2js_info/lib/src/graph.dart b/pkg/dart2js_info/lib/src/graph.dart
index 70c0252..9c7ac0f 100644
--- a/pkg/dart2js_info/lib/src/graph.dart
+++ b/pkg/dart2js_info/lib/src/graph.dart
@@ -187,10 +187,7 @@
/// Component that contains the corresponding node.
List<N>? component;
- _NodeInfo(int depth)
- : index = depth,
- lowlink = depth,
- onStack = false;
+ _NodeInfo(int depth) : index = depth, lowlink = depth, onStack = false;
}
/// Implements Tarjan's Algorithm for finding the strongly connected components
diff --git a/pkg/dart2js_info/lib/src/runtime_coverage_utils.dart b/pkg/dart2js_info/lib/src/runtime_coverage_utils.dart
index 04a1356..a97c990 100644
--- a/pkg/dart2js_info/lib/src/runtime_coverage_utils.dart
+++ b/pkg/dart2js_info/lib/src/runtime_coverage_utils.dart
@@ -83,8 +83,10 @@
}
final colonIndex = input.indexOf(':');
if (colonIndex < 0) {
- throw ArgumentError('AngularInfo format cannot accept undefined schemes.'
- ' No scheme found for: $input');
+ throw ArgumentError(
+ 'AngularInfo format cannot accept undefined schemes.'
+ ' No scheme found for: $input',
+ );
}
final slashIndex = input.indexOf('/');
final spaceIndex = input.indexOf(' ');
diff --git a/pkg/dart2js_info/lib/src/string_edit_buffer.dart b/pkg/dart2js_info/lib/src/string_edit_buffer.dart
index d0313e3..737cec0 100644
--- a/pkg/dart2js_info/lib/src/string_edit_buffer.dart
+++ b/pkg/dart2js_info/lib/src/string_edit_buffer.dart
@@ -96,7 +96,7 @@
final String string;
_StringEdit(this.begin, this.end, this.string, [int? sortId])
- : sortId = sortId ?? begin;
+ : sortId = sortId ?? begin;
int get length => end - begin;
diff --git a/pkg/dart2js_info/lib/src/table.dart b/pkg/dart2js_info/lib/src/table.dart
index 48332d9..fac5d97 100644
--- a/pkg/dart2js_info/lib/src/table.dart
+++ b/pkg/dart2js_info/lib/src/table.dart
@@ -36,14 +36,19 @@
List? _currentRow;
/// Add a column with the given [name].
- void declareColumn(String name,
- {bool abbreviate = false, String color = _noColor}) {
+ void declareColumn(
+ String name, {
+ bool abbreviate = false,
+ String color = _noColor,
+ }) {
assert(!_sealed);
var headerName = name;
if (abbreviate) {
// abbreviate the header by using only the initials of each word
- headerName =
- name.split(' ').map((s) => s.substring(0, 1).toUpperCase()).join('');
+ headerName = name
+ .split(' ')
+ .map((s) => s.substring(0, 1).toUpperCase())
+ .join('');
while (abbreviations[headerName] != null) {
headerName = "$headerName'";
}
@@ -110,8 +115,9 @@
}
// Align first column to the left, everything else to the right.
sb.write(
- // ignore: avoid_dynamic_calls
- i == 0 ? entry.padRight(widths[i]) : entry.padLeft(widths[i] + 1));
+ // ignore: avoid_dynamic_calls
+ i == 0 ? entry.padRight(widths[i]) : entry.padLeft(widths[i] + 1),
+ );
}
if (lastColor != _noColor) sb.write(_noColor);
sb.write('\n');
diff --git a/pkg/dart2js_info/lib/src/util.dart b/pkg/dart2js_info/lib/src/util.dart
index 52c67da..c344d4e 100644
--- a/pkg/dart2js_info/lib/src/util.dart
+++ b/pkg/dart2js_info/lib/src/util.dart
@@ -8,8 +8,10 @@
/// Computes a graph of dependencies from [info].
Graph<Info> graphFromInfo(AllInfo info) {
- print(' info: dependency graph information is work in progress and'
- ' might be incomplete');
+ print(
+ ' info: dependency graph information is work in progress and'
+ ' might be incomplete',
+ );
// Note: we are combining dependency information that is computed in two ways
// (functionInfo.uses vs allInfo.dependencies).
// TODO(sigmund): fix inconsistencies between these two ways, stick with one
diff --git a/pkg/dart2js_info/pubspec.yaml b/pkg/dart2js_info/pubspec.yaml
index c865188..d09fb87 100644
--- a/pkg/dart2js_info/pubspec.yaml
+++ b/pkg/dart2js_info/pubspec.yaml
@@ -6,7 +6,7 @@
--dump-info.
environment:
- sdk: '>=2.19.0 <3.0.0'
+ sdk: '^3.7.0-0'
# Use 'any' constraints here; we get our versions from the DEPS file.
dependencies:
diff --git a/pkg/dart2js_info/test/classes/classes.dart b/pkg/dart2js_info/test/classes/classes.dart
index c4f87d1..a54003f 100644
--- a/pkg/dart2js_info/test/classes/classes.dart
+++ b/pkg/dart2js_info/test/classes/classes.dart
@@ -6,7 +6,7 @@
}
}
-class Mixin {
+mixin Mixin {
void method(int t) {
print(t + 1);
}
diff --git a/pkg/dart2js_info/test/graph_test.dart b/pkg/dart2js_info/test/graph_test.dart
index 003c810..dc5f1e1 100644
--- a/pkg/dart2js_info/test/graph_test.dart
+++ b/pkg/dart2js_info/test/graph_test.dart
@@ -18,12 +18,13 @@
test('topological sort', () {
expect(
- graph.computeTopologicalSort(),
- equals([
- ['C'],
- ['E'],
- ['D', 'B', 'A']
- ]));
+ graph.computeTopologicalSort(),
+ equals([
+ ['C'],
+ ['E'],
+ ['D', 'B', 'A'],
+ ]),
+ );
});
test('contains path', () {
diff --git a/pkg/dart2js_info/test/json_to_proto_test.dart b/pkg/dart2js_info/test/json_to_proto_test.dart
index 4475a4a..cab798e 100644
--- a/pkg/dart2js_info/test/json_to_proto_test.dart
+++ b/pkg/dart2js_info/test/json_to_proto_test.dart
@@ -25,12 +25,18 @@
expect(proto.program.entrypointId, isNotNull);
expect(proto.program.size, 90293);
- expect(proto.program.compilationMoment.toInt(),
- DateTime.parse("2022-07-14 17:35:15.006337").microsecondsSinceEpoch);
- expect(proto.program.toProtoDuration.toInt(),
- Duration(milliseconds: 2).inMicroseconds);
- expect(proto.program.dumpInfoDuration.toInt(),
- Duration(milliseconds: 0).inMicroseconds);
+ expect(
+ proto.program.compilationMoment.toInt(),
+ DateTime.parse("2022-07-14 17:35:15.006337").microsecondsSinceEpoch,
+ );
+ expect(
+ proto.program.toProtoDuration.toInt(),
+ Duration(milliseconds: 2).inMicroseconds,
+ );
+ expect(
+ proto.program.dumpInfoDuration.toInt(),
+ Duration(milliseconds: 0).inMicroseconds,
+ );
expect(proto.program.noSuchMethodEnabled, isFalse);
expect(proto.program.minified, isFalse);
});
@@ -48,32 +54,50 @@
for (final info in proto.allInfos.entries) {
final value = info.value;
if (value.hasLibraryInfo()) {
- expect(value.serializedId,
- startsWith(expectedPrefixes[InfoKind.library]!));
+ expect(
+ value.serializedId,
+ startsWith(expectedPrefixes[InfoKind.library]!),
+ );
} else if (value.hasClassInfo()) {
- expect(value.serializedId,
- startsWith(expectedPrefixes[InfoKind.clazz]!));
+ expect(
+ value.serializedId,
+ startsWith(expectedPrefixes[InfoKind.clazz]!),
+ );
} else if (value.hasClassTypeInfo()) {
- expect(value.serializedId,
- startsWith(expectedPrefixes[InfoKind.classType]!));
+ expect(
+ value.serializedId,
+ startsWith(expectedPrefixes[InfoKind.classType]!),
+ );
} else if (value.hasFunctionInfo()) {
- expect(value.serializedId,
- startsWith(expectedPrefixes[InfoKind.function]!));
+ expect(
+ value.serializedId,
+ startsWith(expectedPrefixes[InfoKind.function]!),
+ );
} else if (value.hasFieldInfo()) {
- expect(value.serializedId,
- startsWith(expectedPrefixes[InfoKind.field]!));
+ expect(
+ value.serializedId,
+ startsWith(expectedPrefixes[InfoKind.field]!),
+ );
} else if (value.hasConstantInfo()) {
- expect(value.serializedId,
- startsWith(expectedPrefixes[InfoKind.constant]!));
+ expect(
+ value.serializedId,
+ startsWith(expectedPrefixes[InfoKind.constant]!),
+ );
} else if (value.hasOutputUnitInfo()) {
- expect(value.serializedId,
- startsWith(expectedPrefixes[InfoKind.outputUnit]!));
+ expect(
+ value.serializedId,
+ startsWith(expectedPrefixes[InfoKind.outputUnit]!),
+ );
} else if (value.hasTypedefInfo()) {
- expect(value.serializedId,
- startsWith(expectedPrefixes[InfoKind.typedef]!));
+ expect(
+ value.serializedId,
+ startsWith(expectedPrefixes[InfoKind.typedef]!),
+ );
} else if (value.hasClosureInfo()) {
- expect(value.serializedId,
- startsWith(expectedPrefixes[InfoKind.closure]!));
+ expect(
+ value.serializedId,
+ startsWith(expectedPrefixes[InfoKind.closure]!),
+ );
}
}
});
diff --git a/pkg/dart2js_info/test/parse_test.dart b/pkg/dart2js_info/test/parse_test.dart
index 0159948..ce1da55 100644
--- a/pkg/dart2js_info/test/parse_test.dart
+++ b/pkg/dart2js_info/test/parse_test.dart
@@ -21,8 +21,10 @@
expect(program!.entrypoint, isNotNull);
expect(program.size, 90293);
- expect(program.compilationMoment,
- DateTime.parse("2022-07-14 17:35:15.006337"));
+ expect(
+ program.compilationMoment,
+ DateTime.parse("2022-07-14 17:35:15.006337"),
+ );
expect(program.compilationDuration, Duration(microseconds: 1289072));
expect(program.toJsonDuration, Duration(milliseconds: 2));
expect(program.dumpInfoDuration, Duration(seconds: 0));
diff --git a/pkg/dart2js_info/test/runtime_coverage_test.dart b/pkg/dart2js_info/test/runtime_coverage_test.dart
index a7b96a4..b2b1355 100644
--- a/pkg/dart2js_info/test/runtime_coverage_test.dart
+++ b/pkg/dart2js_info/test/runtime_coverage_test.dart
@@ -27,11 +27,14 @@
late final AllInfo allInfo;
setUpAll(() async {
- final infoBinaryFile =
- await resolveTestFile('classes/classes.js.info.data');
+ final infoBinaryFile = await resolveTestFile(
+ 'classes/classes.js.info.data',
+ );
allInfo = decode(infoBinaryFile.readAsBytesSync());
- classFilters = (await resolveTestFile('classes/class_filter.txt'))
- .readAsLinesSync();
+ classFilters =
+ (await resolveTestFile(
+ 'classes/class_filter.txt',
+ )).readAsLinesSync();
});
setUp(() {
@@ -46,19 +49,23 @@
test('AngularInfo conversions throws on invalid schemes', () {
expect(
- () => RuntimeClassInfo.fromAngularInfo(
- 'no/scheme/here.dart - ClassName'),
- throwsArgumentError);
+ () => RuntimeClassInfo.fromAngularInfo(
+ 'no/scheme/here.dart - ClassName',
+ ),
+ throwsArgumentError,
+ );
expect(
- () => RuntimeClassInfo.fromAngularInfo('noscheme.dart - ClassName'),
- throwsArgumentError);
+ () => RuntimeClassInfo.fromAngularInfo('noscheme.dart - ClassName'),
+ throwsArgumentError,
+ );
});
test('class filters parse and annotate properly', () {
// Process class filters.
for (final filterString in classFilters) {
- final runtimeClassInfo =
- RuntimeClassInfo.fromAngularInfo(filterString);
+ final runtimeClassInfo = RuntimeClassInfo.fromAngularInfo(
+ filterString,
+ );
expect(runtimeClassInfo.annotated, isFalse);
runtimeClassInfos[runtimeClassInfo.key] = runtimeClassInfo;
}
@@ -66,8 +73,10 @@
// Annotate class filters with their corresponding ClassInfo.
for (final classInfo in allInfo.classes) {
final name = qualifiedName(classInfo);
- final nameWithoutScheme =
- name.substring(name.indexOf(':') + 1, name.length);
+ final nameWithoutScheme = name.substring(
+ name.indexOf(':') + 1,
+ name.length,
+ );
final runtimeClassInfo = runtimeClassInfos[nameWithoutScheme];
if (runtimeClassInfo != null) {
runtimeClassInfo.annotateWithClassInfo(classInfo);
diff --git a/pkg/dart2js_info/test/test_shared.dart b/pkg/dart2js_info/test/test_shared.dart
index e30e30e..24996b1 100644
--- a/pkg/dart2js_info/test/test_shared.dart
+++ b/pkg/dart2js_info/test/test_shared.dart
@@ -9,13 +9,15 @@
resolveTestFileContent('hello_world/hello_world.js.info.json');
Future<String> helloWorldDeferredDumpInfo() async => resolveTestFileContent(
- 'hello_world_deferred/hello_world_deferred.js.info.json');
+ 'hello_world_deferred/hello_world_deferred.js.info.json',
+);
Future<String> resolveTestFileContent(String filePath) async =>
(await resolveTestFile(filePath)).readAsStringSync();
Future<File> resolveTestFile(String filePath) async {
final mainLibraryUri = await Isolate.resolvePackageUri(
- Uri.parse('package:dart2js_info/info.dart'));
+ Uri.parse('package:dart2js_info/info.dart'),
+ );
return File.fromUri(mainLibraryUri!.resolve('../test/$filePath'));
}