Skip to content

Commit 4d3d70a

Browse files
jensjohaCommit Queue
authored andcommitted
[kernel] Format kernel
Kernel sdk version was bumped from 3.6 to 3.12 in https://dart-review.googlesource.com/c/sdk/+/487542 (and to `^3.12.0-0` in https://dart-review.googlesource.com/c/sdk/+/487880) but the source was never formatted. This is, if nothing else, bad for reviews, where editing a file changes the file in lots of places because of new formatting. This CL is the result of running ``` out/ReleaseX64/dart-sdk/bin/dart format pkg/kernel/ ``` but also updates the formatter version used by a source generator (`pkg/front_end/tool/visitor_generator.dart`) so things agree. Change-Id: I66e35d4f1e2d08cecc30fb314546cae78b49e99b Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/490082 Reviewed-by: Chloe Stefantsova <cstefantsova@google.com> Reviewed-by: Johnni Winther <johnniwinther@google.com> Commit-Queue: Jens Johansen <jensj@google.com>
1 parent 9ad39ca commit 4d3d70a

120 files changed

Lines changed: 20012 additions & 10359 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

pkg/front_end/tool/visitor_generator.dart

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
// BSD-style license that can be found in the LICENSE file.
44

55
import 'package:dart_style/dart_style.dart' show DartFormatter;
6+
import 'package:pub_semver/pub_semver.dart' as semver;
67

78
import 'ast_model.dart';
89

