Skip to content
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.23

* More Java linter and linter fixes.

## 0.1.22

* Java code generator enhancements:
Expand Down
1 change: 1 addition & 0 deletions packages/pigeon/ci/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
*
12 changes: 6 additions & 6 deletions packages/pigeon/lib/dart_generator.dart
Original file line number Diff line number Diff line change
Expand Up @@ -65,9 +65,9 @@ if (replyMap == null) {
\t\tdetails: null,
\t);
} else if (replyMap['error'] != null) {
\tfinal Map<Object$nullTag, Object$nullTag> error = replyMap['${Keys.error}'] as Map<Object$nullTag, Object$nullTag>;
\tfinal Map<Object$nullTag, Object$nullTag> error = (replyMap['${Keys.error}'] as Map<Object$nullTag, Object$nullTag>$nullTag)$unwrapOperator;
\tthrow PlatformException(
\t\tcode: error['${Keys.errorCode}'] as String,
\t\tcode: (error['${Keys.errorCode}'] as String$nullTag)$unwrapOperator,
\t\tmessage: error['${Keys.errorMessage}'] as String$nullTag,
\t\tdetails: error['${Keys.errorDetails}'],
\t);
Expand Down Expand Up @@ -161,10 +161,10 @@ void _writeFlutterApi(
} else {
indent.writeln('final $returnType output = $call;');
}
const String returnExpresion = 'output.encode()';
const String returnExpression = 'output.encode()';
final String returnStatement = isMockHandler
? 'return <Object$nullTag, Object$nullTag>{\'${Keys.result}\': $returnExpresion};'
: 'return $returnExpresion;';
? 'return <Object$nullTag, Object$nullTag>{\'${Keys.result}\': $returnExpression};'
: 'return $returnExpression;';
indent.writeln(returnStatement);
}
});
Expand Down Expand Up @@ -197,7 +197,7 @@ void generateDart(DartOptions opt, Root root, StringSink sink) {
indent.writeln('// $generatedCodeWarning');
indent.writeln('// $seeAlsoWarning');
indent.writeln(
'// ignore_for_file: public_member_api_docs, non_constant_identifier_names, avoid_as, unused_import',
'// ignore_for_file: public_member_api_docs, non_constant_identifier_names, avoid_as, unused_import, unnecessary_parenthesis, prefer_null_aware_operators',
);
indent.writeln('// @dart = ${opt.isNullSafe ? '2.12' : '2.8'}');
indent.writeln('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. This must match the version in pubspec.yaml.
const String pigeonVersion = '0.1.22';
const String pigeonVersion = '0.1.23';

/// Read all the content from [stdin] to a String.
String readStdin() {
Expand Down
6 changes: 3 additions & 3 deletions packages/pigeon/lib/java_generator.dart
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ void _writeHostApi(Indent indent, Api api) {
}
indent.addln('');
indent.writeln(
'/** Sets up an instance of `${api.name}` to handle messages through the `binaryMessenger` */');
'/** Sets up an instance of `${api.name}` to handle messages through the `binaryMessenger`. */');
indent.write(
'static void setup(BinaryMessenger binaryMessenger, ${api.name} api) ');
indent.scoped('{', '}', () {
Expand Down Expand Up @@ -108,7 +108,7 @@ void _writeHostApi(Indent indent, Api api) {
'wrapped.put("${Keys.result}", output.toMap());');
}
});
indent.write('catch (Exception exception) ');
indent.write('catch (Error | RuntimeException exception) ');
indent.scoped('{', '}', () {
indent.writeln(
'wrapped.put("${Keys.error}", wrapError(exception));');
Expand Down Expand Up @@ -298,7 +298,7 @@ void generateJava(JavaOptions options, Root root, StringSink sink) {
}

indent.format('''
private static Map<String, Object> wrapError(Exception exception) {
private static Map<String, Object> wrapError(Throwable exception) {
\tMap<String, Object> errorMap = new HashMap<>();
\terrorMap.put("${Keys.errorMessage}", exception.toString());
\terrorMap.put("${Keys.errorCode}", exception.getClass().getSimpleName());
Expand Down
2 changes: 1 addition & 1 deletion packages/pigeon/lib/pigeon_lib.dart
Original file line number Diff line number Diff line change
Expand Up @@ -305,7 +305,7 @@ options:
..addOption('objc_prefix',
help: 'Prefix for generated Objective-C classes and protocols.');

/// Convert command-line arugments to [PigeonOptions].
/// Convert command-line arguments to [PigeonOptions].
static PigeonOptions parseArgs(List<String> args) {
final ArgResults results = _argParser.parse(args);

Expand Down
2 changes: 1 addition & 1 deletion packages/pigeon/pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name: pigeon
version: 0.1.22 # This must match the version in lib/generator_tools.dart
version: 0.1.23 # This must match the version in lib/generator_tools.dart
description: Code generator tool to make communication between Flutter and the host platform type-safe and easier.
homepage: https://github.com/flutter/packages/tree/master/packages/pigeon
dependencies:
Expand Down
51 changes: 39 additions & 12 deletions packages/pigeon/run_tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,16 @@ set -ex
JAVA_LINTER=checkstyle-8.41-all.jar
JAVA_FORMATTER=google-java-format-1.3-all-deps.jar
GOOGLE_CHECKS=google_checks.xml
JAVA_ERROR_PRONE=error_prone_core-2.5.1-with-dependencies.jar
DATAFLOW_SHADED=dataflow-shaded-3.7.1.jar
JFORMAT_STRING=jFormatString-3.0.0.jar
JAVA_VERSION=$(java -version 2>&1 | head -1 | cut -d'"' -f2 | sed '/^1\./s///' | cut -d'.' -f1)
JAVAC_JAR=javac-9+181-r4173-1.jar
if [ $JAVA_VERSION == "8" ]; then
JAVAC_BOOTCLASSPATH="-J-Xbootclasspath/p:ci/$JAVAC_JAR"
else
JAVAC_BOOTCLASSPATH=
fi

# TODO(blasten): Enable on stable when possible.
# https://github.com/flutter/flutter/issues/75187
Expand Down Expand Up @@ -72,17 +82,21 @@ test_pigeon_android() {
--input $1 \
--dart_out $temp_dir/pigeon.dart \
--java_out $temp_dir/Pigeon.java \
--java_package foo

if ! javac $temp_dir/Pigeon.java \
-Xlint:unchecked \
-classpath "$flutter_bin/cache/artifacts/engine/android-x64/flutter.jar"; then
java -jar ci/$JAVA_FORMATTER --replace "$temp_dir/Pigeon.java"
java -jar ci/$JAVA_LINTER -c "ci/$GOOGLE_CHECKS" "$temp_dir/Pigeon.java"
if ! javac \
$JAVAC_BOOTCLASSPATH \
-XDcompilePolicy=simple \
-processorpath "ci/$JAVA_ERROR_PRONE:ci/$DATAFLOW_SHADED:ci/$JFORMAT_STRING" \
'-Xplugin:ErrorProne -Xep:CatchingUnchecked:ERROR' \
-classpath "$flutter_bin/cache/artifacts/engine/android-x64/flutter.jar" \
$temp_dir/Pigeon.java; then
echo "javac $temp_dir/Pigeon.java failed"
exit 1
fi

java -jar $JAVA_FORMATTER $temp_dir/Pigeon.java > $temp_dir/Pigeon.java
java -jar $JAVA_LINTER -c $GOOGLE_CHECKS $temp_dir/Pigeon.java

dartfmt -w $temp_dir/pigeon.dart
dartanalyzer $temp_dir/pigeon.dart --fatal-infos --fatal-warnings --packages ./e2e_tests/test_objc/.packages

Expand All @@ -108,15 +122,28 @@ test_null_safe_dart() {
###############################################################################
# Get java linter / formatter
###############################################################################
if [ ! -f "$JAVA_LINTER" ]; then
curl -L https://github.com/checkstyle/checkstyle/releases/download/checkstyle-8.41/$JAVA_LINTER > $JAVA_LINTER
if [ ! -f "ci/$JAVA_LINTER" ]; then
curl -L https://github.com/checkstyle/checkstyle/releases/download/checkstyle-8.41/$JAVA_LINTER > "ci/$JAVA_LINTER"
fi
if [ ! -f "ci/$JAVA_FORMATTER" ]; then
curl -L https://github.com/google/google-java-format/releases/download/google-java-format-1.3/$JAVA_FORMATTER > "ci/$JAVA_FORMATTER"
fi
if [ ! -f "ci/$GOOGLE_CHECKS" ]; then
curl -L https://raw.githubusercontent.com/checkstyle/checkstyle/master/src/main/resources/$GOOGLE_CHECKS > "ci/$GOOGLE_CHECKS"
fi
if [ ! -f "$JAVA_FORMATTER" ]; then
curl -L https://github.com/google/google-java-format/releases/download/google-java-format-1.3/$JAVA_FORMATTER > $JAVA_FORMATTER
if [ ! -f "ci/$JAVA_ERROR_PRONE" ]; then
curl https://repo1.maven.org/maven2/com/google/errorprone/error_prone_core/2.5.1/$JAVA_ERROR_PRONE > "ci/$JAVA_ERROR_PRONE"
fi
if [ ! -f "$GOOGLE_CHECKS" ]; then
curl -L https://raw.githubusercontent.com/checkstyle/checkstyle/master/src/main/resources/$GOOGLE_CHECKS > $GOOGLE_CHECKS
if [ ! -f "ci/$DATAFLOW_SHADED" ]; then
curl https://repo1.maven.org/maven2/org/checkerframework/dataflow-shaded/3.7.1/$DATAFLOW_SHADED > "ci/$DATAFLOW_SHADED"
fi
if [ ! -f "ci/$JFORMAT_STRING" ]; then
curl https://repo1.maven.org/maven2/com/google/code/findbugs/jFormatString/3.0.0/$JFORMAT_STRING > "ci/$JFORMAT_STRING"
fi
if [ ! -f "ci/$JAVAC_JAR" ]; then
curl https://repo1.maven.org/maven2/com/google/errorprone/javac/9+181-r4173-1/$JAVAC_JAR > "ci/$JAVAC_JAR"
fi


###############################################################################
# Dart analysis and unit tests
Expand Down
2 changes: 1 addition & 1 deletion packages/pigeon/test/pigeon_lib_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,7 @@ void main() {
expect(results.errors.length, 1);
});

test('null saftey flag', () {
test('null safety flag', () {
final PigeonOptions results =
Pigeon.parseArgs(<String>['--dart_null_safety']);
expect(results.dartOptions.isNullSafe, true);
Expand Down