Visitar URL original
[pigeon] removed warnings from generated java code (#171) · flutter/packages@9d90dd3 · GitHub
Skip to content

Commit 9d90dd3

Browse files
authored
[pigeon] removed warnings from generated java code (#171)
1 parent f5f574e commit 9d90dd3

10 files changed

Lines changed: 289 additions & 59 deletions

File tree

‎packages/pigeon/CHANGELOG.md‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
## 0.1.2
2+
3+
* Removed static analysis warnings from generated Java code.
4+
15
## 0.1.1
26

37
* Fixed issue where nested types didn't work if they weren't present in the Api.
Lines changed: 232 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,232 @@
1+
// Autogenerated from Pigeon (v0.1.2), do not edit directly.
2+
// See also: https://pub.dev/packages/pigeon
3+
4+
package dev.flutter.aaclarke.pigeon;
5+
6+
import io.flutter.plugin.common.BasicMessageChannel;
7+
import io.flutter.plugin.common.BinaryMessenger;
8+
import io.flutter.plugin.common.StandardMessageCodec;
9+
import java.util.HashMap;
10+
11+
/** Generated class from Pigeon. */
12+
@SuppressWarnings("unused")
13+
public class Pigeon {
14+
15+
/** Generated class from Pigeon that represents data sent in messages. */
16+
public static class SearchReply {
17+
private String result;
18+
19+
public String getResult() {
20+
return result;
21+
}
22+
23+
public void setResult(String setterArg) {
24+
this.result = setterArg;
25+
}
26+
27+
private String error;
28+
29+
public String getError() {
30+
return error;
31+
}
32+
33+
public void setError(String setterArg) {
34+
this.error = setterArg;
35+
}
36+
37+
HashMap toMap() {
38+
HashMap<String, Object> toMapResult = new HashMap<>();
39+
toMapResult.put("result", result);
40+
toMapResult.put("error", error);
41+
return toMapResult;
42+
}
43+
44+
static SearchReply fromMap(HashMap map) {
45+
SearchReply fromMapResult = new SearchReply();
46+
Object result = map.get("result");
47+
fromMapResult.result = (String) result;
48+
Object error = map.get("error");
49+
fromMapResult.error = (String) error;
50+
return fromMapResult;
51+
}
52+
}
53+
54+
/** Generated class from Pigeon that represents data sent in messages. */
55+
public static class SearchRequest {
56+
private String query;
57+
58+
public String getQuery() {
59+
return query;
60+
}
61+
62+
public void setQuery(String setterArg) {
63+
this.query = setterArg;
64+
}
65+
66+
private Long anInt;
67+
68+
public Long getAnInt() {
69+
return anInt;
70+
}
71+
72+
public void setAnInt(Long setterArg) {
73+
this.anInt = setterArg;
74+
}
75+
76+
private Boolean aBool;
77+
78+
public Boolean getABool() {
79+
return aBool;
80+
}
81+
82+
public void setABool(Boolean setterArg) {
83+
this.aBool = setterArg;
84+
}
85+
86+
HashMap toMap() {
87+
HashMap<String, Object> toMapResult = new HashMap<>();
88+
toMapResult.put("query", query);
89+
toMapResult.put("anInt", anInt);
90+
toMapResult.put("aBool", aBool);
91+
return toMapResult;
92+
}
93+
94+
static SearchRequest fromMap(HashMap map) {
95+
SearchRequest fromMapResult = new SearchRequest();
96+
Object query = map.get("query");
97+
fromMapResult.query = (String) query;
98+
Object anInt = map.get("anInt");
99+
fromMapResult.anInt =
100+
(anInt == null) ? null : ((anInt instanceof Integer) ? (Integer) anInt : (Long) anInt);
101+
Object aBool = map.get("aBool");
102+
fromMapResult.aBool = (Boolean) aBool;
103+
return fromMapResult;
104+
}
105+
}
106+
107+
/** Generated class from Pigeon that represents data sent in messages. */
108+
public static class Nested {
109+
private SearchRequest request;
110+
111+
public SearchRequest getRequest() {
112+
return request;
113+
}
114+
115+
public void setRequest(SearchRequest setterArg) {
116+
this.request = setterArg;
117+
}
118+
119+
HashMap toMap() {
120+
HashMap<String, Object> toMapResult = new HashMap<>();
121+
toMapResult.put("request", request);
122+
return toMapResult;
123+
}
124+
125+
static Nested fromMap(HashMap map) {
126+
Nested fromMapResult = new Nested();
127+
Object request = map.get("request");
128+
fromMapResult.request = (SearchRequest) request;
129+
return fromMapResult;
130+
}
131+
}
132+
133+
/** Generated class from Pigeon that represents Flutter messages that can be called from Java. */
134+
public static class FlutterSearchApi {
135+
private final BinaryMessenger binaryMessenger;
136+
137+
public FlutterSearchApi(BinaryMessenger argBinaryMessenger) {
138+
this.binaryMessenger = argBinaryMessenger;
139+
}
140+
141+
public interface Reply<T> {
142+
void reply(T reply);
143+
}
144+
145+
public void search(SearchRequest argInput, Reply<SearchReply> callback) {
146+
BasicMessageChannel<Object> channel =
147+
new BasicMessageChannel<>(
148+
binaryMessenger,
149+
"dev.flutter.pigeon.FlutterSearchApi.search",
150+
new StandardMessageCodec());
151+
HashMap inputMap = argInput.toMap();
152+
channel.send(
153+
inputMap,
154+
channelReply -> {
155+
HashMap outputMap = (HashMap) channelReply;
156+
@SuppressWarnings("ConstantConditions")
157+
SearchReply output = SearchReply.fromMap(outputMap);
158+
callback.reply(output);
159+
});
160+
}
161+
}
162+
163+
/** Generated interface from Pigeon that represents a handler of messages from Flutter. */
164+
public interface NestedApi {
165+
SearchReply search(Nested arg);
166+
167+
/** Sets up an instance of `NestedApi` to handle messages through the `binaryMessenger` */
168+
static void setup(BinaryMessenger binaryMessenger, NestedApi api) {
169+
{
170+
BasicMessageChannel<Object> channel =
171+
new BasicMessageChannel<>(
172+
binaryMessenger, "dev.flutter.pigeon.NestedApi.search", new StandardMessageCodec());
173+
if (api != null) {
174+
channel.setMessageHandler(
175+
(message, reply) -> {
176+
HashMap<String, HashMap> wrapped = new HashMap<>();
177+
try {
178+
@SuppressWarnings("ConstantConditions")
179+
Nested input = Nested.fromMap((HashMap) message);
180+
SearchReply output = api.search(input);
181+
wrapped.put("result", output.toMap());
182+
} catch (Exception exception) {
183+
wrapped.put("error", wrapError(exception));
184+
}
185+
reply.reply(wrapped);
186+
});
187+
} else {
188+
channel.setMessageHandler(null);
189+
}
190+
}
191+
}
192+
}
193+
194+
/** Generated interface from Pigeon that represents a handler of messages from Flutter. */
195+
public interface Api {
196+
SearchReply search(SearchRequest arg);
197+
198+
/** Sets up an instance of `Api` to handle messages through the `binaryMessenger` */
199+
static void setup(BinaryMessenger binaryMessenger, Api api) {
200+
{
201+
BasicMessageChannel<Object> channel =
202+
new BasicMessageChannel<>(
203+
binaryMessenger, "dev.flutter.pigeon.Api.search", new StandardMessageCodec());
204+
if (api != null) {
205+
channel.setMessageHandler(
206+
(message, reply) -> {
207+
HashMap<String, HashMap> wrapped = new HashMap<>();
208+
try {
209+
@SuppressWarnings("ConstantConditions")
210+
SearchRequest input = SearchRequest.fromMap((HashMap) message);
211+
SearchReply output = api.search(input);
212+
wrapped.put("result", output.toMap());
213+
} catch (Exception exception) {
214+
wrapped.put("error", wrapError(exception));
215+
}
216+
reply.reply(wrapped);
217+
});
218+
} else {
219+
channel.setMessageHandler(null);
220+
}
221+
}
222+
}
223+
}
224+
225+
private static HashMap wrapError(Exception exception) {
226+
HashMap<String, Object> errorMap = new HashMap<>();
227+
errorMap.put("message", exception.toString());
228+
errorMap.put("code", null);
229+
errorMap.put("details", null);
230+
return errorMap;
231+
}
232+
}

‎packages/pigeon/e2e_tests/test_objc/ios/Runner/dartle.h‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Autogenerated from Pigeon (v0.1.0), do not edit directly.
1+
// Autogenerated from Pigeon (v0.1.2), do not edit directly.
22
// See also: https://pub.dev/packages/pigeon
33
#import <Foundation/Foundation.h>
44
@protocol FlutterBinaryMessenger;

‎packages/pigeon/e2e_tests/test_objc/ios/Runner/dartle.m‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Autogenerated from Pigeon (v0.1.0), do not edit directly.
1+
// Autogenerated from Pigeon (v0.1.2), do not edit directly.
22
// See also: https://pub.dev/packages/pigeon
33
#import "dartle.h"
44
#import <Flutter/Flutter.h>

‎packages/pigeon/e2e_tests/test_objc/lib/dartle.dart‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Autogenerated from Pigeon (v0.1.0), do not edit directly.
1+
// Autogenerated from Pigeon (v0.1.2), do not edit directly.
22
// See also: https://pub.dev/packages/pigeon
33
// ignore_for_file: public_member_api_docs, non_constant_identifier_names, avoid_as, unused_import
44
import 'dart:async';

‎packages/pigeon/lib/generator_tools.dart‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import 'dart:mirrors';
88
import 'ast.dart';
99

1010
/// The current version of pigeon.
11-
const String pigeonVersion = '0.1.0';
11+
const String pigeonVersion = '0.1.2';
1212

1313
/// Read all the content from [stdin] to a String.
1414
String readStdin() {

0 commit comments

Comments
 (0)