Skip to content
Open
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
7 changes: 7 additions & 0 deletions packages/pigeon/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
## 26.1.11

* [dart] Ignores all lint rules in generated code.
* [dart] In generated code, imports the meta package for annotations, instead of
the Flutter foundation library.
* [dart] In generated code, no longer imports Uint8List.

## 26.1.10

* Dramatically reduces the number of File write operations sent to the operating
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,14 @@
// found in the LICENSE file.
// Autogenerated from Pigeon, 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, unnecessary_parenthesis, prefer_null_aware_operators, omit_local_variable_types, omit_obvious_local_variable_types, unused_shown_name, unnecessary_import, no_leading_underscores_for_local_identifiers
// ignore_for_file: unused_import, unused_shown_name
// ignore_for_file: public_member_api_docs, non_constant_identifier_names, avoid_as, unnecessary_parenthesis, prefer_null_aware_operators, omit_local_variable_types, omit_obvious_local_variable_types, unnecessary_import, no_leading_underscores_for_local_identifiers

import 'dart:async';
import 'dart:typed_data' show Float64List, Int32List, Int64List, Uint8List;
import 'dart:typed_data' show Float64List, Int32List, Int64List;

import 'package:flutter/foundation.dart' show ReadBuffer, WriteBuffer;
import 'package:flutter/services.dart';
import 'package:meta/meta.dart' show immutable, protected, visibleForTesting;

