Skip to content

Commit 2bb7d14

Browse files
[pigeon] Support other hosts in generated file CI checks (flutter#5944)
Reworks Pigeon's CI validation of generated files to support multiple hosts, rather than only Linux, with the ability to set specific languages per host, to allow us to run validation for each language on whatever host it is most convenient to set up a formatter for that language, rather than having to support all languages on Linux. See discussion in flutter/packages#5928 Part of flutter#41129
1 parent 2b0d290 commit 2bb7d14

File tree

8 files changed

+1424
-556
lines changed

8 files changed

+1424
-556
lines changed

packages/pigeon/example/app/ios/Runner/Messages.g.swift

Lines changed: 24 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,9 @@ private func wrapError(_ error: Any) -> [Any?] {
3434
}
3535

3636
private func createConnectionError(withChannelName channelName: String) -> FlutterError {
37-
return FlutterError(code: "channel-error", message: "Unable to establish connection on channel: '\(channelName)'.", details: "")
37+
return FlutterError(
38+
code: "channel-error", message: "Unable to establish connection on channel: '\(channelName)'.",
39+
details: "")
3840
}
3941

4042
private func isNullish(_ value: Any?) -> Bool {
@@ -130,7 +132,9 @@ class ExampleHostApiSetup {
130132
static var codec: FlutterStandardMessageCodec { ExampleHostApiCodec.shared }
131133
/// Sets up an instance of `ExampleHostApi` to handle messages through the `binaryMessenger`.
132134
static func setUp(binaryMessenger: FlutterBinaryMessenger, api: ExampleHostApi?) {
133-
let getHostLanguageChannel = FlutterBasicMessageChannel(name: "dev.flutter.pigeon.pigeon_example_package.ExampleHostApi.getHostLanguage", binaryMessenger: binaryMessenger, codec: codec)
135+
let getHostLanguageChannel = FlutterBasicMessageChannel(
136+
name: "dev.flutter.pigeon.pigeon_example_package.ExampleHostApi.getHostLanguage",
137+
binaryMessenger: binaryMessenger, codec: codec)
134138
if let api = api {
135139
getHostLanguageChannel.setMessageHandler { _, reply in
136140
do {
@@ -143,7 +147,9 @@ class ExampleHostApiSetup {
143147
} else {
144148
getHostLanguageChannel.setMessageHandler(nil)
145149
}
146-
let addChannel = FlutterBasicMessageChannel(name: "dev.flutter.pigeon.pigeon_example_package.ExampleHostApi.add", binaryMessenger: binaryMessenger, codec: codec)
150+
let addChannel = FlutterBasicMessageChannel(
151+
name: "dev.flutter.pigeon.pigeon_example_package.ExampleHostApi.add",
152+
binaryMessenger: binaryMessenger, codec: codec)
147153
if let api = api {
148154
addChannel.setMessageHandler { message, reply in
149155
let args = message as! [Any?]
@@ -159,7 +165,9 @@ class ExampleHostApiSetup {
159165
} else {
160166
addChannel.setMessageHandler(nil)
161167
}
162-
let sendMessageChannel = FlutterBasicMessageChannel(name: "dev.flutter.pigeon.pigeon_example_package.ExampleHostApi.sendMessage", binaryMessenger: binaryMessenger, codec: codec)
168+
let sendMessageChannel = FlutterBasicMessageChannel(
169+
name: "dev.flutter.pigeon.pigeon_example_package.ExampleHostApi.sendMessage",
170+
binaryMessenger: binaryMessenger, codec: codec)
163171
if let api = api {
164172
sendMessageChannel.setMessageHandler { message, reply in
165173
let args = message as! [Any?]
@@ -180,15 +188,19 @@ class ExampleHostApiSetup {
180188
}
181189
/// Generated protocol from Pigeon that represents Flutter messages that can be called from Swift.
182190
protocol MessageFlutterApiProtocol {
183-
func flutterMethod(aString aStringArg: String?, completion: @escaping (Result<String, FlutterError>) -> Void)
191+
func flutterMethod(
192+
aString aStringArg: String?, completion: @escaping (Result<String, FlutterError>) -> Void)
184193
}
185194
class MessageFlutterApi: MessageFlutterApiProtocol {
186195
private let binaryMessenger: FlutterBinaryMessenger
187196
init(binaryMessenger: FlutterBinaryMessenger) {
188197
self.binaryMessenger = binaryMessenger
189198
}
190-
func flutterMethod(aString aStringArg: String?, completion: @escaping (Result<String, FlutterError>) -> Void) {
191-
let channelName: String = "dev.flutter.pigeon.pigeon_example_package.MessageFlutterApi.flutterMethod"
199+
func flutterMethod(
200+
aString aStringArg: String?, completion: @escaping (Result<String, FlutterError>) -> Void
201+
) {
202+
let channelName: String =
203+
"dev.flutter.pigeon.pigeon_example_package.MessageFlutterApi.flutterMethod"
192204
let channel = FlutterBasicMessageChannel(name: channelName, binaryMessenger: binaryMessenger)
193205
channel.sendMessage([aStringArg] as [Any?]) { response in
194206
guard let listResponse = response as? [Any?] else {
@@ -201,7 +213,11 @@ class MessageFlutterApi: MessageFlutterApiProtocol {
201213
let details: String? = nilOrValue(listResponse[2])
202214
completion(.failure(FlutterError(code: code, message: message, details: details)))
203215
} else if listResponse[0] == nil {
204-
completion(.failure(FlutterError(code: "null-error", message: "Flutter api returned null value for non-null return value.", details: "")))
216+
completion(
217+
.failure(
218+
FlutterError(
219+
code: "null-error",
220+
message: "Flutter api returned null value for non-null return value.", details: "")))
205221
} else {
206222
let result = listResponse[0] as! String
207223
completion(.success(result))

0 commit comments

Comments
 (0)