Skip to content

Commit f0a66f1

Browse files
[pigeon] Adds overrides for constructors and static members of ProxyApis (#9515)
Adds `PigeonOverrides` class that contains overrides for all constructors and static members of ProxyApis. I changed it to have only a single `PigeonOverrides` instead of having a separate overrides class for each proxy api. This makes it easier to export the generated proxy api classes without needing to `hide/show` specific classes. I manually verified this only breaks one line in `camera_android_camerax` and one line in `webview_flutter_android`. Also TIL: ``` class MyClass { MyClass(); <-- These are considered the same. MyClass.new(); <-- } ``` ## Pre-Review Checklist [^1]: Regular contributors who have demonstrated familiarity with the repository guidelines only need to comment if the PR is not auto-exempted by repo tooling.
1 parent cb8fef6 commit f0a66f1

File tree

9 files changed

+1523
-222
lines changed

9 files changed

+1523
-222
lines changed

packages/pigeon/CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
## 26.0.0
2+
3+
* **Breaking Change** [dart] Changes name of constructors used to create subclasses of ProxyApis to
4+
`pigeon_**original_name**`.
5+
* [dart] Adds ProxyApi overrides classes to be used in Flutter unit tests.
6+
17
## 25.5.0
28

39
* [dart] Changes the default InstanceManager and its initialization to no longer make a message call

packages/pigeon/lib/src/ast.dart

Lines changed: 30 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -240,34 +240,53 @@ class AstProxyApi extends Api {
240240
/// `implements`.
241241
Iterable<AstProxyApi> apisOfInterfaces() => _recursiveFindAllInterfaceApis();
242242

243-
/// All methods inherited from interfaces and the interfaces of interfaces.
244-
Iterable<Method> flutterMethodsFromInterfaces() sync* {
243+
/// Returns a record for each method inherited from an interface and its
244+
/// corresponding ProxyApi.
245+
Iterable<(Method, AstProxyApi)> flutterMethodsFromInterfacesWithApis() sync* {
245246
for (final AstProxyApi proxyApi in apisOfInterfaces()) {
246-
yield* proxyApi.methods;
247+
yield* proxyApi.methods.map((Method method) => (method, proxyApi));
247248
}
248249
}
249250

250-
/// A list of Flutter methods inherited from the ProxyApi that this ProxyApi
251-
/// `extends`.
252-
///
253-
/// This also recursively checks the ProxyApi that the super class `extends`
254-
/// and so on.
251+
/// Returns a record for each Flutter method inherited from [superClass].
255252
///
256253
/// This also includes methods that super classes inherited from interfaces
257254
/// with `implements`.
258-
Iterable<Method> flutterMethodsFromSuperClasses() sync* {
255+
Iterable<(Method, AstProxyApi)>
256+
flutterMethodsFromSuperClassesWithApis() sync* {
259257
for (final AstProxyApi proxyApi in allSuperClasses().toList().reversed) {
260-
yield* proxyApi.flutterMethods;
258+
yield* proxyApi.flutterMethods.map((Method method) => (method, proxyApi));
261259
}
262260
if (superClass != null) {
263261
final Set<AstProxyApi> interfaceApisFromSuperClasses =
264262
superClass!.associatedProxyApi!._recursiveFindAllInterfaceApis();
265263
for (final AstProxyApi proxyApi in interfaceApisFromSuperClasses) {
266-
yield* proxyApi.methods;
264+
yield* proxyApi.methods.map((Method method) => (method, proxyApi));
267265
}
268266
}
269267
}
270268

269+
/// All methods inherited from interfaces and the interfaces of interfaces.
270+
Iterable<Method> flutterMethodsFromInterfaces() sync* {
271+
yield* flutterMethodsFromInterfacesWithApis().map(
272+
((Method, AstProxyApi) method) => method.$1,
273+
);
274+
}
275+
276+
/// A list of Flutter methods inherited from the ProxyApi that this ProxyApi
277+
/// `extends`.
278+
///
279+
/// This also recursively checks the ProxyApi that the super class `extends`
280+
/// and so on.
281+
///
282+
/// This also includes methods that super classes inherited from interfaces
283+
/// with `implements`.
284+
Iterable<Method> flutterMethodsFromSuperClasses() sync* {
285+
yield* flutterMethodsFromSuperClassesWithApis().map(
286+
((Method, AstProxyApi) method) => method.$1,
287+
);
288+
}
289+
271290
/// Whether the API has a method that callbacks to Dart to add a new instance
272291
/// to the InstanceManager.
273292
///

0 commit comments

Comments
 (0)