bool _deepEquals(Object? a, Object? b) {
if (a is List && b is List) {
Expand Down
7 changes: 4 additions & 3 deletions packages/pigeon/example/app/lib/src/messages.g.dart
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,14 @@
// found in the LICENSE file.
// Autogenerated from Pigeon, 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, unnecessary_parenthesis, prefer_null_aware_operators, omit_local_variable_types, omit_obvious_local_variable_types, unused_shown_name, unnecessary_import, no_leading_underscores_for_local_identifiers
// ignore_for_file: unused_import, unused_shown_name
// ignore_for_file: public_member_api_docs, non_constant_identifier_names, avoid_as, unnecessary_parenthesis, prefer_null_aware_operators, omit_local_variable_types, omit_obvious_local_variable_types, unnecessary_import, no_leading_underscores_for_local_identifiers

import 'dart:async';
import 'dart:typed_data' show Float64List, Int32List, Int64List, Uint8List;
import 'dart:typed_data' show Float64List, Int32List, Int64List;

import 'package:flutter/foundation.dart' show ReadBuffer, WriteBuffer;
import 'package:flutter/services.dart';
import 'package:meta/meta.dart' show immutable, protected, visibleForTesting;

Object? _extractReplyValueOrThrow(
List<Object?>? replyList,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import 'package:pigeon/pigeon.dart';
@ConfigurePigeon(
PigeonOptions(
dartOut: 'lib/src/event_channel_messages.g.dart',
dartOptions: DartOptions(),
dartOptions: DartOptions(ignoreLints: false),
cppOptions: CppOptions(namespace: 'pigeon_example'),
kotlinOut:
'android/app/src/main/kotlin/dev/flutter/pigeon_example_app/EventChannelMessages.g.kt',
Expand Down
2 changes: 1 addition & 1 deletion packages/pigeon/example/app/pigeons/messages.dart
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import 'package:pigeon/pigeon.dart';
@ConfigurePigeon(
PigeonOptions(
dartOut: 'lib/src/messages.g.dart',
dartOptions: DartOptions(),
dartOptions: DartOptions(ignoreLints: false),
cppOptions: CppOptions(namespace: 'pigeon_example'),
cppHeaderOut: 'windows/runner/messages.g.h',
cppSourceOut: 'windows/runner/messages.g.cpp',
Expand Down
46 changes: 36 additions & 10 deletions packages/pigeon/lib/src/dart/dart_generator.dart
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,8 @@ class DartOptions {
this.copyrightHeader,
this.sourceOutPath,
this.testOutPath,
});
bool ignoreLints = true,
}) : _ignoreLints = ignoreLints;

/// A copyright header that will get prepended to generated code.
final Iterable<String>? copyrightHeader;
Expand All @@ -60,6 +61,9 @@ class DartOptions {
/// Path to output generated Test file for tests.
final String? testOutPath;

/// Whether to ignore lint violations in generated Dart code.
final bool _ignoreLints;

/// Creates a [DartOptions] from a Map representation where:
/// `x = DartOptions.fromMap(x.toMap())`.
static DartOptions fromMap(Map<String, Object> map) {
Expand All @@ -68,6 +72,7 @@ class DartOptions {
copyrightHeader: copyrightHeader?.cast<String>(),
sourceOutPath: map['sourceOutPath'] as String?,
testOutPath: map['testOutPath'] as String?,
ignoreLints: (map['ignoreLints'] as bool?) ?? true,
);
}

Expand All @@ -78,6 +83,7 @@ class DartOptions {
if (copyrightHeader != null) 'copyrightHeader': copyrightHeader!,
if (sourceOutPath != null) 'sourceOutPath': sourceOutPath!,
if (testOutPath != null) 'testOutPath': testOutPath!,
'ignoreLints': _ignoreLints,
};
return result;
}
Expand All @@ -92,7 +98,12 @@ class DartOptions {
/// Options that control how Dart code will be generated.
class InternalDartOptions extends InternalOptions {
/// Constructor for InternalDartOptions.
const InternalDartOptions({this.copyrightHeader, this.dartOut, this.testOut});
const InternalDartOptions({
this.copyrightHeader,
this.dartOut,
this.testOut,
required bool ignoreLints,
}) : _ignoreLints = ignoreLints;

/// Creates InternalDartOptions from DartOptions.
InternalDartOptions.fromDartOptions(
Expand All @@ -102,7 +113,8 @@ class InternalDartOptions extends InternalOptions {
String? testOut,
}) : copyrightHeader = copyrightHeader ?? options.copyrightHeader,
dartOut = (dartOut ?? options.sourceOutPath)!,
testOut = testOut ?? options.testOutPath;
testOut = testOut ?? options.testOutPath,
_ignoreLints = options._ignoreLints;

/// A copyright header that will get prepended to generated code.
final Iterable<String>? copyrightHeader;
Expand All @@ -112,6 +124,9 @@ class InternalDartOptions extends InternalOptions {

/// Path to output generated Test file for tests.
final String? testOut;

/// Whether to ignore lint violations in generated Dart code.
final bool _ignoreLints;
}

/// Class that manages all Dart code generation.
Expand All @@ -136,9 +151,20 @@ class DartGenerator extends StructuredGenerator<InternalDartOptions> {
}
indent.writeln('// ${getGeneratedCodeWarning()}');
indent.writeln('// $seeAlsoWarning');
indent.writeln(
'// ignore_for_file: public_member_api_docs, non_constant_identifier_names, avoid_as, unused_import, unnecessary_parenthesis, prefer_null_aware_operators, omit_local_variable_types, omit_obvious_local_variable_types, unused_shown_name, unnecessary_import, no_leading_underscores_for_local_identifiers',
);
indent.writeln('// ignore_for_file: unused_import, unused_shown_name');
if (generatorOptions._ignoreLints) {
indent.writeln('// ignore_for_file: type=lint');
} else {
// Just ignore the lint rules we know we violate and which we care about
// in our own checked-in generated files.
indent.writeln(
'// ignore_for_file: public_member_api_docs, '
'non_constant_identifier_names, avoid_as, unnecessary_parenthesis, '
'prefer_null_aware_operators, omit_local_variable_types, '
'omit_obvious_local_variable_types, unnecessary_import, '
'no_leading_underscores_for_local_identifiers',
);
}
indent.newln();
}

Expand All @@ -154,19 +180,19 @@ class DartGenerator extends StructuredGenerator<InternalDartOptions> {
indent.writeln("import 'dart:io' show Platform;");
}
indent.writeln(
"import 'dart:typed_data' show Float64List, Int32List, Int64List, Uint8List;",
"import 'dart:typed_data' show Float64List, Int32List, Int64List;",
);
indent.newln();

indent.writeln(
"import 'package:flutter/foundation.dart' show ReadBuffer, WriteBuffer${root.containsProxyApi ? ', immutable, protected, visibleForTesting' : ''};",
);
indent.writeln("import 'package:flutter/services.dart';");
if (root.containsProxyApi) {
indent.writeln(
"import 'package:flutter/widgets.dart' show WidgetsFlutterBinding;",
);
}
indent.writeln(
"import 'package:meta/meta.dart' show immutable, protected, visibleForTesting;",
);
}

@override
Expand Down
2 changes: 1 addition & 1 deletion packages/pigeon/lib/src/generator_tools.dart
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import 'generator.dart';
/// The current version of pigeon.
///
/// This must match the version in pubspec.yaml.
const String pigeonVersion = '26.1.10';
const String pigeonVersion = '26.1.11';

/// Read all the content from [stdin] to a String.
String readStdin() {
Expand Down
12 changes: 11 additions & 1 deletion packages/pigeon/lib/src/pigeon_lib.dart
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ import 'package:path/path.dart' as path;
import 'ast.dart';
import 'cpp/cpp_generator.dart';
import 'dart/dart_generator.dart';
import 'generator_tools.dart';
import 'generator_tools.dart' as generator_tools;
import 'generator_tools.dart';
import 'gobject/gobject_generator.dart';
import 'java/java_generator.dart';
import 'kotlin/kotlin_generator.dart';
Expand Down Expand Up @@ -264,6 +264,7 @@ class PigeonOptions {
this.debugGenerators,
this.basePath,
String? dartPackageName,
this.ignoreLints = true,
}) : _dartPackageName = dartPackageName;

/// Path to the file which will be processed.
Expand Down Expand Up @@ -339,6 +340,9 @@ class PigeonOptions {
/// The name of the package the pigeon files will be used in.
final String? _dartPackageName;

/// Whether to ignore lint violations in generated Dart code.
final bool ignoreLints;

/// Creates a [PigeonOptions] from a Map representation where:
/// `x = PigeonOptions.fromMap(x.toMap())`.
static PigeonOptions fromMap(Map<String, Object> map) {
Expand Down Expand Up @@ -611,6 +615,11 @@ ${_argParser.usage}''';
..addOption(
'package_name',
help: 'The package that generated code will be in.',
)
..addFlag(
'ignore_lints',
help: 'Ignore all lint violations in generated Dart code.',
hide: true,
);

/// Convert command-line arguments to [PigeonOptions].
Expand Down Expand Up @@ -652,6 +661,7 @@ ${_argParser.usage}''';
debugGenerators: results['debug_generators'] as bool?,
basePath: results['base_path'] as String?,
dartPackageName: results['package_name'] as String?,
ignoreLints: results.flag('ignore_lints'),
);
return opts;
}
Expand Down
3 changes: 2 additions & 1 deletion packages/pigeon/lib/src/pigeon_lib_internal.dart
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,8 @@ class InternalPigeonOptions {
options.dartOptions?.sourceOutPath == null)
? null
: InternalDartOptions.fromDartOptions(
options.dartOptions ?? const DartOptions(),
options.dartOptions ??
DartOptions(ignoreLints: options.ignoreLints),
dartOut: options.dartOut,
testOut: options.dartTestOut,
copyrightHeader: copyrightHeader,
Expand Down
2 changes: 1 addition & 1 deletion packages/pigeon/pigeons/configure_pigeon_dart_out.dart
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import 'package:pigeon/pigeon.dart';
PigeonOptions(
dartOut: 'stdout',
javaOut: 'stdout',
dartOptions: DartOptions(),
dartOptions: DartOptions(ignoreLints: false),
),
)
@HostApi()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,14 @@
//
// Autogenerated from Pigeon, 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, unnecessary_parenthesis, prefer_null_aware_operators, omit_local_variable_types, omit_obvious_local_variable_types, unused_shown_name, unnecessary_import, no_leading_underscores_for_local_identifiers
// ignore_for_file: unused_import, unused_shown_name
// ignore_for_file: public_member_api_docs, non_constant_identifier_names, avoid_as, unnecessary_parenthesis, prefer_null_aware_operators, omit_local_variable_types, omit_obvious_local_variable_types, unnecessary_import, no_leading_underscores_for_local_identifiers

import 'dart:async';
import 'dart:typed_data' show Float64List, Int32List, Int64List, Uint8List;
import 'dart:typed_data' show Float64List, Int32List, Int64List;

import 'package:flutter/foundation.dart' show ReadBuffer, WriteBuffer;
import 'package:flutter/services.dart';
import 'package:meta/meta.dart' show immutable, protected, visibleForTesting;

Object? _extractReplyValueOrThrow(
List<Object?>? replyList,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,14 @@
//
// Autogenerated from Pigeon, 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, unnecessary_parenthesis, prefer_null_aware_operators, omit_local_variable_types, omit_obvious_local_variable_types, unused_shown_name, unnecessary_import, no_leading_underscores_for_local_identifiers
// ignore_for_file: unused_import, unused_shown_name
// ignore_for_file: public_member_api_docs, non_constant_identifier_names, avoid_as, unnecessary_parenthesis, prefer_null_aware_operators, omit_local_variable_types, omit_obvious_local_variable_types, unnecessary_import, no_leading_underscores_for_local_identifiers

import 'dart:async';
import 'dart:typed_data' show Float64List, Int32List, Int64List, Uint8List;
import 'dart:typed_data' show Float64List, Int32List, Int64List;

import 'package:flutter/foundation.dart' show ReadBuffer, WriteBuffer;
import 'package:flutter/services.dart';
import 'package:meta/meta.dart' show immutable, protected, visibleForTesting;

Object? _extractReplyValueOrThrow(
List<Object?>? replyList,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,14 @@
//
// Autogenerated from Pigeon, 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, unnecessary_parenthesis, prefer_null_aware_operators, omit_local_variable_types, omit_obvious_local_variable_types, unused_shown_name, unnecessary_import, no_leading_underscores_for_local_identifiers
// ignore_for_file: unused_import, unused_shown_name
// ignore_for_file: public_member_api_docs, non_constant_identifier_names, avoid_as, unnecessary_parenthesis, prefer_null_aware_operators, omit_local_variable_types, omit_obvious_local_variable_types, unnecessary_import, no_leading_underscores_for_local_identifiers

import 'dart:async';
import 'dart:typed_data' show Float64List, Int32List, Int64List, Uint8List;
import 'dart:typed_data' show Float64List, Int32List, Int64List;

import 'package:flutter/foundation.dart' show ReadBuffer, WriteBuffer;
import 'package:flutter/services.dart';
import 'package:meta/meta.dart' show immutable, protected, visibleForTesting;

bool _deepEquals(Object? a, Object? b) {
if (a is List && b is List) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,14 @@
//
// Autogenerated from Pigeon, 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, unnecessary_parenthesis, prefer_null_aware_operators, omit_local_variable_types, omit_obvious_local_variable_types, unused_shown_name, unnecessary_import, no_leading_underscores_for_local_identifiers
// ignore_for_file: unused_import, unused_shown_name
// ignore_for_file: public_member_api_docs, non_constant_identifier_names, avoid_as, unnecessary_parenthesis, prefer_null_aware_operators, omit_local_variable_types, omit_obvious_local_variable_types, unnecessary_import, no_leading_underscores_for_local_identifiers

import 'dart:async';
import 'dart:typed_data' show Float64List, Int32List, Int64List, Uint8List;
import 'dart:typed_data' show Float64List, Int32List, Int64List;

import 'package:flutter/foundation.dart' show ReadBuffer, WriteBuffer;
import 'package:flutter/services.dart';
import 'package:meta/meta.dart' show immutable, protected, visibleForTesting;

class _PigeonCodec extends StandardMessageCodec {
const _PigeonCodec();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,14 @@
//
// Autogenerated from Pigeon, 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, unnecessary_parenthesis, prefer_null_aware_operators, omit_local_variable_types, omit_obvious_local_variable_types, unused_shown_name, unnecessary_import, no_leading_underscores_for_local_identifiers
// ignore_for_file: unused_import, unused_shown_name
// ignore_for_file: public_member_api_docs, non_constant_identifier_names, avoid_as, unnecessary_parenthesis, prefer_null_aware_operators, omit_local_variable_types, omit_obvious_local_variable_types, unnecessary_import, no_leading_underscores_for_local_identifiers

import 'dart:async';
import 'dart:typed_data' show Float64List, Int32List, Int64List, Uint8List;
import 'dart:typed_data' show Float64List, Int32List, Int64List;

import 'package:flutter/foundation.dart' show ReadBuffer, WriteBuffer;
import 'package:flutter/services.dart';
import 'package:meta/meta.dart' show immutable, protected, visibleForTesting;

Object? _extractReplyValueOrThrow(
List<Object?>? replyList,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,14 @@
//
// Autogenerated from Pigeon, 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, unnecessary_parenthesis, prefer_null_aware_operators, omit_local_variable_types, omit_obvious_local_variable_types, unused_shown_name, unnecessary_import, no_leading_underscores_for_local_identifiers
// ignore_for_file: unused_import, unused_shown_name
// ignore_for_file: public_member_api_docs, non_constant_identifier_names, avoid_as, unnecessary_parenthesis, prefer_null_aware_operators, omit_local_variable_types, omit_obvious_local_variable_types, unnecessary_import, no_leading_underscores_for_local_identifiers

import 'dart:async';
import 'dart:typed_data' show Float64List, Int32List, Int64List, Uint8List;
import 'dart:typed_data' show Float64List, Int32List, Int64List;

import 'package:flutter/foundation.dart' show ReadBuffer, WriteBuffer;
import 'package:flutter/services.dart';
import 'package:meta/meta.dart' show immutable, protected, visibleForTesting;

Object? _extractReplyValueOrThrow(
List<Object?>? replyList,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,14 @@
//
// Autogenerated from Pigeon, 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, unnecessary_parenthesis, prefer_null_aware_operators, omit_local_variable_types, omit_obvious_local_variable_types, unused_shown_name, unnecessary_import, no_leading_underscores_for_local_identifiers
// ignore_for_file: unused_import, unused_shown_name
// ignore_for_file: public_member_api_docs, non_constant_identifier_names, avoid_as, unnecessary_parenthesis, prefer_null_aware_operators, omit_local_variable_types, omit_obvious_local_variable_types, unnecessary_import, no_leading_underscores_for_local_identifiers

import 'dart:async';
import 'dart:typed_data' show Float64List, Int32List, Int64List, Uint8List;
import 'dart:typed_data' show Float64List, Int32List, Int64List;

import 'package:flutter/foundation.dart' show ReadBuffer, WriteBuffer;
import 'package:flutter/services.dart';
import 'package:meta/meta.dart' show immutable, protected, visibleForTesting;

Object? _extractReplyValueOrThrow(
List<Object?>? replyList,
Expand Down
Loading
Loading