Skip to content
Closed
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
1 change: 1 addition & 0 deletions analysis_options.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ analyzer:
exclude: # DIFFERENT FROM FLUTTER/FLUTTER
# Ignore generated files
- '**/*.g.dart'
- '**/*.gen.jni.dart'
- '**/*.mocks.dart' # Mockito @GenerateMocks

linter:
Expand Down
2 changes: 1 addition & 1 deletion packages/pigeon/example/app/lib/src/messages.g.dart
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ bool _deepEquals(Object? a, Object? b) {

enum Code {
one,
two,
two;
}

class MessageData {
Expand Down
45 changes: 40 additions & 5 deletions packages/pigeon/lib/src/ast.dart
Original file line number Diff line number Diff line change
Expand Up @@ -510,6 +510,24 @@ class TypeDeclaration {
/// Associated [AstProxyApi], if any.
final AstProxyApi? associatedProxyApi;

/// Returns the full annotated name of the type.
String getFullName({bool withNullable = true}) {
if (baseName == 'List' || baseName == 'Map') {
return '$baseName<$typeArgumentsString>${isNullable && withNullable ? '?' : ''}';
}
return '$baseName${isNullable && withNullable ? '?' : ''}';
}

/// Returns the Type Arguments in annotation form.
String get typeArgumentsString {
if (baseName == 'List') {
return typeArguments.firstOrNull?.getFullName() ?? 'Object?';
} else if (baseName == 'Map') {
return '${typeArguments.firstOrNull?.getFullName() ?? 'Object?'}, ${typeArguments.lastOrNull?.getFullName() ?? 'Object?'}';
}
return '';
}

@override
int get hashCode {
// This has to be implemented because TypeDeclaration is used as a Key to a
Expand Down Expand Up @@ -541,32 +559,35 @@ class TypeDeclaration {

/// Returns duplicated `TypeDeclaration` with attached `associatedEnum` value.
TypeDeclaration copyWithEnum(Enum enumDefinition) {
return TypeDeclaration(
final TypeDeclaration newType = TypeDeclaration(
baseName: baseName,
isNullable: isNullable,
associatedEnum: enumDefinition,
typeArguments: typeArguments,
);
return newType;
}

/// Returns duplicated `TypeDeclaration` with attached `associatedClass` value.
TypeDeclaration copyWithClass(Class classDefinition) {
return TypeDeclaration(
final TypeDeclaration newType = TypeDeclaration(
baseName: baseName,
isNullable: isNullable,
associatedClass: classDefinition,
typeArguments: typeArguments,
);
return newType;
}

/// Returns duplicated `TypeDeclaration` with attached `associatedProxyApi` value.
TypeDeclaration copyWithProxyApi(AstProxyApi proxyApiDefinition) {
return TypeDeclaration(
final TypeDeclaration newType = TypeDeclaration(
baseName: baseName,
isNullable: isNullable,
associatedProxyApi: proxyApiDefinition,
typeArguments: typeArguments,
);
return newType;
}

/// Returns duplicated `TypeDeclaration` with attached `associatedProxyApi` value.
Expand Down Expand Up @@ -814,6 +835,8 @@ class Root extends Node {
required this.classes,
required this.apis,
required this.enums,
this.lists = const <String, TypeDeclaration>{},
this.maps = const <String, TypeDeclaration>{},
this.containsHostApi = false,
this.containsFlutterApi = false,
this.containsProxyApi = false,
Expand All @@ -822,7 +845,13 @@ class Root extends Node {

/// Factory function for generating an empty root, usually used when early errors are encountered.
factory Root.makeEmpty() {
return Root(apis: <Api>[], classes: <Class>[], enums: <Enum>[]);
return Root(
apis: <Api>[],
classes: <Class>[],
enums: <Enum>[],
lists: <String, TypeDeclaration>{},
maps: <String, TypeDeclaration>{},
);
}

/// All the classes contained in the AST.
Expand All @@ -834,6 +863,12 @@ class Root extends Node {
/// All of the enums contained in the AST.
List<Enum> enums;

/// All of the lists contained in the AST.
Map<String, TypeDeclaration> lists;

/// All of the maps contained in the AST.
Map<String, TypeDeclaration> maps;

/// Whether the root has any Host API definitions.
bool containsHostApi;

Expand All @@ -856,6 +891,6 @@ class Root extends Node {

@override
String toString() {
return '(Root classes:$classes apis:$apis enums:$enums)';
return '(Root classes:$classes apis:$apis enums:$enums lists:$lists maps:$maps containsHostApi:$containsHostApi containsFlutterApi:$containsFlutterApi containsProxyApi:$containsProxyApi)';
}
}
2 changes: 1 addition & 1 deletion packages/pigeon/lib/src/cpp/cpp_generator.dart
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ class CppOptions {
/// Overrides any non-null parameters from [options] into this to make a new
/// [CppOptions].
CppOptions merge(CppOptions options) {
return CppOptions.fromMap(mergeMaps(toMap(), options.toMap()));
return CppOptions.fromMap(mergePigeonMaps(toMap(), options.toMap()));
}
}

Expand Down
Loading