2
2
// Use of this source code is governed by a BSD-style license that can be
3
3
// found in the LICENSE file.
4
4
5
- import 'dart:io' ;
6
-
7
5
import 'package:analyzer/dart/ast/ast.dart' ;
8
6
import 'package:analyzer/dart/ast/visitor.dart' ;
9
7
import 'package:apicheck/apicheck.dart' ;
10
- import 'package:litetest/litetest .dart' ;
8
+ import 'package:engine_repo_tools/engine_repo_tools .dart' ;
11
9
import 'package:path/path.dart' as path;
10
+ import 'package:test/test.dart' ;
12
11
13
- void main (List <String > arguments) {
14
- if (arguments.isEmpty) {
15
- print ('usage: dart bin/apicheck.dart path/to/engine/src/flutter' );
16
- exit (1 );
17
- }
18
-
19
- final String flutterRoot = arguments[0 ];
12
+ void main () {
13
+ final String flutterRoot = Engine .findWithin ().flutterDir.path;
20
14
21
15
checkApiConsistency (flutterRoot);
22
16
checkNativeApi (flutterRoot);
@@ -45,12 +39,14 @@ void checkApiConsistency(String flutterRoot) {
45
39
);
46
40
// C values: kFlutterAccessibilityFeatureFooBar = 1 << N,
47
41
final List <String > embedderEnumValues = getCppEnumValues (
48
- sourcePath: path.join (flutterRoot, 'shell' , 'platform' , 'embedder' , 'embedder.h' ),
42
+ sourcePath:
43
+ path.join (flutterRoot, 'shell' , 'platform' , 'embedder' , 'embedder.h' ),
49
44
enumName: 'FlutterAccessibilityFeature' ,
50
45
);
51
46
// C++ values: kFooBar = 1 << N,
52
47
final List <String > internalEnumValues = getCppEnumClassValues (
53
- sourcePath: path.join (flutterRoot, 'lib' ,'ui' , 'window' , 'platform_configuration.h' ),
48
+ sourcePath: path.join (
49
+ flutterRoot, 'lib' , 'ui' , 'window' , 'platform_configuration.h' ),
54
50
enumName: 'AccessibilityFeatureFlag' ,
55
51
);
56
52
// Java values: FOO_BAR(1 << N).
@@ -72,17 +68,20 @@ void checkApiConsistency(String flutterRoot) {
72
68
className: 'SemanticsAction' ,
73
69
);
74
70
final List <String > webuiFields = getDartClassFields (
75
- sourcePath: path.join (flutterRoot, 'lib' , 'web_ui' , 'lib' , 'semantics.dart' ),
71
+ sourcePath:
72
+ path.join (flutterRoot, 'lib' , 'web_ui' , 'lib' , 'semantics.dart' ),
76
73
className: 'SemanticsAction' ,
77
74
);
78
75
// C values: kFlutterSemanticsActionFooBar = 1 << N.
79
76
final List <String > embedderEnumValues = getCppEnumValues (
80
- sourcePath: path.join (flutterRoot, 'shell' , 'platform' , 'embedder' , 'embedder.h' ),
77
+ sourcePath:
78
+ path.join (flutterRoot, 'shell' , 'platform' , 'embedder' , 'embedder.h' ),
81
79
enumName: 'FlutterSemanticsAction' ,
82
80
);
83
81
// C++ values: kFooBar = 1 << N.
84
82
final List <String > internalEnumValues = getCppEnumClassValues (
85
- sourcePath: path.join (flutterRoot, 'lib' , 'ui' , 'semantics' , 'semantics_node.h' ),
83
+ sourcePath:
84
+ path.join (flutterRoot, 'lib' , 'ui' , 'semantics' , 'semantics_node.h' ),
86
85
enumName: 'SemanticsAction' ,
87
86
);
88
87
// Java values: FOO_BAR(1 << N).
@@ -101,22 +100,34 @@ void checkApiConsistency(String flutterRoot) {
101
100
test ('AppLifecycleState enums match' , () {
102
101
// Dart values: _kFooBarIndex = 1 << N.
103
102
final List <String > uiFields = getDartClassFields (
104
- sourcePath: path.join (flutterRoot, 'lib' , 'ui' , 'platform_dispatcher.dart' ),
103
+ sourcePath:
104
+ path.join (flutterRoot, 'lib' , 'ui' , 'platform_dispatcher.dart' ),
105
105
className: 'AppLifecycleState' ,
106
106
);
107
107
final List <String > webuiFields = getDartClassFields (
108
- sourcePath: path.join (flutterRoot, 'lib' , 'web_ui' , 'lib' , 'platform_dispatcher.dart' ),
108
+ sourcePath: path.join (
109
+ flutterRoot, 'lib' , 'web_ui' , 'lib' , 'platform_dispatcher.dart' ),
109
110
className: 'AppLifecycleState' ,
110
111
);
111
112
// C++ values: kFooBar = 1 << N.
112
113
final List <String > internalEnumValues = getCppEnumClassValues (
113
- sourcePath: path.join (flutterRoot, 'shell' , 'platform' , 'common' , 'app_lifecycle_state.h' ),
114
+ sourcePath: path.join (
115
+ flutterRoot, 'shell' , 'platform' , 'common' , 'app_lifecycle_state.h' ),
114
116
enumName: 'AppLifecycleState' ,
115
117
);
116
118
// Java values: FOO_BAR(1 << N).
117
119
final List <String > javaEnumValues = getJavaEnumValues (
118
- sourcePath: path.join (flutterRoot, 'shell' , 'platform' , 'android' , 'io' ,
119
- 'flutter' , 'embedding' , 'engine' , 'systemchannels' , 'LifecycleChannel.java' ),
120
+ sourcePath: path.join (
121
+ flutterRoot,
122
+ 'shell' ,
123
+ 'platform' ,
124
+ 'android' ,
125
+ 'io' ,
126
+ 'flutter' ,
127
+ 'embedding' ,
128
+ 'engine' ,
129
+ 'systemchannels' ,
130
+ 'LifecycleChannel.java' ),
120
131
enumName: 'AppLifecycleState' ,
121
132
).map (allCapsToCamelCase).toList ();
122
133
@@ -137,12 +148,14 @@ void checkApiConsistency(String flutterRoot) {
137
148
);
138
149
// C values: kFlutterSemanticsFlagFooBar = 1 << N.
139
150
final List <String > embedderEnumValues = getCppEnumValues (
140
- sourcePath: path.join (flutterRoot, 'shell' , 'platform' , 'embedder' , 'embedder.h' ),
151
+ sourcePath:
152
+ path.join (flutterRoot, 'shell' , 'platform' , 'embedder' , 'embedder.h' ),
141
153
enumName: 'FlutterSemanticsFlag' ,
142
154
);
143
155
// C++ values: kFooBar = 1 << N.
144
156
final List <String > internalEnumValues = getCppEnumClassValues (
145
- sourcePath: path.join (flutterRoot, 'lib' , 'ui' , 'semantics' , 'semantics_node.h' ),
157
+ sourcePath:
158
+ path.join (flutterRoot, 'lib' , 'ui' , 'semantics' , 'semantics_node.h' ),
146
159
enumName: 'SemanticsFlags' ,
147
160
);
148
161
// Java values: FOO_BAR(1 << N).
@@ -185,15 +198,17 @@ class NativeFunctionVisitor extends RecursiveAstVisitor<void> {
185
198
186
199
@override
187
200
void visitNativeFunctionBody (NativeFunctionBody node) {
188
- final MethodDeclaration ? method = node.thisOrAncestorOfType <MethodDeclaration >();
201
+ final MethodDeclaration ? method =
202
+ node.thisOrAncestorOfType <MethodDeclaration >();
189
203
if (method != null ) {
190
204
if (method.parameters != null ) {
191
205
check (method.toString (), method.parameters! );
192
206
}
193
207
return ;
194
208
}
195
209
196
- final FunctionDeclaration ? func = node.thisOrAncestorOfType <FunctionDeclaration >();
210
+ final FunctionDeclaration ? func =
211
+ node.thisOrAncestorOfType <FunctionDeclaration >();
197
212
if (func != null ) {
198
213
final FunctionExpression funcExpr = func.functionExpression;
199
214
if (funcExpr.parameters != null ) {
0 commit comments