Skip to content

Commit 3353a3e

Browse files
committed
Reformat
1 parent b631860 commit 3353a3e

2 files changed

Lines changed: 18 additions & 87 deletions

File tree

engine/src/flutter/tools/api_check/lib/apicheck.dart

Lines changed: 8 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -55,10 +55,7 @@ Future<List<String>> getDartClassFields({
5555
///
5656
/// Enum values are expected to be of the form `kEnumNameFooBar`; prefixed with
5757
/// `kEnumName`.
58-
List<String> getCppEnumValues({
59-
required String sourcePath,
60-
required String enumName,
61-
}) {
58+
List<String> getCppEnumValues({required String sourcePath, required String enumName}) {
6259
final List<String> lines = File(sourcePath).readAsLinesSync();
6360
final int enumEnd = lines.indexOf('} $enumName;');
6461
if (enumEnd < 0) {
@@ -69,19 +66,13 @@ List<String> getCppEnumValues({
6966
return <String>[];
7067
}
7168
final valueExp = RegExp('^\\s*k$enumName(\\w*)');
72-
return _extractMatchingExpression(
73-
lines: lines.sublist(enumStart + 1, enumEnd),
74-
regexp: valueExp,
75-
);
69+
return _extractMatchingExpression(lines: lines.sublist(enumStart + 1, enumEnd), regexp: valueExp);
7670
}
7771

7872
/// Returns all values in [enumName].
7973
///
8074
/// Enum values are expected to be of the form `kFooBar`; prefixed with `k`.
81-
List<String> getCppEnumClassValues({
82-
required String sourcePath,
83-
required String enumName,
84-
}) {
75+
List<String> getCppEnumClassValues({required String sourcePath, required String enumName}) {
8576
final List<String> lines = _getBlockStartingWith(
8677
source: File(sourcePath).readAsStringSync(),
8778
startExp: RegExp('enum class $enumName .* {'),
@@ -94,10 +85,7 @@ List<String> getCppEnumClassValues({
9485
///
9586
/// Enum value declarations are expected to be of the form `FOO_BAR(1 << N)`;
9687
/// in all caps.
97-
List<String> getJavaEnumValues({
98-
required String sourcePath,
99-
required String enumName,
100-
}) {
88+
List<String> getJavaEnumValues({required String sourcePath, required String enumName}) {
10189
final List<String> lines = _getBlockStartingWith(
10290
source: File(sourcePath).readAsStringSync(),
10391
startExp: RegExp('enum $enumName {'),
@@ -126,10 +114,7 @@ List<String> getSwiftOptionSetProperties({
126114
///
127115
/// The contents of the first match group in [regexp] is returned; therefore
128116
/// it must contain a match group.
129-
List<String> _extractMatchingExpression({
130-
required Iterable<String> lines,
131-
required RegExp regexp,
132-
}) {
117+
List<String> _extractMatchingExpression({required Iterable<String> lines, required RegExp regexp}) {
133118
final values = <String>[];
134119
for (final line in lines) {
135120
final RegExpMatch? match = regexp.firstMatch(line);
@@ -143,10 +128,7 @@ List<String> _extractMatchingExpression({
143128
/// Returns all lines of the block starting with [startString].
144129
///
145130
/// [startString] MUST end with '{'.
146-
List<String> _getBlockStartingWith({
147-
required String source,
148-
required RegExp startExp,
149-
}) {
131+
List<String> _getBlockStartingWith({required String source, required RegExp startExp}) {
150132
assert(startExp.pattern.endsWith('{'));
151133

152134
final int blockStart = source.indexOf(startExp);
@@ -182,16 +164,14 @@ void visitUIUnits(String flutterRoot, AstVisitor<void> visitor) {
182164
path: '$uiRoot/ui.dart',
183165
featureSet: analyzerFeatures,
184166
);
185-
for (final PartDirective part
186-
in uiResult.unit.directives.whereType<PartDirective>()) {
167+
for (final PartDirective part in uiResult.unit.directives.whereType<PartDirective>()) {
187168
final String partPath = part.uri.stringValue!;
188169
final ParseStringResult partResult = parseFile(
189170
path: '$uiRoot/$partPath',
190171
featureSet: analyzerFeatures,
191172
);
192173

193-
for (final CompilationUnitMember unitMember
194-
in partResult.unit.declarations) {
174+
for (final CompilationUnitMember unitMember in partResult.unit.declarations) {
195175
unitMember.accept(visitor);
196176
}
197177
}

engine/src/flutter/tools/api_check/test/apicheck_test.dart

Lines changed: 10 additions & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -39,24 +39,12 @@ void checkApiConsistency(String flutterRoot) {
3939
);
4040
// C values: kFlutterAccessibilityFeatureFooBar = 1 << N,
4141
final List<String> embedderEnumValues = getCppEnumValues(
42-
sourcePath: path.join(
43-
flutterRoot,
44-
'shell',
45-
'platform',
46-
'embedder',
47-
'embedder.h',
48-
),
42+
sourcePath: path.join(flutterRoot, 'shell', 'platform', 'embedder', 'embedder.h'),
4943
enumName: 'FlutterAccessibilityFeature',
5044
);
5145
// C++ values: kFooBar = 1 << N,
5246
final List<String> internalEnumValues = getCppEnumClassValues(
53-
sourcePath: path.join(
54-
flutterRoot,
55-
'lib',
56-
'ui',
57-
'window',
58-
'platform_configuration.h',
59-
),
47+
sourcePath: path.join(flutterRoot, 'lib', 'ui', 'window', 'platform_configuration.h'),
6048
enumName: 'AccessibilityFeatureFlag',
6149
);
6250
// Java values: FOO_BAR(1 << N).
@@ -101,35 +89,17 @@ void checkApiConsistency(String flutterRoot) {
10189
className: 'SemanticsAction',
10290
);
10391
final List<String> webuiFields = await getDartClassFields(
104-
sourcePath: path.join(
105-
flutterRoot,
106-
'lib',
107-
'web_ui',
108-
'lib',
109-
'semantics.dart',
110-
),
92+
sourcePath: path.join(flutterRoot, 'lib', 'web_ui', 'lib', 'semantics.dart'),
11193
className: 'SemanticsAction',
11294
);
11395
// C values: kFlutterSemanticsActionFooBar = 1 << N.
11496
final List<String> embedderEnumValues = getCppEnumValues(
115-
sourcePath: path.join(
116-
flutterRoot,
117-
'shell',
118-
'platform',
119-
'embedder',
120-
'embedder.h',
121-
),
97+
sourcePath: path.join(flutterRoot, 'shell', 'platform', 'embedder', 'embedder.h'),
12298
enumName: 'FlutterSemanticsAction',
12399
);
124100
// C++ values: kFooBar = 1 << N.
125101
final List<String> internalEnumValues = getCppEnumClassValues(
126-
sourcePath: path.join(
127-
flutterRoot,
128-
'lib',
129-
'ui',
130-
'semantics',
131-
'semantics_node.h',
132-
),
102+
sourcePath: path.join(flutterRoot, 'lib', 'ui', 'semantics', 'semantics_node.h'),
133103
enumName: 'SemanticsAction',
134104
);
135105
// Java values: FOO_BAR(1 << N).
@@ -156,33 +126,16 @@ void checkApiConsistency(String flutterRoot) {
156126
test('AppLifecycleState enums match', () async {
157127
// Dart values: _kFooBarIndex = 1 << N.
158128
final List<String> uiFields = await getDartClassFields(
159-
sourcePath: path.join(
160-
flutterRoot,
161-
'lib',
162-
'ui',
163-
'platform_dispatcher.dart',
164-
),
129+
sourcePath: path.join(flutterRoot, 'lib', 'ui', 'platform_dispatcher.dart'),
165130
className: 'AppLifecycleState',
166131
);
167132
final List<String> webuiFields = await getDartClassFields(
168-
sourcePath: path.join(
169-
flutterRoot,
170-
'lib',
171-
'web_ui',
172-
'lib',
173-
'platform_dispatcher.dart',
174-
),
133+
sourcePath: path.join(flutterRoot, 'lib', 'web_ui', 'lib', 'platform_dispatcher.dart'),
175134
className: 'AppLifecycleState',
176135
);
177136
// C++ values: kFooBar = 1 << N.
178137
final List<String> internalEnumValues = getCppEnumClassValues(
179-
sourcePath: path.join(
180-
flutterRoot,
181-
'shell',
182-
'platform',
183-
'common',
184-
'app_lifecycle_state.h',
185-
),
138+
sourcePath: path.join(flutterRoot, 'shell', 'platform', 'common', 'app_lifecycle_state.h'),
186139
enumName: 'AppLifecycleState',
187140
);
188141
// Java values: FOO_BAR(1 << N).
@@ -286,17 +239,15 @@ class NativeFunctionVisitor extends RecursiveAstVisitor<void> {
286239

287240
@override
288241
void visitNativeFunctionBody(NativeFunctionBody node) {
289-
final MethodDeclaration? method = node
290-
.thisOrAncestorOfType<MethodDeclaration>();
242+
final MethodDeclaration? method = node.thisOrAncestorOfType<MethodDeclaration>();
291243
if (method != null) {
292244
if (method.parameters != null) {
293245
check(method.toString(), method.parameters!);
294246
}
295247
return;
296248
}
297249

298-
final FunctionDeclaration? func = node
299-
.thisOrAncestorOfType<FunctionDeclaration>();
250+
final FunctionDeclaration? func = node.thisOrAncestorOfType<FunctionDeclaration>();
300251
if (func != null) {
301252
final FunctionExpression funcExpr = func.functionExpression;
302253
if (funcExpr.parameters != null) {

0 commit comments

Comments
 (0)