Auto-format Framework (#160545)

This auto-formats all *.dart files in the repository outside of the
`engine` subdirectory and enforces that these files stay formatted with
a presubmit check.

**Reviewers:** Please carefully review all the commits except for the
one titled "formatted". The "formatted" commit was auto-generated by
running `dev/tools/format.sh -a -f`. The other commits were hand-crafted
to prepare the repo for the formatting change. I recommend reviewing the
commits one-by-one via the "Commits" tab and avoiding Github's "Files
changed" tab as it will likely slow down your browser because of the
size of this PR.

---------

Co-authored-by: Kate Lovett <katelovett@google.com>
Co-authored-by: LongCatIsLooong <31859944+LongCatIsLooong@users.noreply.github.com>
This commit is contained in:
Michael Goderbauer
2024-12-19 12:06:21 -08:00
committed by GitHub
parent 8e0993eda8
commit 5491c8c146
4411 changed files with 455108 additions and 415991 deletions

View File

@@ -15,20 +15,22 @@ const List<int> kPointerActions = <int>[
const double kDoubleErrorMargin = 1e-4;
String diffMotionEvents(
Map<String, dynamic> originalEvent,
Map<String, dynamic> synthesizedEvent,
) {
String diffMotionEvents(Map<String, dynamic> originalEvent, Map<String, dynamic> synthesizedEvent) {
final StringBuffer diff = StringBuffer();
diffMaps(originalEvent, synthesizedEvent, diff, excludeKeys: const <String>[
'pointerProperties', // Compared separately.
'pointerCoords', // Compared separately.
'source', // Unused by Flutter.
'deviceId', // Android documentation says that's an arbitrary number that shouldn't be depended on.
'action', // Compared separately.
'motionEventId', // TODO(kaushikiska): add support for motion event diffing, https://github.com/flutter/flutter/issues/61022.
]);
diffMaps(
originalEvent,
synthesizedEvent,
diff,
excludeKeys: const <String>[
'pointerProperties', // Compared separately.
'pointerCoords', // Compared separately.
'source', // Unused by Flutter.
'deviceId', // Android documentation says that's an arbitrary number that shouldn't be depended on.
'action', // Compared separately.
'motionEventId', // TODO(kaushikiska): add support for motion event diffing, https://github.com/flutter/flutter/issues/61022.
],
);
diffActions(diff, originalEvent, synthesizedEvent);
diffPointerProperties(diff, originalEvent, synthesizedEvent);
@@ -37,19 +39,24 @@ String diffMotionEvents(
return diff.toString();
}
void diffActions(StringBuffer diffBuffer, Map<String, dynamic> originalEvent,
Map<String, dynamic> synthesizedEvent) {
final int synthesizedActionMasked =
getActionMasked(synthesizedEvent['action'] as int);
void diffActions(
StringBuffer diffBuffer,
Map<String, dynamic> originalEvent,
Map<String, dynamic> synthesizedEvent,
) {
final int synthesizedActionMasked = getActionMasked(synthesizedEvent['action'] as int);
final int originalActionMasked = getActionMasked(originalEvent['action'] as int);
final String synthesizedActionName =
getActionName(synthesizedActionMasked, synthesizedEvent['action'] as int);
final String originalActionName =
getActionName(originalActionMasked, originalEvent['action'] as int);
final String synthesizedActionName = getActionName(
synthesizedActionMasked,
synthesizedEvent['action'] as int,
);
final String originalActionName = getActionName(
originalActionMasked,
originalEvent['action'] as int,
);
if (synthesizedActionMasked != originalActionMasked) {
diffBuffer.write(
'action (expected: $originalActionName actual: $synthesizedActionName) ');
diffBuffer.write('action (expected: $originalActionName actual: $synthesizedActionName) ');
}
if (kPointerActions.contains(originalActionMasked) &&
@@ -58,13 +65,17 @@ void diffActions(StringBuffer diffBuffer, Map<String, dynamic> originalEvent,
final int synthesizedPointer = getPointerIdx(synthesizedEvent['action'] as int);
if (originalPointer != synthesizedPointer) {
diffBuffer.write(
'pointerIdx (expected: $originalPointer actual: $synthesizedPointer action: $originalActionName ');
'pointerIdx (expected: $originalPointer actual: $synthesizedPointer action: $originalActionName ',
);
}
}
}
void diffPointerProperties(StringBuffer diffBuffer,
Map<String, dynamic> originalEvent, Map<String, dynamic> synthesizedEvent) {
void diffPointerProperties(
StringBuffer diffBuffer,
Map<String, dynamic> originalEvent,
Map<String, dynamic> synthesizedEvent,
) {
final List<Map<dynamic, dynamic>> expectedList =
(originalEvent['pointerProperties'] as List<dynamic>).cast<Map<dynamic, dynamic>>();
final List<Map<dynamic, dynamic>> actualList =
@@ -72,21 +83,23 @@ void diffPointerProperties(StringBuffer diffBuffer,
if (expectedList.length != actualList.length) {
diffBuffer.write(
'pointerProperties (actual length: ${actualList.length}, expected length: ${expectedList.length} ');
'pointerProperties (actual length: ${actualList.length}, expected length: ${expectedList.length} ',
);
return;
}
for (int i = 0; i < expectedList.length; i++) {
final Map<String, dynamic> expected =
expectedList[i].cast<String, dynamic>();
final Map<String, dynamic> expected = expectedList[i].cast<String, dynamic>();
final Map<String, dynamic> actual = actualList[i].cast<String, dynamic>();
diffMaps(expected, actual, diffBuffer,
messagePrefix: '[pointerProperty $i] ');
diffMaps(expected, actual, diffBuffer, messagePrefix: '[pointerProperty $i] ');
}
}
void diffPointerCoordsList(StringBuffer diffBuffer,
Map<String, dynamic> originalEvent, Map<String, dynamic> synthesizedEvent) {
void diffPointerCoordsList(
StringBuffer diffBuffer,
Map<String, dynamic> originalEvent,
Map<String, dynamic> synthesizedEvent,
) {
final List<Map<dynamic, dynamic>> expectedList =
(originalEvent['pointerCoords'] as List<dynamic>).cast<Map<dynamic, dynamic>>();
final List<Map<dynamic, dynamic>> actualList =
@@ -94,20 +107,24 @@ void diffPointerCoordsList(StringBuffer diffBuffer,
if (expectedList.length != actualList.length) {
diffBuffer.write(
'pointerCoords (actual length: ${actualList.length}, expected length: ${expectedList.length} ');
'pointerCoords (actual length: ${actualList.length}, expected length: ${expectedList.length} ',
);
return;
}
for (int i = 0; i < expectedList.length; i++) {
final Map<String, dynamic> expected =
expectedList[i].cast<String, dynamic>();
final Map<String, dynamic> expected = expectedList[i].cast<String, dynamic>();
final Map<String, dynamic> actual = actualList[i].cast<String, dynamic>();
diffPointerCoords(expected, actual, i, diffBuffer);
}
}
void diffPointerCoords(Map<String, dynamic> expected,
Map<String, dynamic> actual, int pointerIdx, StringBuffer diffBuffer) {
void diffPointerCoords(
Map<String, dynamic> expected,
Map<String, dynamic> actual,
int pointerIdx,
StringBuffer diffBuffer,
) {
diffMaps(expected, actual, diffBuffer, messagePrefix: '[pointerCoord $pointerIdx] ');
}
@@ -120,8 +137,7 @@ void diffMaps(
}) {
const IterableEquality<String> eq = IterableEquality<String>();
if (!eq.equals(expected.keys, actual.keys)) {
diffBuffer.write(
'${messagePrefix}keys (expected: ${expected.keys} actual: ${actual.keys} ');
diffBuffer.write('${messagePrefix}keys (expected: ${expected.keys} actual: ${actual.keys} ');
return;
}
for (final String key in expected.keys) {
@@ -133,8 +149,7 @@ void diffMaps(
}
if (expected[key] != actual[key]) {
diffBuffer.write(
'$messagePrefix$key (expected: ${expected[key]} actual: ${actual[key]}) ');
diffBuffer.write('$messagePrefix$key (expected: ${expected[key]} actual: ${actual[key]}) ');
}
}
}