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

@@ -13,19 +13,18 @@ import 'utils.dart';
/// Generates the key mapping for Windows, based on the information in the key
/// data structure given to it.
class WindowsCodeGenerator extends PlatformCodeGenerator {
WindowsCodeGenerator(
super.keyData,
super.logicalData,
String scancodeToLogical,
) : _scancodeToLogical = parseMapOfString(scancodeToLogical);
WindowsCodeGenerator(super.keyData, super.logicalData, String scancodeToLogical)
: _scancodeToLogical = parseMapOfString(scancodeToLogical);
/// This generates the map of Windows scan codes to physical keys.
String get _windowsScanCodeMap {
final OutputLines<int> lines = OutputLines<int>('Windows scancode map');
for (final PhysicalKeyEntry entry in keyData.entries) {
if (entry.windowsScanCode != null) {
lines.add(entry.windowsScanCode!,
' {${toHex(entry.windowsScanCode)}, ${toHex(entry.usbHidCode)}}, // ${entry.constantName}');
lines.add(
entry.windowsScanCode!,
' {${toHex(entry.windowsScanCode)}, ${toHex(entry.usbHidCode)}}, // ${entry.constantName}',
);
}
}
return lines.sortedJoin().trimRight();
@@ -35,13 +34,13 @@ class WindowsCodeGenerator extends PlatformCodeGenerator {
String get _windowsLogicalKeyCodeMap {
final OutputLines<int> lines = OutputLines<int>('Windows logical map');
for (final LogicalKeyEntry entry in logicalData.entries) {
zipStrict(entry.windowsValues, entry.windowsNames,
(int windowsValue, String windowsName) {
lines.add(windowsValue,
' {${toHex(windowsValue)}, ${toHex(entry.value, digits: 11)}}, '
'// $windowsName -> ${entry.constantName}');
},
);
zipStrict(entry.windowsValues, entry.windowsNames, (int windowsValue, String windowsName) {
lines.add(
windowsValue,
' {${toHex(windowsValue)}, ${toHex(entry.value, digits: 11)}}, '
'// $windowsName -> ${entry.constantName}',
);
});
}
return lines.sortedJoin().trimRight();
}
@@ -56,12 +55,15 @@ class WindowsCodeGenerator extends PlatformCodeGenerator {
_scancodeToLogical.forEach((String scanCodeName, String logicalName) {
final PhysicalKeyEntry physicalEntry = keyData.entryByName(scanCodeName);
final LogicalKeyEntry logicalEntry = logicalData.entryByName(logicalName);
lines.add(physicalEntry.windowsScanCode!,
' {${toHex(physicalEntry.windowsScanCode)}, ${toHex(logicalEntry.value, digits: 11)}}, '
'// ${physicalEntry.constantName} -> ${logicalEntry.constantName}');
lines.add(
physicalEntry.windowsScanCode!,
' {${toHex(physicalEntry.windowsScanCode)}, ${toHex(logicalEntry.value, digits: 11)}}, '
'// ${physicalEntry.constantName} -> ${logicalEntry.constantName}',
);
});
return lines.sortedJoin().trimRight();
}
final Map<String, String> _scancodeToLogical;
/// This generates the mask values for the part of a key code that defines its plane.
@@ -73,7 +75,9 @@ class WindowsCodeGenerator extends PlatformCodeGenerator {
kWindowsPlane,
];
for (final MaskConstant constant in maskConstants) {
buffer.writeln('const uint64_t KeyboardKeyEmbedderHandler::${constant.lowerCamelName} = ${toHex(constant.value, digits: 11)};');
buffer.writeln(
'const uint64_t KeyboardKeyEmbedderHandler::${constant.lowerCamelName} = ${toHex(constant.value, digits: 11)};',
);
}
return buffer.toString().trimRight();
}
@@ -82,8 +86,13 @@ class WindowsCodeGenerator extends PlatformCodeGenerator {
String get templatePath => path.join(dataRoot, 'windows_flutter_key_map_cc.tmpl');
@override
String outputPath(String platform) => path.join(PlatformCodeGenerator.engineRoot,
'shell', 'platform', 'windows', 'flutter_key_map.g.cc');
String outputPath(String platform) => path.join(
PlatformCodeGenerator.engineRoot,
'shell',
'platform',
'windows',
'flutter_key_map.g.cc',
);
@override
Map<String, String> mappings() {