22// Use of this source code is governed by a BSD-style license that can be
33// found in the LICENSE file.
44
5- import 'dart:io' ;
6-
75import 'package:analyzer/dart/ast/ast.dart' ;
86import 'package:analyzer/dart/ast/visitor.dart' ;
97import 'package:apicheck/apicheck.dart' ;
10- import 'package:litetest/litetest .dart' ;
8+ import 'package:engine_repo_tools/engine_repo_tools .dart' ;
119import 'package:path/path.dart' as path;
10+ import 'package:test/test.dart' ;
1211
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;
2014
2115 checkApiConsistency (flutterRoot);
2216 checkNativeApi (flutterRoot);
@@ -45,12 +39,14 @@ void checkApiConsistency(String flutterRoot) {
4539 );
4640 // C values: kFlutterAccessibilityFeatureFooBar = 1 << N,
4741 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' ),
4944 enumName: 'FlutterAccessibilityFeature' ,
5045 );
5146 // C++ values: kFooBar = 1 << N,
5247 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' ),
5450 enumName: 'AccessibilityFeatureFlag' ,
5551 );
5652 // Java values: FOO_BAR(1 << N).
@@ -72,17 +68,20 @@ void checkApiConsistency(String flutterRoot) {
7268 className: 'SemanticsAction' ,
7369 );
7470 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' ),
7673 className: 'SemanticsAction' ,
7774 );
7875 // C values: kFlutterSemanticsActionFooBar = 1 << N.
7976 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' ),
8179 enumName: 'FlutterSemanticsAction' ,
8280 );
8381 // C++ values: kFooBar = 1 << N.
8482 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' ),
8685 enumName: 'SemanticsAction' ,
8786 );
8887 // Java values: FOO_BAR(1 << N).
@@ -101,22 +100,34 @@ void checkApiConsistency(String flutterRoot) {
101100 test ('AppLifecycleState enums match' , () {
102101 // Dart values: _kFooBarIndex = 1 << N.
103102 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' ),
105105 className: 'AppLifecycleState' ,
106106 );
107107 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' ),
109110 className: 'AppLifecycleState' ,
110111 );
111112 // C++ values: kFooBar = 1 << N.
112113 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' ),
114116 enumName: 'AppLifecycleState' ,
115117 );
116118 // Java values: FOO_BAR(1 << N).
117119 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' ),
120131 enumName: 'AppLifecycleState' ,
121132 ).map (allCapsToCamelCase).toList ();
122133
@@ -137,12 +148,14 @@ void checkApiConsistency(String flutterRoot) {
137148 );
138149 // C values: kFlutterSemanticsFlagFooBar = 1 << N.
139150 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' ),
141153 enumName: 'FlutterSemanticsFlag' ,
142154 );
143155 // C++ values: kFooBar = 1 << N.
144156 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' ),
146159 enumName: 'SemanticsFlags' ,
147160 );
148161 // Java values: FOO_BAR(1 << N).
@@ -185,15 +198,17 @@ class NativeFunctionVisitor extends RecursiveAstVisitor<void> {
185198
186199 @override
187200 void visitNativeFunctionBody (NativeFunctionBody node) {
188- final MethodDeclaration ? method = node.thisOrAncestorOfType <MethodDeclaration >();
201+ final MethodDeclaration ? method =
202+ node.thisOrAncestorOfType <MethodDeclaration >();
189203 if (method != null ) {
190204 if (method.parameters != null ) {
191205 check (method.toString (), method.parameters! );
192206 }
193207 return ;
194208 }
195209
196- final FunctionDeclaration ? func = node.thisOrAncestorOfType <FunctionDeclaration >();
210+ final FunctionDeclaration ? func =
211+ node.thisOrAncestorOfType <FunctionDeclaration >();
197212 if (func != null ) {
198213 final FunctionExpression funcExpr = func.functionExpression;
199214 if (funcExpr.parameters != null ) {
0 commit comments