Skip to content

Commit 5cacaca

Browse files
fishythefishCommit Queue
authored andcommitted
[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 <[email protected]> Reviewed-by: Nate Biggs <[email protected]> Commit-Queue: Nate Biggs <[email protected]> Commit-Queue: Mayank Patke <[email protected]>
1 parent 8f222e9 commit 5cacaca

39 files changed

+1254
-847
lines changed

pkg/dart2js_info/bin/src/code_deps.dart

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -57,17 +57,21 @@ class _SomePathQuery extends Command<void> with PrintUsageException {
5757
void run() async {
5858
var args = argResults!.rest;
5959
if (args.length < 3) {
60-
usageException("Missing arguments for some_path, expected: "
61-
"info.data <element-regexp-1> <element-regexp-2>");
60+
usageException(
61+
"Missing arguments for some_path, expected: "
62+
"info.data <element-regexp-1> <element-regexp-2>",
63+
);
6264
}
6365

6466
var info = await infoFromFile(args.first);
6567
var graph = graphFromInfo(info);
6668

67-
final source =
68-
info.functions.firstWhereOrNull(_longNameMatcher(RegExp(args[1])));
69-
final target =
70-
info.functions.firstWhereOrNull(_longNameMatcher(RegExp(args[2])));
69+
final source = info.functions.firstWhereOrNull(
70+
_longNameMatcher(RegExp(args[1])),
71+
);
72+
final target = info.functions.firstWhereOrNull(
73+
_longNameMatcher(RegExp(args[2])),
74+
);
7175
print('query: some_path');
7276
if (source == null) {
7377
usageException("source '${args[1]}' not found in '${args[0]}'");

pkg/dart2js_info/bin/src/common_command.dart

Lines changed: 58 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -19,20 +19,29 @@ class CommonCommand extends Command<void> with PrintUsageException {
1919
"See code element commonalities between two dump-info files.";
2020

2121
CommonCommand() {
22-
argParser.addFlag('packages-only',
23-
defaultsTo: false,
24-
help: "Show only packages in common. "
25-
"Cannot be used with `main-only`.");
26-
argParser.addFlag('order-by-size',
27-
defaultsTo: false,
28-
help: "Show output ordered by size in bytes (decreasing). "
29-
"If there are size discrepancies, orders by the first "
30-
"dump-info file's reported size.");
31-
argParser.addFlag('main-only',
32-
defaultsTo: false,
33-
help: "Only shows output comparison for main output unit. Provides "
34-
"results by class and member rather than by library. "
35-
"Cannot be used with `packages-only`.");
22+
argParser.addFlag(
23+
'packages-only',
24+
defaultsTo: false,
25+
help:
26+
"Show only packages in common. "
27+
"Cannot be used with `main-only`.",
28+
);
29+
argParser.addFlag(
30+
'order-by-size',
31+
defaultsTo: false,
32+
help:
33+
"Show output ordered by size in bytes (decreasing). "
34+
"If there are size discrepancies, orders by the first "
35+
"dump-info file's reported size.",
36+
);
37+
argParser.addFlag(
38+
'main-only',
39+
defaultsTo: false,
40+
help:
41+
"Only shows output comparison for main output unit. Provides "
42+
"results by class and member rather than by library. "
43+
"Cannot be used with `packages-only`.",
44+
);
3645
}
3746

3847
@override
@@ -41,7 +50,8 @@ class CommonCommand extends Command<void> with PrintUsageException {
4150
final args = argRes.rest;
4251
if (args.length < 2) {
4352
usageException(
44-
'Missing arguments, expected two dump-info files to compare');
53+
'Missing arguments, expected two dump-info files to compare',
54+
);
4555
}
4656

4757
var oldInfo = await infoFromFile(args[0]);
@@ -51,11 +61,15 @@ class CommonCommand extends Command<void> with PrintUsageException {
5161
bool mainOnly = argRes['main-only'];
5262
if (packagesOnly && mainOnly) {
5363
throw ArgumentError(
54-
'Only one of `main-only` and `packages-only` can be provided.');
64+
'Only one of `main-only` and `packages-only` can be provided.',
65+
);
5566
}
5667

57-
var commonElements =
58-
findCommonalities(oldInfo, newInfo, mainOnly: mainOnly);
68+
var commonElements = findCommonalities(
69+
oldInfo,
70+
newInfo,
71+
mainOnly: mainOnly,
72+
);
5973

6074
if (packagesOnly) {
6175
reportPackages(commonElements, orderBySize: orderBySize);
@@ -78,10 +92,12 @@ void report(List<CommonElement> commonElements, {orderBySize = false}) {
7892
}
7993
}
8094

81-
_section('COMMON ELEMENTS',
82-
elementCount: commonElements.length,
83-
oldSizeTotal: oldSizeTotal,
84-
newSizeTotal: newSizeTotal);
95+
_section(
96+
'COMMON ELEMENTS',
97+
elementCount: commonElements.length,
98+
oldSizeTotal: oldSizeTotal,
99+
newSizeTotal: newSizeTotal,
100+
);
85101

86102
if (orderBySize) {
87103
commonElements.sort((a, b) => b.oldInfo.size.compareTo(a.oldInfo.size));
@@ -95,8 +111,10 @@ void report(List<CommonElement> commonElements, {orderBySize = false}) {
95111
if (oldSize == newSize) {
96112
print('${element.name}: ${element.oldInfo.size} bytes');
97113
} else {
98-
print('${element.name}: ${element.oldInfo.size} -> '
99-
'${element.newInfo.size} bytes');
114+
print(
115+
'${element.name}: ${element.oldInfo.size} -> '
116+
'${element.newInfo.size} bytes',
117+
);
100118
}
101119
}
102120
}
@@ -128,10 +146,12 @@ void reportPackages(List<CommonElement> commonElements, {orderBySize = false}) {
128146
newSizeTotal += newPackageSize;
129147
});
130148

131-
_section('COMMON ELEMENTS (PACKAGES)',
132-
elementCount: oldPackageInfo.keys.length,
133-
oldSizeTotal: oldSizeTotal,
134-
newSizeTotal: newSizeTotal);
149+
_section(
150+
'COMMON ELEMENTS (PACKAGES)',
151+
elementCount: oldPackageInfo.keys.length,
152+
oldSizeTotal: oldSizeTotal,
153+
newSizeTotal: newSizeTotal,
154+
);
135155

136156
var packageInfoEntries = oldPackageInfo.entries.toList();
137157

@@ -152,15 +172,19 @@ void reportPackages(List<CommonElement> commonElements, {orderBySize = false}) {
152172
}
153173
}
154174

155-
void _section(String title,
156-
{required int elementCount,
157-
required int oldSizeTotal,
158-
required int newSizeTotal}) {
175+
void _section(
176+
String title, {
177+
required int elementCount,
178+
required int oldSizeTotal,
179+
required int newSizeTotal,
180+
}) {
159181
if (oldSizeTotal == newSizeTotal) {
160182
print('$title ($elementCount common elements, $oldSizeTotal bytes)');
161183
} else {
162-
print('$title ($elementCount common elements, '
163-
'$oldSizeTotal bytes -> $newSizeTotal bytes)');
184+
print(
185+
'$title ($elementCount common elements, '
186+
'$oldSizeTotal bytes -> $newSizeTotal bytes)',
187+
);
164188
}
165189
print('=' * 72);
166190
}

pkg/dart2js_info/bin/src/convert.dart

Lines changed: 17 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -25,16 +25,22 @@ class ConvertCommand extends Command<void> with PrintUsageException {
2525
void _addSubcommand(Command<void> command) {
2626
addSubcommand(command);
2727
command.argParser
28-
..addOption('out',
29-
abbr: 'o',
30-
help: 'Output file '
31-
'(to_json defauts to <input>.json, to_binary defaults to\n'
32-
'<input>.data, and to_proto defaults to <input>.pb)')
33-
..addFlag('inject-text',
34-
negatable: false,
35-
help: 'Whether to inject output code snippets.\n\n'
36-
'By default dart2js produces code spans, but excludes the text. This\n'
37-
'option can be used to embed the text directly in the output.\n'
38-
'Note: this requires access to dart2js output files.\n');
28+
..addOption(
29+
'out',
30+
abbr: 'o',
31+
help:
32+
'Output file '
33+
'(to_json defauts to <input>.json, to_binary defaults to\n'
34+
'<input>.data, and to_proto defaults to <input>.pb)',
35+
)
36+
..addFlag(
37+
'inject-text',
38+
negatable: false,
39+
help:
40+
'Whether to inject output code snippets.\n\n'
41+
'By default dart2js produces code spans, but excludes the text. This\n'
42+
'option can be used to embed the text directly in the output.\n'
43+
'Note: this requires access to dart2js output files.\n',
44+
);
3945
}
4046
}

pkg/dart2js_info/bin/src/coverage_log_server.dart

Lines changed: 50 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -41,16 +41,24 @@ class CoverageLogServerCommand extends Command<void> with PrintUsageException {
4141
CoverageLogServerCommand() {
4242
argParser
4343
..addOption('port', abbr: 'p', help: 'port number', defaultsTo: "8080")
44-
..addOption('host',
45-
help: 'host name (use 0.0.0.0 for all interfaces)',
46-
defaultsTo: 'localhost')
47-
..addOption('uri-prefix',
48-
help:
49-
'uri path prefix that will hit this server. This will be injected'
50-
' into the .js file',
51-
defaultsTo: '')
52-
..addOption('out',
53-
abbr: 'o', help: 'output log file', defaultsTo: _defaultOutTemplate);
44+
..addOption(
45+
'host',
46+
help: 'host name (use 0.0.0.0 for all interfaces)',
47+
defaultsTo: 'localhost',
48+
)
49+
..addOption(
50+
'uri-prefix',
51+
help:
52+
'uri path prefix that will hit this server. This will be injected'
53+
' into the .js file',
54+
defaultsTo: '',
55+
)
56+
..addOption(
57+
'out',
58+
abbr: 'o',
59+
help: 'output log file',
60+
defaultsTo: _defaultOutTemplate,
61+
);
5462
}
5563

5664
@override
@@ -67,8 +75,14 @@ class CoverageLogServerCommand extends Command<void> with PrintUsageException {
6775
}
6876
var outPath = args['out'];
6977
if (outPath == _defaultOutTemplate) outPath = '$jsPath.coverage.json';
70-
var server = _Server(args['host'], int.parse(args['port']), jsPath,
71-
htmlPath, outPath, args['uri-prefix']);
78+
var server = _Server(
79+
args['host'],
80+
int.parse(args['port']),
81+
jsPath,
82+
htmlPath,
83+
outPath,
84+
args['uri-prefix'],
85+
);
7286
await server.run();
7387
}
7488
}
@@ -108,19 +122,26 @@ class _Server {
108122

109123
String get _serializedData => JsonEncoder.withIndent(' ').convert(data);
110124

111-
_Server(this.hostname, this.port, this.jsPath, this.htmlPath, this.outPath,
112-
String prefix)
113-
: jsCode = _adjustRequestUrl(File(jsPath).readAsStringSync(), prefix),
114-
prefix = _normalize(prefix);
125+
_Server(
126+
this.hostname,
127+
this.port,
128+
this.jsPath,
129+
this.htmlPath,
130+
this.outPath,
131+
String prefix,
132+
) : jsCode = _adjustRequestUrl(File(jsPath).readAsStringSync(), prefix),
133+
prefix = _normalize(prefix);
115134

116135
Future<void> run() async {
117136
await shelf.serve(_handler, hostname, port);
118137
var urlBase = "http://$hostname:$port${prefix == '' ? '/' : '/$prefix/'}";
119138
var htmlFilename = htmlPath == null ? '' : path.basename(htmlPath!);
120-
print("Server is listening\n"
121-
" - html page: $urlBase$htmlFilename\n"
122-
" - js code: $urlBase${path.basename(jsPath)}\n"
123-
" - coverage reporting: ${urlBase}coverage\n");
139+
print(
140+
"Server is listening\n"
141+
" - html page: $urlBase$htmlFilename\n"
142+
" - js code: $urlBase${path.basename(jsPath)}\n"
143+
" - coverage reporting: ${urlBase}coverage\n",
144+
);
124145
}
125146

126147
String _expectedPath(String tail) => prefix == '' ? tail : '$prefix/$tail';
@@ -136,9 +157,10 @@ class _Server {
136157
if (urlPath == prefix ||
137158
urlPath == '$prefix/' ||
138159
urlPath == _expectedPath(baseHtmlName)) {
139-
var contents = htmlPath == null
140-
? '<html><script src="$baseJsName"></script>'
141-
: await File(htmlPath!).readAsString();
160+
var contents =
161+
htmlPath == null
162+
? '<html><script src="$baseJsName"></script>'
163+
: await File(htmlPath!).readAsString();
142164
return shelf.Response.ok(contents, headers: _htmlHeaders);
143165
}
144166

@@ -180,9 +202,11 @@ class _Server {
180202
await Future.delayed(Duration(seconds: 3));
181203
await File(outPath).writeAsString(_serializedData);
182204
var diff = data.length - _total;
183-
print(diff == 0
184-
? ' - no new element covered'
185-
: ' - $diff new elements covered');
205+
print(
206+
diff == 0
207+
? ' - no new element covered'
208+
: ' - $diff new elements covered',
209+
);
186210
_savePending = false;
187211
_total = data.length;
188212
}

0 commit comments

Comments
 (0)