Skip to content

[pigeon] removed warnings from generated java code #171

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Jun 17, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions packages/pigeon/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## 0.1.2

* Removed static analysis warnings from generated Java code.

## 0.1.1

* Fixed issue where nested types didn't work if they weren't present in the Api.
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,232 @@
// Autogenerated from Pigeon (v0.1.2), do not edit directly.
// See also: https://pub.dev/packages/pigeon

package dev.flutter.aaclarke.pigeon;

import io.flutter.plugin.common.BasicMessageChannel;
import io.flutter.plugin.common.BinaryMessenger;
import io.flutter.plugin.common.StandardMessageCodec;
import java.util.HashMap;

/** Generated class from Pigeon. */
@SuppressWarnings("unused")
public class Pigeon {

/** Generated class from Pigeon that represents data sent in messages. */
public static class SearchReply {
private String result;

public String getResult() {
return result;
}

public void setResult(String setterArg) {
this.result = setterArg;
}

private String error;

public String getError() {
return error;
}

public void setError(String setterArg) {
this.error = setterArg;
}

HashMap toMap() {
HashMap<String, Object> toMapResult = new HashMap<>();
toMapResult.put("result", result);
toMapResult.put("error", error);
return toMapResult;
}

static SearchReply fromMap(HashMap map) {
SearchReply fromMapResult = new SearchReply();
Object result = map.get("result");
fromMapResult.result = (String) result;
Object error = map.get("error");
fromMapResult.error = (String) error;
return fromMapResult;
}
}

/** Generated class from Pigeon that represents data sent in messages. */
public static class SearchRequest {
private String query;

public String getQuery() {
return query;
}

public void setQuery(String setterArg) {
this.query = setterArg;
}

private Long anInt;

public Long getAnInt() {
return anInt;
}

public void setAnInt(Long setterArg) {
this.anInt = setterArg;
}

private Boolean aBool;

public Boolean getABool() {
return aBool;
}

public void setABool(Boolean setterArg) {
this.aBool = setterArg;
}

HashMap toMap() {
HashMap<String, Object> toMapResult = new HashMap<>();
toMapResult.put("query", query);
toMapResult.put("anInt", anInt);
toMapResult.put("aBool", aBool);
return toMapResult;
}

static SearchRequest fromMap(HashMap map) {
SearchRequest fromMapResult = new SearchRequest();
Object query = map.get("query");
fromMapResult.query = (String) query;
Object anInt = map.get("anInt");
fromMapResult.anInt =
(anInt == null) ? null : ((anInt instanceof Integer) ? (Integer) anInt : (Long) anInt);
Object aBool = map.get("aBool");
fromMapResult.aBool = (Boolean) aBool;
return fromMapResult;
}
}

/** Generated class from Pigeon that represents data sent in messages. */
public static class Nested {
private SearchRequest request;

public SearchRequest getRequest() {
return request;
}

public void setRequest(SearchRequest setterArg) {
this.request = setterArg;
}

HashMap toMap() {
HashMap<String, Object> toMapResult = new HashMap<>();
toMapResult.put("request", request);
return toMapResult;
}

static Nested fromMap(HashMap map) {
Nested fromMapResult = new Nested();
Object request = map.get("request");
fromMapResult.request = (SearchRequest) request;
return fromMapResult;
}
}

/** Generated class from Pigeon that represents Flutter messages that can be called from Java. */
public static class FlutterSearchApi {
private final BinaryMessenger binaryMessenger;

public FlutterSearchApi(BinaryMessenger argBinaryMessenger) {
this.binaryMessenger = argBinaryMessenger;
}

public interface Reply<T> {
void reply(T reply);
}

public void search(SearchRequest argInput, Reply<SearchReply> callback) {
BasicMessageChannel<Object> channel =
new BasicMessageChannel<>(
binaryMessenger,
"dev.flutter.pigeon.FlutterSearchApi.search",
new StandardMessageCodec());
HashMap inputMap = argInput.toMap();
channel.send(
inputMap,
channelReply -> {
HashMap outputMap = (HashMap) channelReply;
@SuppressWarnings("ConstantConditions")
SearchReply output = SearchReply.fromMap(outputMap);
callback.reply(output);
});
}
}

/** Generated interface from Pigeon that represents a handler of messages from Flutter. */
public interface NestedApi {
SearchReply search(Nested arg);

/** Sets up an instance of `NestedApi` to handle messages through the `binaryMessenger` */
static void setup(BinaryMessenger binaryMessenger, NestedApi api) {
{
BasicMessageChannel<Object> channel =
new BasicMessageChannel<>(
binaryMessenger, "dev.flutter.pigeon.NestedApi.search", new StandardMessageCodec());
if (api != null) {
channel.setMessageHandler(
(message, reply) -> {
HashMap<String, HashMap> wrapped = new HashMap<>();
try {
@SuppressWarnings("ConstantConditions")
Nested input = Nested.fromMap((HashMap) message);
SearchReply output = api.search(input);
wrapped.put("result", output.toMap());
} catch (Exception exception) {
wrapped.put("error", wrapError(exception));
}
reply.reply(wrapped);
});
} else {
channel.setMessageHandler(null);
}
}
}
}

/** Generated interface from Pigeon that represents a handler of messages from Flutter. */
public interface Api {
SearchReply search(SearchRequest arg);

/** Sets up an instance of `Api` to handle messages through the `binaryMessenger` */
static void setup(BinaryMessenger binaryMessenger, Api api) {
{
BasicMessageChannel<Object> channel =
new BasicMessageChannel<>(
binaryMessenger, "dev.flutter.pigeon.Api.search", new StandardMessageCodec());
if (api != null) {
channel.setMessageHandler(
(message, reply) -> {
HashMap<String, HashMap> wrapped = new HashMap<>();
try {
@SuppressWarnings("ConstantConditions")
SearchRequest input = SearchRequest.fromMap((HashMap) message);
SearchReply output = api.search(input);
wrapped.put("result", output.toMap());
} catch (Exception exception) {
wrapped.put("error", wrapError(exception));
}
reply.reply(wrapped);
});
} else {
channel.setMessageHandler(null);
}
}
}
}

private static HashMap wrapError(Exception exception) {
HashMap<String, Object> errorMap = new HashMap<>();
errorMap.put("message", exception.toString());
errorMap.put("code", null);
errorMap.put("details", null);
return errorMap;
}
}
2 changes: 1 addition & 1 deletion packages/pigeon/e2e_tests/test_objc/ios/Runner/dartle.h
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Autogenerated from Pigeon (v0.1.0), do not edit directly.
// Autogenerated from Pigeon (v0.1.2), do not edit directly.
// See also: https://pub.dev/packages/pigeon
#import <Foundation/Foundation.h>
@protocol FlutterBinaryMessenger;
Expand Down
2 changes: 1 addition & 1 deletion packages/pigeon/e2e_tests/test_objc/ios/Runner/dartle.m
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Autogenerated from Pigeon (v0.1.0), do not edit directly.
// Autogenerated from Pigeon (v0.1.2), do not edit directly.
// See also: https://pub.dev/packages/pigeon
#import "dartle.h"
#import <Flutter/Flutter.h>
Expand Down
2 changes: 1 addition & 1 deletion packages/pigeon/e2e_tests/test_objc/lib/dartle.dart
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Autogenerated from Pigeon (v0.1.0), do not edit directly.
// Autogenerated from Pigeon (v0.1.2), do not edit directly.
// See also: https://pub.dev/packages/pigeon
// ignore_for_file: public_member_api_docs, non_constant_identifier_names, avoid_as, unused_import
import 'dart:async';
Expand Down
2 changes: 1 addition & 1 deletion packages/pigeon/lib/generator_tools.dart
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import 'dart:mirrors';
import 'ast.dart';

/// The current version of pigeon.
const String pigeonVersion = '0.1.0';
const String pigeonVersion = '0.1.2';

/// Read all the content from [stdin] to a String.
String readStdin() {
Expand Down
Loading