@@ -75,7 +76,7 @@ String generateVisitor(
7576
String result = sb.toString();
7677
if (format) {
7778
result = new DartFormatter(
78-
languageVersion: DartFormatter.latestShortStyleLanguageVersion,
79+
languageVersion: semver.Version(3, 12, 0),
7980
).format(result);
8081
}
8182
return result;

pkg/kernel/bin/compare_hierarchies.dart

Lines changed: 41 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,10 @@ import 'package:kernel/src/tool/command_line_util.dart';
1313
void usage() {
1414
print("Compares the hierarchies of two dill files.");
1515
print("");
16-
print("Usage: dart <script> dillFile1.dill dillFile2.dill "
17-
"[import:uri#classToIgnore|another:uri#andClassToIgnore]");
16+
print(
17+
"Usage: dart <script> dillFile1.dill dillFile2.dill "
18+
"[import:uri#classToIgnore|another:uri#andClassToIgnore]",
19+
);
1820
exit(1);
1921
}
2022

@@ -30,8 +32,10 @@ void main(List<String> args) {
3032
for (String ignore in ignores) {
3133
List<String> uriClassName = ignore.split("#");
3234
if (uriClassName.length != 2) {
33-
print("Ignoring '$ignore' as it doesn't conform to "
34-
"'importUri#className'");
35+
print(
36+
"Ignoring '$ignore' as it doesn't conform to "
37+
"'importUri#className'",
38+
);
3539
continue;
3640
}
3741
Uri uri = Uri.parse(uriClassName[0]);
@@ -59,10 +63,14 @@ void main(List<String> args) {
5963
for (Uri uri in agreeingImportUris) {
6064
Library lib1 = libMap1[uri]!;
6165
Library lib2 = libMap2[uri]!;
62-
Map<String, Class> libClass1 =
63-
createPublicClassMap(lib1, ignored: ignoresMap[uri]);
64-
Map<String, Class> libClass2 =
65-
createPublicClassMap(lib2, ignored: ignoresMap[uri]);
66+
Map<String, Class> libClass1 = createPublicClassMap(
67+
lib1,
68+
ignored: ignoresMap[uri],
69+
);
70+
Map<String, Class> libClass2 = createPublicClassMap(
71+
lib2,
72+
ignored: ignoresMap[uri],
73+
);
6674
Set<String> agreeingClasses = new Set<String>.from(libClass1.keys)
6775
..retainAll(libClass2.keys);
6876
if (agreeingClasses.length != libClass1.length ||
@@ -84,24 +92,30 @@ void main(List<String> args) {
8492
Class c1 = libClass1[className]!;
8593
Class c2 = libClass2[className]!;
8694
Set<ClassReference> c1Supertypes = createClassReferenceSet(
87-
ch1.getAllSupertypeClassesForTesting(c1),
88-
onlyPublic: true,
89-
ignoresMap: ignoresMap);
95+
ch1.getAllSupertypeClassesForTesting(c1),
96+
onlyPublic: true,
97+
ignoresMap: ignoresMap,
98+
);
9099
Set<ClassReference> c2Supertypes = createClassReferenceSet(
91-
ch2.getAllSupertypeClassesForTesting(c2),
92-
onlyPublic: true,
93-
ignoresMap: ignoresMap);
100+
ch2.getAllSupertypeClassesForTesting(c2),
101+
onlyPublic: true,
102+
ignoresMap: ignoresMap,
103+
);
94104
Set<ClassReference> missing = new Set<ClassReference>.from(c1Supertypes)
95105
..removeAll(c2Supertypes);
96106
if (missing.isNotEmpty) {
97-
print("$c1 in $lib1 from (1) has these extra supertypes: "
98-
"${missing.toList()}");
107+
print(
108+
"$c1 in $lib1 from (1) has these extra supertypes: "
109+
"${missing.toList()}",
110+
);
99111
}
100112
missing = new Set<ClassReference>.from(c2Supertypes)
101113
..removeAll(c1Supertypes);
102114
if (missing.isNotEmpty) {
103-
print("$c2 in $lib2 from (2) has these extra supertypes: "
104-
"${missing.toList()}");
115+
print(
116+
"$c2 in $lib2 from (2) has these extra supertypes: "
117+
"${missing.toList()}",
118+
);
105119
}
106120
}
107121
}
@@ -115,8 +129,10 @@ Map<Uri, Library> createLibMap(Component c) {
115129
return map;
116130
}
117131

118-
Map<String, Class> createPublicClassMap(Library lib,
119-
{required Set<String>? ignored}) {
132+
Map<String, Class> createPublicClassMap(
133+
Library lib, {
134+
required Set<String>? ignored,
135+
}) {
120136
Map<String, Class> map = {};
121137
for (Class c in lib.classes) {
122138
if (c.name.startsWith("_")) continue;
@@ -126,8 +142,11 @@ Map<String, Class> createPublicClassMap(Library lib,
126142
return map;
127143
}
128144

129-
Set<ClassReference> createClassReferenceSet(List<Class> classes,
130-
{required bool onlyPublic, required Map<Uri, Set<String>> ignoresMap}) {
145+
Set<ClassReference> createClassReferenceSet(
146+
List<Class> classes, {
147+
required bool onlyPublic,
148+
required Map<Uri, Set<String>> ignoresMap,
149+
}) {
131150
Set<ClassReference> result = {};
132151
for (Class c in classes) {
133152
if (onlyPublic && c.name.startsWith("_")) continue;

pkg/kernel/bin/count_breakdown.dart

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,11 @@ void usage() {
1818
}
1919

2020
void main(List<String> args) {
21-
CommandLineHelper.requireExactlyOneArgument(args, usage,
22-
requireFileExists: true);
21+
CommandLineHelper.requireExactlyOneArgument(
22+
args,
23+
usage,
24+
requireFileExists: true,
25+
);
2326
Component component = CommandLineHelper.tryLoadDill(args[0]);
2427
TypeCounter counter = new TypeCounter();
2528
component.accept(counter);

pkg/kernel/bin/dill_extractor.dart

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,8 @@ void main(List<String> args) {
2424
print("Warning: ${args[1]} is an existing dir.");
2525
} else if (!dir.parent.existsSync()) {
2626
print(
27-
"Warning: ${dir.parent} is not an existing dir, but will be created.");
27+
"Warning: ${dir.parent} is not an existing dir, but will be created.",
28+
);
2829
dir.createSync(recursive: true);
2930
} else {
3031
dir.createSync();
@@ -47,7 +48,8 @@ void main(List<String> args) {
4748
Set<MapEntry<Uri, Source>> nonPackageUris = {};
4849
int writes = 0;
4950
for (MapEntry<Uri, Source> sourceEntry in component.uriToSource.entries) {
50-
Uri uri = sourceEntry.value.importUri ??
51+
Uri uri =
52+
sourceEntry.value.importUri ??
5153
sourceEntry.value.fileUri ??
5254
sourceEntry.key;
5355
Uri fileUri = sourceEntry.key;
@@ -138,7 +140,7 @@ void main(List<String> args) {
138140
"name": package.key,
139141
"rootUri": "../${package.key}",
140142
"packageUri": "lib/",
141-
"languageVersion": version.toText()
143+
"languageVersion": version.toText(),
142144
});
143145
}
144146
File.fromUri(dir.uri.resolve(".dart_tool/package_config.json"))

pkg/kernel/bin/dill_forensic.dart

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -58,14 +58,17 @@ List<Component> splitAndRead(Uint8List bytes) {
5858
bytes[index + 2] == magicTagBytes[2] &&
5959
bytes[index + 3] == magicTagBytes[3]) {
6060
// Try to read binary version too and see if it matches.
61-
int version = (bytes[index + 4] << 24) |
61+
int version =
62+
(bytes[index + 4] << 24) |
6263
(bytes[index + 5] << 16) |
6364
(bytes[index + 6] << 8) |
6465
bytes[index + 7];
6566
if (version != Tag.BinaryFormatVersion) {
66-
print("Found tag, but version mismatches "
67-
"('$version' vs readable version '${Tag.BinaryFormatVersion}'). "
68-
"Try again in a different checkout.");
67+
print(
68+
"Found tag, but version mismatches "
69+
"('$version' vs readable version '${Tag.BinaryFormatVersion}'). "
70+
"Try again in a different checkout.",
71+
);
6972
} else {
7073
tagOffsets.add(index);
7174
}
@@ -86,16 +89,21 @@ List<Component> splitAndRead(Uint8List bytes) {
8689
// Cut bytes and try to load.
8790
int fromOffset = tagOffsets[fromIndex];
8891
int toOffset = tagOffsets[toIndex];
89-
Uint8List bytesView =
90-
new Uint8List.sublistView(bytes, fromOffset, toOffset);
92+
Uint8List bytesView = new Uint8List.sublistView(
93+
bytes,
94+
fromOffset,
95+
toOffset,
96+
);
9197
try {
9298
Component loaded = loadComponentFromBytes(bytesView);
9399
components.add(loaded);
94100
print("Loaded from tag ${fromIndex} to ${toIndex}.");
95101
break;
96102
} catch (e) {
97-
print("Failed loading from tag ${fromIndex} to ${toIndex}"
98-
" (${toOffset - fromOffset} bytes).");
103+
print(
104+
"Failed loading from tag ${fromIndex} to ${toIndex}"
105+
" (${toOffset - fromOffset} bytes).",
106+
);
99107
toIndex++;
100108
}
101109
}

pkg/kernel/bin/size_breakdown.dart

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,11 @@ void usage() {
2020
}
2121

2222
void main(args) {
23-
CommandLineHelper.requireExactlyOneArgument(args, usage,
24-
requireFileExists: true);
23+
CommandLineHelper.requireExactlyOneArgument(
24+
args,
25+
usage,
26+
requireFileExists: true,
27+
);
2528
List<int> bytes = new File(args[0]).readAsBytesSync();
2629
try {
2730
Component p = new Component();

pkg/kernel/bin/split.dart

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,11 @@ void usage() {
2121
}
2222

2323
void main(args) async {
24-
CommandLineHelper.requireExactlyOneArgument(args, usage,
25-
requireFileExists: true);
24+
CommandLineHelper.requireExactlyOneArgument(
25+
args,
26+
usage,
27+
requireFileExists: true,
28+
);
2629
Component binary = CommandLineHelper.tryLoadDill(args[0]);
2730

2831
int part = 1;
@@ -40,12 +43,17 @@ void main(args) async {
4043
}
4144

4245
Future<Null> writeComponentToFile(
43-
Component component, String path, Library wantedLibrary) async {
46+
Component component,
47+
String path,
48+
Library wantedLibrary,
49+
) async {
4450
File output = new File(path);
4551
IOSink sink = output.openWrite();
4652
try {
47-
BinaryPrinter printer =
48-
new BinaryPrinter(sink, libraryFilter: (lib) => lib == wantedLibrary);
53+
BinaryPrinter printer = new BinaryPrinter(
54+
sink,
55+
libraryFilter: (lib) => lib == wantedLibrary,
56+
);
4957
printer.writeComponentFile(component);
5058
} finally {
5159
await sink.close();

pkg/kernel/bin/switch_order.dart

Lines changed: 28 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,9 @@ void main(List<String> args) {
2323
List<int> bytes = new File(arg).readAsBytesSync();
2424
try {
2525
Component p = new Component();
26-
WrappedBinaryBuilder wrappedBinaryBuilder =
27-
new WrappedBinaryBuilder(bytes)..readComponent(p);
26+
WrappedBinaryBuilder wrappedBinaryBuilder = new WrappedBinaryBuilder(
27+
bytes,
28+
)..readComponent(p);
2829
expressionAverages.add(average(wrappedBinaryBuilder.expressionTypes));
2930
initializerAverages.add(average(wrappedBinaryBuilder.initializerTypes));
3031
statementAverages.add(average(wrappedBinaryBuilder.statementTypes));
@@ -35,9 +36,11 @@ void main(List<String> args) {
3536
sumInto(sum, wrappedBinaryBuilder.statementTypes);
3637
sumInto(sum, wrappedBinaryBuilder.typeTypes);
3738
} catch (e) {
38-
print("Error when reading '$arg'. Dill file expected.\n"
39-
"Got error: '$e'.\n\n"
40-
"Skipping.");
39+
print(
40+
"Error when reading '$arg'. Dill file expected.\n"
41+
"Got error: '$e'.\n\n"
42+
"Skipping.",
43+
);
4144
continue;
4245
}
4346
}
@@ -52,7 +55,10 @@ void main(List<String> args) {
5255
}
5356

5457
void printSummary(
55-
String headline, List<List<double>> data, List<int> totalRead) {
58+
String headline,
59+
List<List<double>> data,
60+
List<int> totalRead,
61+
) {
5662
if (data.isEmpty) {
5763
print("$headline: No data.");
5864
return;
@@ -82,18 +88,24 @@ void printSummary(
8288
String? tagName = getNameOfTag(i);
8389
String tagNameExtra = tagName == null ? "" : " ($tagName) ";
8490
if (minPercentages[i] != maxPercentages[i]) {
85-
printMe.add(new SortableDataString(
91+
printMe.add(
92+
new SortableDataString(
8693
average,
8794
"$i$tagNameExtra: ${formatPercent(average)} ("
8895
"${formatPercent(minPercentages[i])} - "
8996
"${formatPercent(maxPercentages[i])}) ("
90-
"${totalRead[i]} totally recorded)."));
97+
"${totalRead[i]} totally recorded).",
98+
),
99+
);
91100
} else {
92-
printMe.add(new SortableDataString(
101+
printMe.add(
102+
new SortableDataString(
93103
average,
94104
"$i$tagNameExtra: "
95105
"${formatPercent(average)} ("
96-
"${totalRead[i]} totally recorded)."));
106+
"${totalRead[i]} totally recorded).",
107+
),
108+
);
97109
}
98110
}
99111
printMe.sort();
@@ -146,10 +158,12 @@ class WrappedBinaryBuilder extends BinaryBuilder {
146158
List<int> typeTypes = List<int>.filled(255, 0);
147159

148160
WrappedBinaryBuilder(var _bytes)
149-
: super(_bytes,
150-
disableLazyReading: true,
151-
disableLazyClassReading: true,
152-
useGrowableLists: false);
161+
: super(
162+
_bytes,
163+
disableLazyReading: true,
164+
disableLazyClassReading: true,
165+
useGrowableLists: false,
166+
);
153167

154168
@override
155169
Expression readExpression() {

pkg/kernel/bin/type_check.dart

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,11 @@ void usage() {
1919
}
2020

2121
void main(List<String> args) {
22-
CommandLineHelper.requireExactlyOneArgument(args, usage,
23-
requireFileExists: true);
22+
CommandLineHelper.requireExactlyOneArgument(
23+
args,
24+
usage,
25+
requireFileExists: true,
26+
);
2427
final binary = CommandLineHelper.tryLoadDill(args[0]);
2528
ErrorFormatter errorFormatter = new ErrorFormatter();
2629
new NaiveTypeChecker(errorFormatter, binary)..checkComponent(binary);

0 commit comments

Comments
 (0)