mirror of
https://github.com/flutter/packages.git
synced 2025-07-01 23:51:55 +08:00
[pigeon] added support for explicit objects (#483)
This commit is contained in:
@ -1,3 +1,8 @@
|
||||
## 1.0.8
|
||||
|
||||
* [front-end] Started accepting explicit Object references in type arguments.
|
||||
* [codecs] Fixed nuisance where duplicate entries could show up in custom codecs.
|
||||
|
||||
## 1.0.7
|
||||
|
||||
* [front-end] Fixed bug where nested classes' type arguments aren't included in
|
||||
|
@ -2,6 +2,11 @@
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
import 'package:collection/collection.dart' show ListEquality;
|
||||
import 'package:meta/meta.dart';
|
||||
|
||||
final Function _listEquals = const ListEquality<dynamic>().equals;
|
||||
|
||||
/// Enum that represents where an [Api] is located, on the host or Flutter.
|
||||
enum ApiLocation {
|
||||
/// The API is for calling functions defined on the host.
|
||||
@ -79,16 +84,17 @@ class Api extends Node {
|
||||
}
|
||||
|
||||
/// A specific instance of a type.
|
||||
@immutable
|
||||
class TypeDeclaration {
|
||||
/// Constructor for [TypeDeclaration].
|
||||
TypeDeclaration({
|
||||
const TypeDeclaration({
|
||||
required this.baseName,
|
||||
required this.isNullable,
|
||||
this.typeArguments = const <TypeDeclaration>[],
|
||||
});
|
||||
|
||||
/// Void constructor.
|
||||
TypeDeclaration.voidDeclaration()
|
||||
const TypeDeclaration.voidDeclaration()
|
||||
: baseName = 'void',
|
||||
isNullable = false,
|
||||
typeArguments = const <TypeDeclaration>[];
|
||||
@ -105,6 +111,31 @@ class TypeDeclaration {
|
||||
/// True if the type is nullable.
|
||||
final bool isNullable;
|
||||
|
||||
@override
|
||||
int get hashCode {
|
||||
// This has to be implemented because TypeDeclaration is used as a Key to a
|
||||
// Map in generator_tools.dart.
|
||||
int hash = 17;
|
||||
hash = hash * 37 + baseName.hashCode;
|
||||
hash = hash * 37 + isNullable.hashCode;
|
||||
for (final TypeDeclaration typeArgument in typeArguments) {
|
||||
hash = hash * 37 + typeArgument.hashCode;
|
||||
}
|
||||
return hash;
|
||||
}
|
||||
|
||||
@override
|
||||
bool operator ==(Object other) {
|
||||
if (other.runtimeType != runtimeType) {
|
||||
return false;
|
||||
} else {
|
||||
return other is TypeDeclaration &&
|
||||
baseName == other.baseName &&
|
||||
isNullable == other.isNullable &&
|
||||
_listEquals(typeArguments, other.typeArguments);
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return '(TypeDeclaration baseName:$baseName isNullable:$isNullable typeArguments:$typeArguments)';
|
||||
|
@ -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 = '1.0.7';
|
||||
const String pigeonVersion = '1.0.8';
|
||||
|
||||
/// Read all the content from [stdin] to a String.
|
||||
String readStdin() {
|
||||
@ -275,6 +275,7 @@ const List<String> validTypes = <String>[
|
||||
'Float64List',
|
||||
'List',
|
||||
'Map',
|
||||
'Object',
|
||||
];
|
||||
|
||||
/// Custom codecs' custom types are enumerated from 255 down to this number to
|
||||
|
@ -62,48 +62,58 @@ String _className(String? prefix, String className) {
|
||||
}
|
||||
}
|
||||
|
||||
String _callbackForType(TypeDeclaration type, String objcType) {
|
||||
String _callbackForType(TypeDeclaration type, _ObjcPtr objcType) {
|
||||
return type.isVoid
|
||||
? 'void(^)(NSError *_Nullable)'
|
||||
: 'void(^)($objcType *, NSError *_Nullable)';
|
||||
: 'void(^)(${objcType.ptr.trim()}, NSError *_Nullable)';
|
||||
}
|
||||
|
||||
const Map<String, String> _objcTypeForDartTypeMap = <String, String>{
|
||||
'bool': 'NSNumber',
|
||||
'int': 'NSNumber',
|
||||
'String': 'NSString',
|
||||
'double': 'NSNumber',
|
||||
'Uint8List': 'FlutterStandardTypedData',
|
||||
'Int32List': 'FlutterStandardTypedData',
|
||||
'Int64List': 'FlutterStandardTypedData',
|
||||
'Float64List': 'FlutterStandardTypedData',
|
||||
'List': 'NSArray',
|
||||
'Map': 'NSDictionary',
|
||||
class _ObjcPtr {
|
||||
const _ObjcPtr({required this.baseName}) : hasAsterisk = baseName != 'id';
|
||||
final String baseName;
|
||||
final bool hasAsterisk;
|
||||
String get ptr => '$baseName${hasAsterisk ? ' *' : ' '}';
|
||||
}
|
||||
|
||||
const Map<String, _ObjcPtr> _objcTypeForDartTypeMap = <String, _ObjcPtr>{
|
||||
'bool': _ObjcPtr(baseName: 'NSNumber'),
|
||||
'int': _ObjcPtr(baseName: 'NSNumber'),
|
||||
'String': _ObjcPtr(baseName: 'NSString'),
|
||||
'double': _ObjcPtr(baseName: 'NSNumber'),
|
||||
'Uint8List': _ObjcPtr(baseName: 'FlutterStandardTypedData'),
|
||||
'Int32List': _ObjcPtr(baseName: 'FlutterStandardTypedData'),
|
||||
'Int64List': _ObjcPtr(baseName: 'FlutterStandardTypedData'),
|
||||
'Float64List': _ObjcPtr(baseName: 'FlutterStandardTypedData'),
|
||||
'List': _ObjcPtr(baseName: 'NSArray'),
|
||||
'Map': _ObjcPtr(baseName: 'NSDictionary'),
|
||||
'Object': _ObjcPtr(baseName: 'id'),
|
||||
};
|
||||
|
||||
String _flattenTypeArguments(String? classPrefix, List<TypeDeclaration> args) {
|
||||
final String result = args
|
||||
.map<String>(
|
||||
(TypeDeclaration e) => '${_objcTypeForDartType(classPrefix, e)} *')
|
||||
.map<String>((TypeDeclaration e) =>
|
||||
_objcTypeForDartType(classPrefix, e).ptr.trim())
|
||||
.join(', ');
|
||||
return result;
|
||||
}
|
||||
|
||||
String? _objcTypePtrForPrimitiveDartType(String? classPrefix, NamedType field) {
|
||||
return _objcTypeForDartTypeMap.containsKey(field.type.baseName)
|
||||
? '${_objcTypeForDartType(classPrefix, field.type)} *'
|
||||
? _objcTypeForDartType(classPrefix, field.type).ptr
|
||||
: null;
|
||||
}
|
||||
|
||||
/// Returns the objc type for a dart [type], prepending the [classPrefix] for
|
||||
/// generated classes. For example:
|
||||
/// _objcTypeForDartType(null, 'int') => 'NSNumber'.
|
||||
String _objcTypeForDartType(String? classPrefix, TypeDeclaration field) {
|
||||
_ObjcPtr _objcTypeForDartType(String? classPrefix, TypeDeclaration field) {
|
||||
return _objcTypeForDartTypeMap.containsKey(field.baseName)
|
||||
? field.typeArguments.isEmpty
|
||||
? _objcTypeForDartTypeMap[field.baseName]!
|
||||
: '${_objcTypeForDartTypeMap[field.baseName]}<${_flattenTypeArguments(classPrefix, field.typeArguments)}>'
|
||||
: _className(classPrefix, field.baseName);
|
||||
: _ObjcPtr(
|
||||
baseName:
|
||||
'${_objcTypeForDartTypeMap[field.baseName]!.baseName}<${_flattenTypeArguments(classPrefix, field.typeArguments)}>')
|
||||
: _ObjcPtr(baseName: _className(classPrefix, field.baseName));
|
||||
}
|
||||
|
||||
String _propertyTypeForDartType(NamedType field) {
|
||||
@ -293,8 +303,8 @@ String _makeObjcSignature({
|
||||
final Iterable<String> argTypes = followedByOne(
|
||||
func.arguments.map((NamedType arg) {
|
||||
final String nullable = func.isAsynchronous ? 'nullable ' : '';
|
||||
final String argType = _objcTypeForDartType(options.prefix, arg.type);
|
||||
return '$nullable$argType *';
|
||||
final _ObjcPtr argType = _objcTypeForDartType(options.prefix, arg.type);
|
||||
return '$nullable${argType.ptr.trim()}';
|
||||
}),
|
||||
lastArgType,
|
||||
);
|
||||
@ -313,7 +323,7 @@ void _writeHostApiDeclaration(Indent indent, Api api, ObjcOptions options) {
|
||||
final String apiName = _className(options.prefix, api.name);
|
||||
indent.writeln('@protocol $apiName');
|
||||
for (final Method func in api.methods) {
|
||||
final String returnTypeName =
|
||||
final _ObjcPtr returnTypeName =
|
||||
_objcTypeForDartType(options.prefix, func.returnType);
|
||||
|
||||
String? lastArgName;
|
||||
@ -326,12 +336,13 @@ void _writeHostApiDeclaration(Indent indent, Api api, ObjcOptions options) {
|
||||
lastArgName = 'completion';
|
||||
} else {
|
||||
lastArgType =
|
||||
'void(^)($returnTypeName *_Nullable, FlutterError *_Nullable)';
|
||||
'void(^)(${returnTypeName.ptr}_Nullable, FlutterError *_Nullable)';
|
||||
lastArgName = 'completion';
|
||||
}
|
||||
} else {
|
||||
returnType =
|
||||
func.returnType.isVoid ? 'void' : 'nullable $returnTypeName *';
|
||||
returnType = func.returnType.isVoid
|
||||
? 'void'
|
||||
: 'nullable ${returnTypeName.ptr.trim()}';
|
||||
lastArgType = 'FlutterError *_Nullable *_Nonnull';
|
||||
lastArgName = 'error';
|
||||
}
|
||||
@ -356,7 +367,7 @@ void _writeFlutterApiDeclaration(Indent indent, Api api, ObjcOptions options) {
|
||||
indent.writeln(
|
||||
'- (instancetype)initWithBinaryMessenger:(id<FlutterBinaryMessenger>)binaryMessenger;');
|
||||
for (final Method func in api.methods) {
|
||||
final String returnType =
|
||||
final _ObjcPtr returnType =
|
||||
_objcTypeForDartType(options.prefix, func.returnType);
|
||||
final String callbackType = _callbackForType(func.returnType, returnType);
|
||||
indent.writeln(_makeObjcSignature(
|
||||
@ -492,7 +503,7 @@ void _writeHostApiSource(Indent indent, ObjcOptions options, Api api) {
|
||||
indent.write(
|
||||
'[channel setMessageHandler:^(id _Nullable message, FlutterReply callback) ');
|
||||
indent.scoped('{', '}];', () {
|
||||
final String returnType =
|
||||
final _ObjcPtr returnType =
|
||||
_objcTypeForDartType(options.prefix, func.returnType);
|
||||
String syncCall;
|
||||
String? callSignature;
|
||||
@ -506,9 +517,9 @@ void _writeHostApiSource(Indent indent, ObjcOptions options, Api api) {
|
||||
indexMap(func.arguments, _getSafeArgName);
|
||||
map3(wholeNumbers.take(func.arguments.length), argNames,
|
||||
func.arguments, (int count, String argName, NamedType arg) {
|
||||
final String argType =
|
||||
final _ObjcPtr argType =
|
||||
_objcTypeForDartType(options.prefix, arg.type);
|
||||
return '$argType *$argName = args[$count];';
|
||||
return '${argType.ptr}$argName = args[$count];';
|
||||
}).forEach(indent.writeln);
|
||||
callSignature =
|
||||
map2(selectorComponents.take(argNames.length), argNames,
|
||||
@ -537,13 +548,13 @@ void _writeHostApiSource(Indent indent, ObjcOptions options, Api api) {
|
||||
const String callback = 'callback(wrapResult(output, error));';
|
||||
if (func.arguments.isEmpty) {
|
||||
indent.writeScoped(
|
||||
'[api ${selectorComponents.first}:^($returnType *_Nullable output, FlutterError *_Nullable error) {',
|
||||
'[api ${selectorComponents.first}:^(${returnType.ptr}_Nullable output, FlutterError *_Nullable error) {',
|
||||
'}];', () {
|
||||
indent.writeln(callback);
|
||||
});
|
||||
} else {
|
||||
indent.writeScoped(
|
||||
'[api $callSignature ${selectorComponents.last}:^($returnType *_Nullable output, FlutterError *_Nullable error) {',
|
||||
'[api $callSignature ${selectorComponents.last}:^(${returnType.ptr}_Nullable output, FlutterError *_Nullable error) {',
|
||||
'}];', () {
|
||||
indent.writeln(callback);
|
||||
});
|
||||
@ -555,7 +566,7 @@ void _writeHostApiSource(Indent indent, ObjcOptions options, Api api) {
|
||||
indent.writeln('$syncCall;');
|
||||
indent.writeln('callback(wrapResult(nil, error));');
|
||||
} else {
|
||||
indent.writeln('$returnType *output = $syncCall;');
|
||||
indent.writeln('${returnType.ptr}output = $syncCall;');
|
||||
indent.writeln('callback(wrapResult(output, error));');
|
||||
}
|
||||
}
|
||||
@ -591,7 +602,7 @@ void _writeFlutterApiSource(Indent indent, ObjcOptions options, Api api) {
|
||||
});
|
||||
indent.addln('');
|
||||
for (final Method func in api.methods) {
|
||||
final String returnType =
|
||||
final _ObjcPtr returnType =
|
||||
_objcTypeForDartType(options.prefix, func.returnType);
|
||||
final String callbackType = _callbackForType(func.returnType, returnType);
|
||||
|
||||
@ -627,7 +638,7 @@ void _writeFlutterApiSource(Indent indent, ObjcOptions options, Api api) {
|
||||
if (func.returnType.isVoid) {
|
||||
indent.writeln('completion(nil);');
|
||||
} else {
|
||||
indent.writeln('$returnType *output = reply;');
|
||||
indent.writeln('${returnType.ptr}output = reply;');
|
||||
indent.writeln('completion(output, nil);');
|
||||
}
|
||||
});
|
||||
|
@ -565,6 +565,7 @@ class _RootBuilder extends dart_ast_visitor.RecursiveAstVisitor<Object?> {
|
||||
!validTypes.contains(element.key.baseName) &&
|
||||
!element.key.isVoid &&
|
||||
element.key.baseName != 'dynamic' &&
|
||||
element.key.baseName != 'Object' &&
|
||||
element.key.baseName.isNotEmpty) {
|
||||
final int? lineNumber = element.value.isEmpty
|
||||
? null
|
||||
@ -709,7 +710,7 @@ class _RootBuilder extends dart_ast_visitor.RecursiveAstVisitor<Object?> {
|
||||
} else {
|
||||
return NamedType(
|
||||
name: '',
|
||||
type: TypeDeclaration(baseName: '', isNullable: false),
|
||||
type: const TypeDeclaration(baseName: '', isNullable: false),
|
||||
offset: parameter.offset,
|
||||
);
|
||||
}
|
||||
|
@ -19,6 +19,7 @@ class Everything {
|
||||
Map? aMap;
|
||||
List<List<bool?>?>? nestedList;
|
||||
Map<String?, String?>? mapWithAnnotations;
|
||||
Map<String?, Object?>? mapWithObject;
|
||||
}
|
||||
|
||||
@HostApi()
|
||||
|
@ -51,6 +51,7 @@ public class AllDatatypesTest {
|
||||
assertNull(everything.getAFloatArray());
|
||||
assertNull(everything.getAList());
|
||||
assertNull(everything.getAMap());
|
||||
assertNull(everything.getMapWithObject());
|
||||
});
|
||||
assertTrue(didCall[0]);
|
||||
}
|
||||
@ -61,6 +62,12 @@ public class AllDatatypesTest {
|
||||
return result;
|
||||
}
|
||||
|
||||
private static HashMap<String, Object> makeStringMap(String key, Integer value) {
|
||||
HashMap<String, Object> result = new HashMap<String, Object>();
|
||||
result.put(key, value);
|
||||
return result;
|
||||
}
|
||||
|
||||
private static boolean floatArraysEqual(double[] x, double[] y) {
|
||||
if (x.length != y.length) {
|
||||
return false;
|
||||
@ -86,6 +93,7 @@ public class AllDatatypesTest {
|
||||
everything.setAFloatArray(new double[] {0.5, 0.25, 1.5, 1.25});
|
||||
everything.setAList(Arrays.asList(new int[] {1, 2, 3}));
|
||||
everything.setAMap(makeMap("hello", 1234));
|
||||
everything.setMapWithObject(makeStringMap("hello", 1234));
|
||||
BinaryMessenger binaryMessenger = mock(BinaryMessenger.class);
|
||||
doAnswer(
|
||||
invocation -> {
|
||||
@ -120,6 +128,9 @@ public class AllDatatypesTest {
|
||||
everything.getAMap().keySet().toArray(), result.getAMap().keySet().toArray());
|
||||
assertArrayEquals(
|
||||
everything.getAMap().values().toArray(), result.getAMap().values().toArray());
|
||||
assertArrayEquals(
|
||||
everything.getMapWithObject().values().toArray(),
|
||||
result.getMapWithObject().values().toArray());
|
||||
});
|
||||
assertTrue(didCall[0]);
|
||||
}
|
||||
|
@ -2,7 +2,7 @@
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
//
|
||||
// Autogenerated from Pigeon (v0.3.0), do not edit directly.
|
||||
// Autogenerated from Pigeon (v1.0.8), 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, unused_shown_name
|
||||
// @dart = 2.12
|
||||
@ -25,6 +25,7 @@ class Everything {
|
||||
Map<Object?, Object?>? aMap;
|
||||
List<List<bool?>?>? nestedList;
|
||||
Map<String?, String?>? mapWithAnnotations;
|
||||
Map<String?, Object?>? mapWithObject;
|
||||
|
||||
Object encode() {
|
||||
final Map<Object?, Object?> pigeonMap = <Object?, Object?>{};
|
||||
@ -40,6 +41,7 @@ class Everything {
|
||||
pigeonMap['aMap'] = aMap;
|
||||
pigeonMap['nestedList'] = nestedList;
|
||||
pigeonMap['mapWithAnnotations'] = mapWithAnnotations;
|
||||
pigeonMap['mapWithObject'] = mapWithObject;
|
||||
return pigeonMap;
|
||||
}
|
||||
|
||||
@ -60,7 +62,9 @@ class Everything {
|
||||
(pigeonMap['nestedList'] as List<Object?>?)?.cast<List<bool?>?>()
|
||||
..mapWithAnnotations =
|
||||
(pigeonMap['mapWithAnnotations'] as Map<Object?, Object?>?)
|
||||
?.cast<String?, String?>();
|
||||
?.cast<String?, String?>()
|
||||
..mapWithObject = (pigeonMap['mapWithObject'] as Map<Object?, Object?>?)
|
||||
?.cast<String?, Object?>();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -35,6 +35,7 @@ void main() {
|
||||
expect(result.aMap, isNull);
|
||||
expect(result.nestedList, isNull);
|
||||
expect(result.mapWithAnnotations, isNull);
|
||||
expect(result.mapWithObject, isNull);
|
||||
});
|
||||
|
||||
test('with values', () async {
|
||||
@ -54,6 +55,7 @@ void main() {
|
||||
<bool?>[true]
|
||||
];
|
||||
everything.mapWithAnnotations = <String?, String?>{'hello': 'world'};
|
||||
everything.mapWithObject = <String?, Object?>{'hello': 1234};
|
||||
final BinaryMessenger mockMessenger = MockBinaryMessenger();
|
||||
echoOneArgument(
|
||||
mockMessenger,
|
||||
@ -74,5 +76,6 @@ void main() {
|
||||
expect(result.aMap, everything.aMap);
|
||||
expect(result.aList, everything.aList);
|
||||
expect(result.mapWithAnnotations, everything.mapWithAnnotations);
|
||||
expect(result.mapWithObject, everything.mapWithObject);
|
||||
});
|
||||
}
|
||||
|
@ -1,6 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<Scheme
|
||||
LastUpgradeVersion = "1020"
|
||||
LastUpgradeVersion = "1300"
|
||||
version = "1.3">
|
||||
<BuildAction
|
||||
parallelizeBuildables = "YES"
|
||||
|
@ -53,6 +53,7 @@
|
||||
typedDataWithFloat64:[@"12345678" dataUsingEncoding:NSUTF8StringEncoding]];
|
||||
everything.aList = @[ @(1), @(2) ];
|
||||
everything.aMap = @{ @"hello" : @(1234) };
|
||||
everything.mapWithObject = @{ @"hello" : @(1234), @"goodbye" : @"world" };
|
||||
EchoBinaryMessenger* binaryMessenger =
|
||||
[[EchoBinaryMessenger alloc] initWithCodec:FlutterEverythingGetCodec()];
|
||||
FlutterEverything* api = [[FlutterEverything alloc] initWithBinaryMessenger:binaryMessenger];
|
||||
@ -69,6 +70,7 @@
|
||||
XCTAssertEqualObjects(result.aFloatArray.data, everything.aFloatArray.data);
|
||||
XCTAssertEqualObjects(result.aList, everything.aList);
|
||||
XCTAssertEqualObjects(result.aMap, everything.aMap);
|
||||
XCTAssertEqualObjects(result.mapWithObject, everything.mapWithObject);
|
||||
[expectation fulfill];
|
||||
}];
|
||||
[self waitForExpectations:@[ expectation ] timeout:1.0];
|
||||
|
@ -2,7 +2,7 @@ name: pigeon
|
||||
description: Code generator tool to make communication between Flutter and the host platform type-safe and easier.
|
||||
repository: https://github.com/flutter/packages/tree/master/packages/pigeon
|
||||
issue_tracker: https://github.com/flutter/flutter/issues?q=is%3Aissue+is%3Aopen+label%3Apigeon
|
||||
version: 1.0.7 # This must match the version in lib/generator_tools.dart
|
||||
version: 1.0.8 # This must match the version in lib/generator_tools.dart
|
||||
|
||||
environment:
|
||||
sdk: '>=2.12.0 <3.0.0'
|
||||
@ -10,6 +10,8 @@ environment:
|
||||
dependencies:
|
||||
analyzer: ^2.4.0
|
||||
args: ^2.0.0
|
||||
collection: ^1.15.0
|
||||
meta: ^1.7.0
|
||||
path: ^1.8.0
|
||||
|
||||
dev_dependencies:
|
||||
|
@ -234,8 +234,8 @@ run_mock_handler_tests() {
|
||||
--input pigeons/message.dart \
|
||||
--dart_out mock_handler_tester/test/message.dart \
|
||||
--dart_test_out mock_handler_tester/test/test.dart
|
||||
dartfmt -w mock_handler_tester/test/message.dart
|
||||
dartfmt -w mock_handler_tester/test/test.dart
|
||||
dart format mock_handler_tester/test/message.dart
|
||||
dart format mock_handler_tester/test/test.dart
|
||||
cd mock_handler_tester
|
||||
flutter test
|
||||
popd
|
||||
@ -299,7 +299,7 @@ run_ios_e2e_tests() {
|
||||
--objc_header_out $DARTLE_H \
|
||||
--objc_source_out $DARTLE_M \
|
||||
--java_out $PIGEON_JAVA
|
||||
dartfmt -w $DARTLE_DART
|
||||
dart format $DARTLE_DART
|
||||
|
||||
pushd $PWD
|
||||
cd e2e_tests/test_objc
|
||||
|
@ -13,7 +13,7 @@ void main() {
|
||||
name: 'Foobar',
|
||||
fields: <NamedType>[
|
||||
NamedType(
|
||||
type: TypeDeclaration(
|
||||
type: const TypeDeclaration(
|
||||
baseName: 'dataType1',
|
||||
isNullable: true,
|
||||
),
|
||||
@ -61,21 +61,22 @@ void main() {
|
||||
name: 'doSomething',
|
||||
arguments: <NamedType>[
|
||||
NamedType(
|
||||
type: TypeDeclaration(
|
||||
type: const TypeDeclaration(
|
||||
baseName: 'Input',
|
||||
isNullable: false,
|
||||
),
|
||||
name: 'input',
|
||||
offset: null)
|
||||
],
|
||||
returnType: TypeDeclaration(baseName: 'Output', isNullable: false),
|
||||
returnType:
|
||||
const TypeDeclaration(baseName: 'Output', isNullable: false),
|
||||
isAsynchronous: false,
|
||||
)
|
||||
])
|
||||
], classes: <Class>[
|
||||
Class(name: 'Input', fields: <NamedType>[
|
||||
NamedType(
|
||||
type: TypeDeclaration(
|
||||
type: const TypeDeclaration(
|
||||
baseName: 'String',
|
||||
isNullable: true,
|
||||
),
|
||||
@ -84,7 +85,7 @@ void main() {
|
||||
]),
|
||||
Class(name: 'Output', fields: <NamedType>[
|
||||
NamedType(
|
||||
type: TypeDeclaration(
|
||||
type: const TypeDeclaration(
|
||||
baseName: 'String',
|
||||
isNullable: true,
|
||||
),
|
||||
@ -107,12 +108,14 @@ void main() {
|
||||
arguments: <NamedType>[
|
||||
NamedType(
|
||||
name: 'x',
|
||||
type: TypeDeclaration(isNullable: false, baseName: 'int')),
|
||||
type:
|
||||
const TypeDeclaration(isNullable: false, baseName: 'int')),
|
||||
NamedType(
|
||||
name: 'y',
|
||||
type: TypeDeclaration(isNullable: false, baseName: 'int')),
|
||||
type:
|
||||
const TypeDeclaration(isNullable: false, baseName: 'int')),
|
||||
],
|
||||
returnType: TypeDeclaration(baseName: 'int', isNullable: false),
|
||||
returnType: const TypeDeclaration(baseName: 'int', isNullable: false),
|
||||
isAsynchronous: false,
|
||||
)
|
||||
])
|
||||
@ -133,12 +136,14 @@ void main() {
|
||||
arguments: <NamedType>[
|
||||
NamedType(
|
||||
name: 'x',
|
||||
type: TypeDeclaration(isNullable: false, baseName: 'int')),
|
||||
type:
|
||||
const TypeDeclaration(isNullable: false, baseName: 'int')),
|
||||
NamedType(
|
||||
name: 'y',
|
||||
type: TypeDeclaration(isNullable: false, baseName: 'int')),
|
||||
type:
|
||||
const TypeDeclaration(isNullable: false, baseName: 'int')),
|
||||
],
|
||||
returnType: TypeDeclaration(baseName: 'int', isNullable: false),
|
||||
returnType: const TypeDeclaration(baseName: 'int', isNullable: false),
|
||||
isAsynchronous: false,
|
||||
)
|
||||
])
|
||||
@ -161,7 +166,7 @@ void main() {
|
||||
name: 'Input',
|
||||
fields: <NamedType>[
|
||||
NamedType(
|
||||
type: TypeDeclaration(
|
||||
type: const TypeDeclaration(
|
||||
baseName: 'String',
|
||||
isNullable: true,
|
||||
),
|
||||
@ -173,7 +178,7 @@ void main() {
|
||||
name: 'Nested',
|
||||
fields: <NamedType>[
|
||||
NamedType(
|
||||
type: TypeDeclaration(
|
||||
type: const TypeDeclaration(
|
||||
baseName: 'Input',
|
||||
isNullable: true,
|
||||
),
|
||||
@ -206,21 +211,22 @@ void main() {
|
||||
name: 'doSomething',
|
||||
arguments: <NamedType>[
|
||||
NamedType(
|
||||
type: TypeDeclaration(
|
||||
type: const TypeDeclaration(
|
||||
baseName: 'Input',
|
||||
isNullable: false,
|
||||
),
|
||||
name: 'input',
|
||||
offset: null)
|
||||
],
|
||||
returnType: TypeDeclaration(baseName: 'Output', isNullable: false),
|
||||
returnType:
|
||||
const TypeDeclaration(baseName: 'Output', isNullable: false),
|
||||
isAsynchronous: false,
|
||||
)
|
||||
])
|
||||
], classes: <Class>[
|
||||
Class(name: 'Input', fields: <NamedType>[
|
||||
NamedType(
|
||||
type: TypeDeclaration(
|
||||
type: const TypeDeclaration(
|
||||
baseName: 'String',
|
||||
isNullable: true,
|
||||
),
|
||||
@ -229,7 +235,7 @@ void main() {
|
||||
]),
|
||||
Class(name: 'Output', fields: <NamedType>[
|
||||
NamedType(
|
||||
type: TypeDeclaration(
|
||||
type: const TypeDeclaration(
|
||||
baseName: 'String',
|
||||
isNullable: true,
|
||||
),
|
||||
@ -252,21 +258,21 @@ void main() {
|
||||
name: 'doSomething',
|
||||
arguments: <NamedType>[
|
||||
NamedType(
|
||||
type: TypeDeclaration(
|
||||
type: const TypeDeclaration(
|
||||
baseName: 'Input',
|
||||
isNullable: false,
|
||||
),
|
||||
name: '',
|
||||
offset: null)
|
||||
],
|
||||
returnType: TypeDeclaration.voidDeclaration(),
|
||||
returnType: const TypeDeclaration.voidDeclaration(),
|
||||
isAsynchronous: false,
|
||||
)
|
||||
])
|
||||
], classes: <Class>[
|
||||
Class(name: 'Input', fields: <NamedType>[
|
||||
NamedType(
|
||||
type: TypeDeclaration(
|
||||
type: const TypeDeclaration(
|
||||
baseName: 'String',
|
||||
isNullable: true,
|
||||
),
|
||||
@ -288,21 +294,21 @@ void main() {
|
||||
name: 'doSomething',
|
||||
arguments: <NamedType>[
|
||||
NamedType(
|
||||
type: TypeDeclaration(
|
||||
type: const TypeDeclaration(
|
||||
baseName: 'Input',
|
||||
isNullable: false,
|
||||
),
|
||||
name: '',
|
||||
offset: null)
|
||||
],
|
||||
returnType: TypeDeclaration.voidDeclaration(),
|
||||
returnType: const TypeDeclaration.voidDeclaration(),
|
||||
isAsynchronous: false,
|
||||
)
|
||||
])
|
||||
], classes: <Class>[
|
||||
Class(name: 'Input', fields: <NamedType>[
|
||||
NamedType(
|
||||
type: TypeDeclaration(
|
||||
type: const TypeDeclaration(
|
||||
baseName: 'String',
|
||||
isNullable: true,
|
||||
),
|
||||
@ -326,14 +332,15 @@ void main() {
|
||||
Method(
|
||||
name: 'doSomething',
|
||||
arguments: <NamedType>[],
|
||||
returnType: TypeDeclaration(baseName: 'Output', isNullable: false),
|
||||
returnType:
|
||||
const TypeDeclaration(baseName: 'Output', isNullable: false),
|
||||
isAsynchronous: false,
|
||||
)
|
||||
])
|
||||
], classes: <Class>[
|
||||
Class(name: 'Output', fields: <NamedType>[
|
||||
NamedType(
|
||||
type: TypeDeclaration(
|
||||
type: const TypeDeclaration(
|
||||
baseName: 'String',
|
||||
isNullable: true,
|
||||
),
|
||||
@ -355,21 +362,22 @@ void main() {
|
||||
name: 'doSomething',
|
||||
arguments: <NamedType>[
|
||||
NamedType(
|
||||
type: TypeDeclaration(
|
||||
type: const TypeDeclaration(
|
||||
baseName: 'EnumClass',
|
||||
isNullable: false,
|
||||
),
|
||||
name: '',
|
||||
offset: null)
|
||||
],
|
||||
returnType: TypeDeclaration(baseName: 'EnumClass', isNullable: false),
|
||||
returnType:
|
||||
const TypeDeclaration(baseName: 'EnumClass', isNullable: false),
|
||||
isAsynchronous: false,
|
||||
)
|
||||
])
|
||||
], classes: <Class>[
|
||||
Class(name: 'EnumClass', fields: <NamedType>[
|
||||
NamedType(
|
||||
type: TypeDeclaration(
|
||||
type: const TypeDeclaration(
|
||||
baseName: 'Enum',
|
||||
isNullable: true,
|
||||
),
|
||||
@ -401,21 +409,22 @@ void main() {
|
||||
name: 'doSomething',
|
||||
arguments: <NamedType>[
|
||||
NamedType(
|
||||
type: TypeDeclaration(
|
||||
type: const TypeDeclaration(
|
||||
baseName: 'EnumClass',
|
||||
isNullable: false,
|
||||
),
|
||||
name: '',
|
||||
offset: null)
|
||||
],
|
||||
returnType: TypeDeclaration(baseName: 'EnumClass', isNullable: false),
|
||||
returnType:
|
||||
const TypeDeclaration(baseName: 'EnumClass', isNullable: false),
|
||||
isAsynchronous: false,
|
||||
)
|
||||
])
|
||||
], classes: <Class>[
|
||||
Class(name: 'EnumClass', fields: <NamedType>[
|
||||
NamedType(
|
||||
type: TypeDeclaration(
|
||||
type: const TypeDeclaration(
|
||||
baseName: 'Enum',
|
||||
isNullable: true,
|
||||
),
|
||||
@ -448,14 +457,15 @@ void main() {
|
||||
Method(
|
||||
name: 'doSomething',
|
||||
arguments: <NamedType>[],
|
||||
returnType: TypeDeclaration(baseName: 'Output', isNullable: false),
|
||||
returnType:
|
||||
const TypeDeclaration(baseName: 'Output', isNullable: false),
|
||||
isAsynchronous: false,
|
||||
)
|
||||
])
|
||||
], classes: <Class>[
|
||||
Class(name: 'Output', fields: <NamedType>[
|
||||
NamedType(
|
||||
type: TypeDeclaration(
|
||||
type: const TypeDeclaration(
|
||||
baseName: 'String',
|
||||
isNullable: true,
|
||||
),
|
||||
@ -480,7 +490,7 @@ void main() {
|
||||
name: 'doSomething',
|
||||
arguments: <NamedType>[
|
||||
NamedType(
|
||||
type: TypeDeclaration(
|
||||
type: const TypeDeclaration(
|
||||
baseName: 'Input',
|
||||
isNullable: false,
|
||||
),
|
||||
@ -488,28 +498,28 @@ void main() {
|
||||
offset: null)
|
||||
],
|
||||
returnType:
|
||||
TypeDeclaration(baseName: 'Output', isNullable: false),
|
||||
const TypeDeclaration(baseName: 'Output', isNullable: false),
|
||||
isAsynchronous: false,
|
||||
),
|
||||
Method(
|
||||
name: 'voidReturner',
|
||||
arguments: <NamedType>[
|
||||
NamedType(
|
||||
type: TypeDeclaration(
|
||||
type: const TypeDeclaration(
|
||||
baseName: 'Input',
|
||||
isNullable: false,
|
||||
),
|
||||
name: '',
|
||||
offset: null)
|
||||
],
|
||||
returnType: TypeDeclaration.voidDeclaration(),
|
||||
returnType: const TypeDeclaration.voidDeclaration(),
|
||||
isAsynchronous: false,
|
||||
)
|
||||
])
|
||||
], classes: <Class>[
|
||||
Class(name: 'Input', fields: <NamedType>[
|
||||
NamedType(
|
||||
type: TypeDeclaration(
|
||||
type: const TypeDeclaration(
|
||||
baseName: 'String',
|
||||
isNullable: true,
|
||||
),
|
||||
@ -518,7 +528,7 @@ void main() {
|
||||
]),
|
||||
Class(name: 'Output', fields: <NamedType>[
|
||||
NamedType(
|
||||
type: TypeDeclaration(
|
||||
type: const TypeDeclaration(
|
||||
baseName: 'String',
|
||||
isNullable: true,
|
||||
),
|
||||
@ -552,7 +562,7 @@ void main() {
|
||||
name: 'Foobar',
|
||||
fields: <NamedType>[
|
||||
NamedType(
|
||||
type: TypeDeclaration(
|
||||
type: const TypeDeclaration(
|
||||
baseName: 'dataType1',
|
||||
isNullable: true,
|
||||
),
|
||||
@ -578,21 +588,22 @@ void main() {
|
||||
name: 'doSomething',
|
||||
arguments: <NamedType>[
|
||||
NamedType(
|
||||
type: TypeDeclaration(
|
||||
type: const TypeDeclaration(
|
||||
baseName: 'Input',
|
||||
isNullable: false,
|
||||
),
|
||||
name: '',
|
||||
offset: null)
|
||||
],
|
||||
returnType: TypeDeclaration(baseName: 'Output', isNullable: false),
|
||||
returnType:
|
||||
const TypeDeclaration(baseName: 'Output', isNullable: false),
|
||||
isAsynchronous: true,
|
||||
)
|
||||
])
|
||||
], classes: <Class>[
|
||||
Class(name: 'Input', fields: <NamedType>[
|
||||
NamedType(
|
||||
type: TypeDeclaration(
|
||||
type: const TypeDeclaration(
|
||||
baseName: 'String',
|
||||
isNullable: true,
|
||||
),
|
||||
@ -601,7 +612,7 @@ void main() {
|
||||
]),
|
||||
Class(name: 'Output', fields: <NamedType>[
|
||||
NamedType(
|
||||
type: TypeDeclaration(
|
||||
type: const TypeDeclaration(
|
||||
baseName: 'String',
|
||||
isNullable: true,
|
||||
),
|
||||
@ -625,21 +636,21 @@ void main() {
|
||||
name: 'doSomething',
|
||||
arguments: <NamedType>[
|
||||
NamedType(
|
||||
type: TypeDeclaration(
|
||||
type: const TypeDeclaration(
|
||||
baseName: 'Input',
|
||||
isNullable: false,
|
||||
),
|
||||
name: '',
|
||||
offset: null)
|
||||
],
|
||||
returnType: TypeDeclaration.voidDeclaration(),
|
||||
returnType: const TypeDeclaration.voidDeclaration(),
|
||||
isAsynchronous: true,
|
||||
)
|
||||
])
|
||||
], classes: <Class>[
|
||||
Class(name: 'Input', fields: <NamedType>[
|
||||
NamedType(
|
||||
type: TypeDeclaration(
|
||||
type: const TypeDeclaration(
|
||||
baseName: 'String',
|
||||
isNullable: true,
|
||||
),
|
||||
@ -648,7 +659,7 @@ void main() {
|
||||
]),
|
||||
Class(name: 'Output', fields: <NamedType>[
|
||||
NamedType(
|
||||
type: TypeDeclaration(
|
||||
type: const TypeDeclaration(
|
||||
baseName: 'String',
|
||||
isNullable: true,
|
||||
),
|
||||
@ -671,21 +682,22 @@ void main() {
|
||||
name: 'doSomething',
|
||||
arguments: <NamedType>[
|
||||
NamedType(
|
||||
type: TypeDeclaration(
|
||||
type: const TypeDeclaration(
|
||||
baseName: 'Input',
|
||||
isNullable: false,
|
||||
),
|
||||
name: '',
|
||||
offset: null)
|
||||
],
|
||||
returnType: TypeDeclaration(baseName: 'Output', isNullable: false),
|
||||
returnType:
|
||||
const TypeDeclaration(baseName: 'Output', isNullable: false),
|
||||
isAsynchronous: true,
|
||||
)
|
||||
])
|
||||
], classes: <Class>[
|
||||
Class(name: 'Input', fields: <NamedType>[
|
||||
NamedType(
|
||||
type: TypeDeclaration(
|
||||
type: const TypeDeclaration(
|
||||
baseName: 'String',
|
||||
isNullable: true,
|
||||
),
|
||||
@ -694,7 +706,7 @@ void main() {
|
||||
]),
|
||||
Class(name: 'Output', fields: <NamedType>[
|
||||
NamedType(
|
||||
type: TypeDeclaration(
|
||||
type: const TypeDeclaration(
|
||||
baseName: 'String',
|
||||
isNullable: true,
|
||||
),
|
||||
@ -715,14 +727,15 @@ void main() {
|
||||
Method(
|
||||
name: 'doSomething',
|
||||
arguments: <NamedType>[],
|
||||
returnType: TypeDeclaration(baseName: 'Output', isNullable: false),
|
||||
returnType:
|
||||
const TypeDeclaration(baseName: 'Output', isNullable: false),
|
||||
isAsynchronous: true,
|
||||
)
|
||||
])
|
||||
], classes: <Class>[
|
||||
Class(name: 'Output', fields: <NamedType>[
|
||||
NamedType(
|
||||
type: TypeDeclaration(
|
||||
type: const TypeDeclaration(
|
||||
baseName: 'String',
|
||||
isNullable: true,
|
||||
),
|
||||
@ -758,7 +771,7 @@ void main() {
|
||||
name: 'Foobar',
|
||||
fields: <NamedType>[
|
||||
NamedType(
|
||||
type: TypeDeclaration(
|
||||
type: const TypeDeclaration(
|
||||
baseName: 'List',
|
||||
isNullable: true,
|
||||
typeArguments: <TypeDeclaration>[
|
||||
@ -785,7 +798,7 @@ void main() {
|
||||
name: 'Foobar',
|
||||
fields: <NamedType>[
|
||||
NamedType(
|
||||
type: TypeDeclaration(
|
||||
type: const TypeDeclaration(
|
||||
baseName: 'Map',
|
||||
isNullable: true,
|
||||
typeArguments: <TypeDeclaration>[
|
||||
@ -814,10 +827,10 @@ void main() {
|
||||
Api(name: 'Api', location: ApiLocation.host, methods: <Method>[
|
||||
Method(
|
||||
name: 'doit',
|
||||
returnType: TypeDeclaration.voidDeclaration(),
|
||||
returnType: const TypeDeclaration.voidDeclaration(),
|
||||
arguments: <NamedType>[
|
||||
NamedType(
|
||||
type: TypeDeclaration(
|
||||
type: const TypeDeclaration(
|
||||
baseName: 'List',
|
||||
isNullable: false,
|
||||
typeArguments: <TypeDeclaration>[
|
||||
@ -843,10 +856,10 @@ void main() {
|
||||
Api(name: 'Api', location: ApiLocation.flutter, methods: <Method>[
|
||||
Method(
|
||||
name: 'doit',
|
||||
returnType: TypeDeclaration.voidDeclaration(),
|
||||
returnType: const TypeDeclaration.voidDeclaration(),
|
||||
arguments: <NamedType>[
|
||||
NamedType(
|
||||
type: TypeDeclaration(
|
||||
type: const TypeDeclaration(
|
||||
baseName: 'List',
|
||||
isNullable: false,
|
||||
typeArguments: <TypeDeclaration>[
|
||||
@ -872,7 +885,7 @@ void main() {
|
||||
Api(name: 'Api', location: ApiLocation.host, methods: <Method>[
|
||||
Method(
|
||||
name: 'doit',
|
||||
returnType: TypeDeclaration(
|
||||
returnType: const TypeDeclaration(
|
||||
baseName: 'List',
|
||||
isNullable: false,
|
||||
typeArguments: <TypeDeclaration>[
|
||||
@ -900,7 +913,7 @@ void main() {
|
||||
Api(name: 'Api', location: ApiLocation.flutter, methods: <Method>[
|
||||
Method(
|
||||
name: 'doit',
|
||||
returnType: TypeDeclaration(
|
||||
returnType: const TypeDeclaration(
|
||||
baseName: 'List',
|
||||
isNullable: false,
|
||||
typeArguments: <TypeDeclaration>[
|
||||
@ -908,7 +921,7 @@ void main() {
|
||||
]),
|
||||
arguments: <NamedType>[
|
||||
NamedType(
|
||||
type: TypeDeclaration(
|
||||
type: const TypeDeclaration(
|
||||
baseName: 'List',
|
||||
isNullable: false,
|
||||
typeArguments: <TypeDeclaration>[
|
||||
|
@ -72,7 +72,7 @@ void main() {
|
||||
name: 'doSomething',
|
||||
arguments: <NamedType>[
|
||||
NamedType(
|
||||
type: TypeDeclaration(
|
||||
type: const TypeDeclaration(
|
||||
baseName: 'List',
|
||||
isNullable: false,
|
||||
typeArguments: <TypeDeclaration>[
|
||||
@ -83,7 +83,8 @@ void main() {
|
||||
offset: null,
|
||||
)
|
||||
],
|
||||
returnType: TypeDeclaration(baseName: 'Output', isNullable: false),
|
||||
returnType:
|
||||
const TypeDeclaration(baseName: 'Output', isNullable: false),
|
||||
isAsynchronous: true,
|
||||
)
|
||||
]);
|
||||
@ -110,12 +111,12 @@ void main() {
|
||||
name: 'doSomething',
|
||||
arguments: <NamedType>[
|
||||
NamedType(
|
||||
type: TypeDeclaration(baseName: 'Output', isNullable: false),
|
||||
type: const TypeDeclaration(baseName: 'Output', isNullable: false),
|
||||
name: '',
|
||||
offset: null,
|
||||
)
|
||||
],
|
||||
returnType: TypeDeclaration(
|
||||
returnType: const TypeDeclaration(
|
||||
baseName: 'List',
|
||||
isNullable: false,
|
||||
typeArguments: <TypeDeclaration>[
|
||||
@ -148,17 +149,17 @@ void main() {
|
||||
name: 'doSomething',
|
||||
arguments: <NamedType>[
|
||||
NamedType(
|
||||
type: TypeDeclaration(baseName: 'Foo', isNullable: false),
|
||||
type: const TypeDeclaration(baseName: 'Foo', isNullable: false),
|
||||
name: '',
|
||||
offset: null,
|
||||
),
|
||||
NamedType(
|
||||
type: TypeDeclaration(baseName: 'Bar', isNullable: false),
|
||||
type: const TypeDeclaration(baseName: 'Bar', isNullable: false),
|
||||
name: '',
|
||||
offset: null,
|
||||
),
|
||||
],
|
||||
returnType: TypeDeclaration(
|
||||
returnType: const TypeDeclaration(
|
||||
baseName: 'List',
|
||||
isNullable: false,
|
||||
typeArguments: <TypeDeclaration>[TypeDeclaration.voidDeclaration()],
|
||||
@ -190,14 +191,14 @@ void main() {
|
||||
arguments: <NamedType>[
|
||||
NamedType(
|
||||
name: 'x',
|
||||
type: TypeDeclaration(
|
||||
type: const TypeDeclaration(
|
||||
isNullable: false,
|
||||
baseName: 'List',
|
||||
typeArguments: <TypeDeclaration>[
|
||||
TypeDeclaration(baseName: 'Foo', isNullable: true)
|
||||
])),
|
||||
],
|
||||
returnType: TypeDeclaration.voidDeclaration(),
|
||||
returnType: const TypeDeclaration.voidDeclaration(),
|
||||
isAsynchronous: false,
|
||||
)
|
||||
])
|
||||
@ -205,12 +206,12 @@ void main() {
|
||||
Class(name: 'Foo', fields: <NamedType>[
|
||||
NamedType(
|
||||
name: 'bar',
|
||||
type: TypeDeclaration(baseName: 'Bar', isNullable: true)),
|
||||
type: const TypeDeclaration(baseName: 'Bar', isNullable: true)),
|
||||
]),
|
||||
Class(name: 'Bar', fields: <NamedType>[
|
||||
NamedType(
|
||||
name: 'value',
|
||||
type: TypeDeclaration(baseName: 'int', isNullable: true))
|
||||
type: const TypeDeclaration(baseName: 'int', isNullable: true))
|
||||
])
|
||||
], enums: <Enum>[]);
|
||||
final List<EnumeratedClass> classes =
|
||||
@ -227,4 +228,57 @@ void main() {
|
||||
.length,
|
||||
1);
|
||||
});
|
||||
|
||||
test('getCodecClasses: unique entries', () {
|
||||
final Root root = Root(apis: <Api>[
|
||||
Api(
|
||||
name: 'Api1',
|
||||
location: ApiLocation.flutter,
|
||||
methods: <Method>[
|
||||
Method(
|
||||
name: 'foo',
|
||||
arguments: <NamedType>[
|
||||
NamedType(
|
||||
name: 'x',
|
||||
type: const TypeDeclaration(
|
||||
isNullable: false, baseName: 'Foo')),
|
||||
],
|
||||
returnType: const TypeDeclaration.voidDeclaration(),
|
||||
isAsynchronous: false,
|
||||
)
|
||||
],
|
||||
),
|
||||
Api(
|
||||
name: 'Api2',
|
||||
location: ApiLocation.host,
|
||||
methods: <Method>[
|
||||
Method(
|
||||
name: 'foo',
|
||||
arguments: <NamedType>[
|
||||
NamedType(
|
||||
name: 'x',
|
||||
type: const TypeDeclaration(
|
||||
isNullable: false, baseName: 'Foo')),
|
||||
],
|
||||
returnType: const TypeDeclaration.voidDeclaration(),
|
||||
isAsynchronous: false,
|
||||
)
|
||||
],
|
||||
)
|
||||
], classes: <Class>[
|
||||
Class(name: 'Foo', fields: <NamedType>[
|
||||
NamedType(
|
||||
name: 'bar',
|
||||
type: const TypeDeclaration(baseName: 'int', isNullable: true)),
|
||||
]),
|
||||
], enums: <Enum>[]);
|
||||
final List<EnumeratedClass> classes =
|
||||
getCodecClasses(root.apis[0], root).toList();
|
||||
expect(classes.length, 1);
|
||||
expect(
|
||||
classes
|
||||
.where((EnumeratedClass element) => element.name == 'Foo')
|
||||
.length,
|
||||
1);
|
||||
});
|
||||
}
|
||||
|
@ -12,7 +12,7 @@ void main() {
|
||||
name: 'Foobar',
|
||||
fields: <NamedType>[
|
||||
NamedType(
|
||||
type: TypeDeclaration(
|
||||
type: const TypeDeclaration(
|
||||
baseName: 'int',
|
||||
isNullable: true,
|
||||
),
|
||||
@ -64,7 +64,7 @@ void main() {
|
||||
name: 'Foobar',
|
||||
fields: <NamedType>[
|
||||
NamedType(
|
||||
type: TypeDeclaration(
|
||||
type: const TypeDeclaration(
|
||||
baseName: 'int',
|
||||
isNullable: true,
|
||||
),
|
||||
@ -93,21 +93,22 @@ void main() {
|
||||
name: 'doSomething',
|
||||
arguments: <NamedType>[
|
||||
NamedType(
|
||||
type: TypeDeclaration(
|
||||
type: const TypeDeclaration(
|
||||
baseName: 'Input',
|
||||
isNullable: false,
|
||||
),
|
||||
name: '',
|
||||
offset: null)
|
||||
],
|
||||
returnType: TypeDeclaration(baseName: 'Output', isNullable: false),
|
||||
returnType:
|
||||
const TypeDeclaration(baseName: 'Output', isNullable: false),
|
||||
isAsynchronous: false,
|
||||
)
|
||||
])
|
||||
], classes: <Class>[
|
||||
Class(name: 'Input', fields: <NamedType>[
|
||||
NamedType(
|
||||
type: TypeDeclaration(
|
||||
type: const TypeDeclaration(
|
||||
baseName: 'String',
|
||||
isNullable: true,
|
||||
),
|
||||
@ -116,7 +117,7 @@ void main() {
|
||||
]),
|
||||
Class(name: 'Output', fields: <NamedType>[
|
||||
NamedType(
|
||||
type: TypeDeclaration(
|
||||
type: const TypeDeclaration(
|
||||
baseName: 'String',
|
||||
isNullable: true,
|
||||
),
|
||||
@ -137,56 +138,56 @@ void main() {
|
||||
final Root root = Root(apis: <Api>[], classes: <Class>[
|
||||
Class(name: 'Foobar', fields: <NamedType>[
|
||||
NamedType(
|
||||
type: TypeDeclaration(
|
||||
type: const TypeDeclaration(
|
||||
baseName: 'bool',
|
||||
isNullable: true,
|
||||
),
|
||||
name: 'aBool',
|
||||
offset: null),
|
||||
NamedType(
|
||||
type: TypeDeclaration(
|
||||
type: const TypeDeclaration(
|
||||
baseName: 'int',
|
||||
isNullable: true,
|
||||
),
|
||||
name: 'aInt',
|
||||
offset: null),
|
||||
NamedType(
|
||||
type: TypeDeclaration(
|
||||
type: const TypeDeclaration(
|
||||
baseName: 'double',
|
||||
isNullable: true,
|
||||
),
|
||||
name: 'aDouble',
|
||||
offset: null),
|
||||
NamedType(
|
||||
type: TypeDeclaration(
|
||||
type: const TypeDeclaration(
|
||||
baseName: 'String',
|
||||
isNullable: true,
|
||||
),
|
||||
name: 'aString',
|
||||
offset: null),
|
||||
NamedType(
|
||||
type: TypeDeclaration(
|
||||
type: const TypeDeclaration(
|
||||
baseName: 'Uint8List',
|
||||
isNullable: true,
|
||||
),
|
||||
name: 'aUint8List',
|
||||
offset: null),
|
||||
NamedType(
|
||||
type: TypeDeclaration(
|
||||
type: const TypeDeclaration(
|
||||
baseName: 'Int32List',
|
||||
isNullable: true,
|
||||
),
|
||||
name: 'aInt32List',
|
||||
offset: null),
|
||||
NamedType(
|
||||
type: TypeDeclaration(
|
||||
type: const TypeDeclaration(
|
||||
baseName: 'Int64List',
|
||||
isNullable: true,
|
||||
),
|
||||
name: 'aInt64List',
|
||||
offset: null),
|
||||
NamedType(
|
||||
type: TypeDeclaration(
|
||||
type: const TypeDeclaration(
|
||||
baseName: 'Float64List',
|
||||
isNullable: true,
|
||||
),
|
||||
@ -216,21 +217,22 @@ void main() {
|
||||
name: 'doSomething',
|
||||
arguments: <NamedType>[
|
||||
NamedType(
|
||||
type: TypeDeclaration(
|
||||
type: const TypeDeclaration(
|
||||
baseName: 'Input',
|
||||
isNullable: false,
|
||||
),
|
||||
name: '',
|
||||
offset: null)
|
||||
],
|
||||
returnType: TypeDeclaration(baseName: 'Output', isNullable: false),
|
||||
returnType:
|
||||
const TypeDeclaration(baseName: 'Output', isNullable: false),
|
||||
isAsynchronous: false,
|
||||
)
|
||||
])
|
||||
], classes: <Class>[
|
||||
Class(name: 'Input', fields: <NamedType>[
|
||||
NamedType(
|
||||
type: TypeDeclaration(
|
||||
type: const TypeDeclaration(
|
||||
baseName: 'String',
|
||||
isNullable: true,
|
||||
),
|
||||
@ -239,7 +241,7 @@ void main() {
|
||||
]),
|
||||
Class(name: 'Output', fields: <NamedType>[
|
||||
NamedType(
|
||||
type: TypeDeclaration(
|
||||
type: const TypeDeclaration(
|
||||
baseName: 'String',
|
||||
isNullable: true,
|
||||
),
|
||||
@ -262,21 +264,21 @@ void main() {
|
||||
name: 'doSomething',
|
||||
arguments: <NamedType>[
|
||||
NamedType(
|
||||
type: TypeDeclaration(
|
||||
type: const TypeDeclaration(
|
||||
baseName: 'Input',
|
||||
isNullable: false,
|
||||
),
|
||||
name: '',
|
||||
offset: null)
|
||||
],
|
||||
returnType: TypeDeclaration.voidDeclaration(),
|
||||
returnType: const TypeDeclaration.voidDeclaration(),
|
||||
isAsynchronous: false,
|
||||
)
|
||||
])
|
||||
], classes: <Class>[
|
||||
Class(name: 'Input', fields: <NamedType>[
|
||||
NamedType(
|
||||
type: TypeDeclaration(
|
||||
type: const TypeDeclaration(
|
||||
baseName: 'String',
|
||||
isNullable: true,
|
||||
),
|
||||
@ -299,21 +301,21 @@ void main() {
|
||||
name: 'doSomething',
|
||||
arguments: <NamedType>[
|
||||
NamedType(
|
||||
type: TypeDeclaration(
|
||||
type: const TypeDeclaration(
|
||||
baseName: 'Input',
|
||||
isNullable: false,
|
||||
),
|
||||
name: '',
|
||||
offset: null)
|
||||
],
|
||||
returnType: TypeDeclaration.voidDeclaration(),
|
||||
returnType: const TypeDeclaration.voidDeclaration(),
|
||||
isAsynchronous: false,
|
||||
)
|
||||
])
|
||||
], classes: <Class>[
|
||||
Class(name: 'Input', fields: <NamedType>[
|
||||
NamedType(
|
||||
type: TypeDeclaration(
|
||||
type: const TypeDeclaration(
|
||||
baseName: 'String',
|
||||
isNullable: true,
|
||||
),
|
||||
@ -335,14 +337,15 @@ void main() {
|
||||
Method(
|
||||
name: 'doSomething',
|
||||
arguments: <NamedType>[],
|
||||
returnType: TypeDeclaration(baseName: 'Output', isNullable: false),
|
||||
returnType:
|
||||
const TypeDeclaration(baseName: 'Output', isNullable: false),
|
||||
isAsynchronous: false,
|
||||
)
|
||||
])
|
||||
], classes: <Class>[
|
||||
Class(name: 'Output', fields: <NamedType>[
|
||||
NamedType(
|
||||
type: TypeDeclaration(
|
||||
type: const TypeDeclaration(
|
||||
baseName: 'String',
|
||||
isNullable: true,
|
||||
),
|
||||
@ -364,14 +367,15 @@ void main() {
|
||||
Method(
|
||||
name: 'doSomething',
|
||||
arguments: <NamedType>[],
|
||||
returnType: TypeDeclaration(baseName: 'Output', isNullable: false),
|
||||
returnType:
|
||||
const TypeDeclaration(baseName: 'Output', isNullable: false),
|
||||
isAsynchronous: false,
|
||||
)
|
||||
])
|
||||
], classes: <Class>[
|
||||
Class(name: 'Output', fields: <NamedType>[
|
||||
NamedType(
|
||||
type: TypeDeclaration(
|
||||
type: const TypeDeclaration(
|
||||
baseName: 'String',
|
||||
isNullable: true,
|
||||
),
|
||||
@ -391,7 +395,7 @@ void main() {
|
||||
final Root root = Root(apis: <Api>[], classes: <Class>[
|
||||
Class(name: 'Foobar', fields: <NamedType>[
|
||||
NamedType(
|
||||
type: TypeDeclaration(
|
||||
type: const TypeDeclaration(
|
||||
baseName: 'List',
|
||||
isNullable: true,
|
||||
),
|
||||
@ -411,7 +415,7 @@ void main() {
|
||||
final Root root = Root(apis: <Api>[], classes: <Class>[
|
||||
Class(name: 'Foobar', fields: <NamedType>[
|
||||
NamedType(
|
||||
type: TypeDeclaration(
|
||||
type: const TypeDeclaration(
|
||||
baseName: 'Map',
|
||||
isNullable: true,
|
||||
),
|
||||
@ -432,7 +436,7 @@ void main() {
|
||||
name: 'Outer',
|
||||
fields: <NamedType>[
|
||||
NamedType(
|
||||
type: TypeDeclaration(
|
||||
type: const TypeDeclaration(
|
||||
baseName: 'Nested',
|
||||
isNullable: true,
|
||||
),
|
||||
@ -444,7 +448,7 @@ void main() {
|
||||
name: 'Nested',
|
||||
fields: <NamedType>[
|
||||
NamedType(
|
||||
type: TypeDeclaration(
|
||||
type: const TypeDeclaration(
|
||||
baseName: 'int',
|
||||
isNullable: true,
|
||||
),
|
||||
@ -477,21 +481,22 @@ void main() {
|
||||
name: 'doSomething',
|
||||
arguments: <NamedType>[
|
||||
NamedType(
|
||||
type: TypeDeclaration(
|
||||
type: const TypeDeclaration(
|
||||
baseName: 'Input',
|
||||
isNullable: false,
|
||||
),
|
||||
name: 'arg',
|
||||
offset: null)
|
||||
],
|
||||
returnType: TypeDeclaration(baseName: 'Output', isNullable: false),
|
||||
returnType:
|
||||
const TypeDeclaration(baseName: 'Output', isNullable: false),
|
||||
isAsynchronous: true,
|
||||
)
|
||||
])
|
||||
], classes: <Class>[
|
||||
Class(name: 'Input', fields: <NamedType>[
|
||||
NamedType(
|
||||
type: TypeDeclaration(
|
||||
type: const TypeDeclaration(
|
||||
baseName: 'String',
|
||||
isNullable: true,
|
||||
),
|
||||
@ -500,7 +505,7 @@ void main() {
|
||||
]),
|
||||
Class(name: 'Output', fields: <NamedType>[
|
||||
NamedType(
|
||||
type: TypeDeclaration(
|
||||
type: const TypeDeclaration(
|
||||
baseName: 'String',
|
||||
isNullable: true,
|
||||
),
|
||||
@ -528,21 +533,22 @@ void main() {
|
||||
name: 'doSomething',
|
||||
arguments: <NamedType>[
|
||||
NamedType(
|
||||
type: TypeDeclaration(
|
||||
type: const TypeDeclaration(
|
||||
baseName: 'Input',
|
||||
isNullable: false,
|
||||
),
|
||||
name: '',
|
||||
offset: null)
|
||||
],
|
||||
returnType: TypeDeclaration(baseName: 'Output', isNullable: false),
|
||||
returnType:
|
||||
const TypeDeclaration(baseName: 'Output', isNullable: false),
|
||||
isAsynchronous: true,
|
||||
)
|
||||
])
|
||||
], classes: <Class>[
|
||||
Class(name: 'Input', fields: <NamedType>[
|
||||
NamedType(
|
||||
type: TypeDeclaration(
|
||||
type: const TypeDeclaration(
|
||||
baseName: 'String',
|
||||
isNullable: true,
|
||||
),
|
||||
@ -551,7 +557,7 @@ void main() {
|
||||
]),
|
||||
Class(name: 'Output', fields: <NamedType>[
|
||||
NamedType(
|
||||
type: TypeDeclaration(
|
||||
type: const TypeDeclaration(
|
||||
baseName: 'String',
|
||||
isNullable: true,
|
||||
),
|
||||
@ -579,7 +585,7 @@ void main() {
|
||||
name: 'EnumClass',
|
||||
fields: <NamedType>[
|
||||
NamedType(
|
||||
type: TypeDeclaration(
|
||||
type: const TypeDeclaration(
|
||||
baseName: 'Enum1',
|
||||
isNullable: true,
|
||||
),
|
||||
@ -628,7 +634,7 @@ void main() {
|
||||
name: 'Foobar',
|
||||
fields: <NamedType>[
|
||||
NamedType(
|
||||
type: TypeDeclaration(
|
||||
type: const TypeDeclaration(
|
||||
baseName: 'List',
|
||||
isNullable: true,
|
||||
typeArguments: <TypeDeclaration>[
|
||||
@ -656,7 +662,7 @@ void main() {
|
||||
name: 'Foobar',
|
||||
fields: <NamedType>[
|
||||
NamedType(
|
||||
type: TypeDeclaration(
|
||||
type: const TypeDeclaration(
|
||||
baseName: 'Map',
|
||||
isNullable: true,
|
||||
typeArguments: <TypeDeclaration>[
|
||||
@ -686,10 +692,10 @@ void main() {
|
||||
Api(name: 'Api', location: ApiLocation.host, methods: <Method>[
|
||||
Method(
|
||||
name: 'doit',
|
||||
returnType: TypeDeclaration.voidDeclaration(),
|
||||
returnType: const TypeDeclaration.voidDeclaration(),
|
||||
arguments: <NamedType>[
|
||||
NamedType(
|
||||
type: TypeDeclaration(
|
||||
type: const TypeDeclaration(
|
||||
baseName: 'List',
|
||||
isNullable: false,
|
||||
typeArguments: <TypeDeclaration>[
|
||||
@ -716,10 +722,10 @@ void main() {
|
||||
Api(name: 'Api', location: ApiLocation.flutter, methods: <Method>[
|
||||
Method(
|
||||
name: 'doit',
|
||||
returnType: TypeDeclaration.voidDeclaration(),
|
||||
returnType: const TypeDeclaration.voidDeclaration(),
|
||||
arguments: <NamedType>[
|
||||
NamedType(
|
||||
type: TypeDeclaration(
|
||||
type: const TypeDeclaration(
|
||||
baseName: 'List',
|
||||
isNullable: false,
|
||||
typeArguments: <TypeDeclaration>[
|
||||
@ -746,7 +752,7 @@ void main() {
|
||||
Api(name: 'Api', location: ApiLocation.host, methods: <Method>[
|
||||
Method(
|
||||
name: 'doit',
|
||||
returnType: TypeDeclaration(
|
||||
returnType: const TypeDeclaration(
|
||||
baseName: 'List',
|
||||
isNullable: false,
|
||||
typeArguments: <TypeDeclaration>[
|
||||
@ -772,7 +778,7 @@ void main() {
|
||||
Api(name: 'Api', location: ApiLocation.flutter, methods: <Method>[
|
||||
Method(
|
||||
name: 'doit',
|
||||
returnType: TypeDeclaration(
|
||||
returnType: const TypeDeclaration(
|
||||
baseName: 'List',
|
||||
isNullable: false,
|
||||
typeArguments: <TypeDeclaration>[
|
||||
@ -800,12 +806,14 @@ void main() {
|
||||
arguments: <NamedType>[
|
||||
NamedType(
|
||||
name: 'x',
|
||||
type: TypeDeclaration(isNullable: false, baseName: 'int')),
|
||||
type:
|
||||
const TypeDeclaration(isNullable: false, baseName: 'int')),
|
||||
NamedType(
|
||||
name: 'y',
|
||||
type: TypeDeclaration(isNullable: false, baseName: 'int')),
|
||||
type:
|
||||
const TypeDeclaration(isNullable: false, baseName: 'int')),
|
||||
],
|
||||
returnType: TypeDeclaration(baseName: 'int', isNullable: false),
|
||||
returnType: const TypeDeclaration(baseName: 'int', isNullable: false),
|
||||
isAsynchronous: false,
|
||||
)
|
||||
])
|
||||
@ -832,12 +840,14 @@ void main() {
|
||||
arguments: <NamedType>[
|
||||
NamedType(
|
||||
name: 'x',
|
||||
type: TypeDeclaration(isNullable: false, baseName: 'int')),
|
||||
type:
|
||||
const TypeDeclaration(isNullable: false, baseName: 'int')),
|
||||
NamedType(
|
||||
name: 'y',
|
||||
type: TypeDeclaration(isNullable: false, baseName: 'int')),
|
||||
type:
|
||||
const TypeDeclaration(isNullable: false, baseName: 'int')),
|
||||
],
|
||||
returnType: TypeDeclaration(baseName: 'int', isNullable: false),
|
||||
returnType: const TypeDeclaration(baseName: 'int', isNullable: false),
|
||||
isAsynchronous: false,
|
||||
)
|
||||
])
|
||||
|
@ -11,7 +11,7 @@ void main() {
|
||||
final Root root = Root(apis: <Api>[], classes: <Class>[
|
||||
Class(name: 'Foobar', fields: <NamedType>[
|
||||
NamedType(
|
||||
type: TypeDeclaration(baseName: 'String', isNullable: true),
|
||||
type: const TypeDeclaration(baseName: 'String', isNullable: true),
|
||||
name: 'field1',
|
||||
offset: null)
|
||||
]),
|
||||
@ -27,7 +27,7 @@ void main() {
|
||||
final Root root = Root(apis: <Api>[], classes: <Class>[
|
||||
Class(name: 'Foobar', fields: <NamedType>[
|
||||
NamedType(
|
||||
type: TypeDeclaration(baseName: 'String', isNullable: true),
|
||||
type: const TypeDeclaration(baseName: 'String', isNullable: true),
|
||||
name: 'field1',
|
||||
offset: null)
|
||||
]),
|
||||
@ -83,11 +83,13 @@ void main() {
|
||||
name: 'Foobar',
|
||||
fields: <NamedType>[
|
||||
NamedType(
|
||||
type: TypeDeclaration(baseName: 'String', isNullable: true),
|
||||
type:
|
||||
const TypeDeclaration(baseName: 'String', isNullable: true),
|
||||
name: 'field1',
|
||||
offset: null),
|
||||
NamedType(
|
||||
type: TypeDeclaration(baseName: 'Enum1', isNullable: true),
|
||||
type:
|
||||
const TypeDeclaration(baseName: 'Enum1', isNullable: true),
|
||||
name: 'enum1',
|
||||
offset: null),
|
||||
],
|
||||
@ -119,11 +121,13 @@ void main() {
|
||||
name: 'Foobar',
|
||||
fields: <NamedType>[
|
||||
NamedType(
|
||||
type: TypeDeclaration(baseName: 'String', isNullable: true),
|
||||
type:
|
||||
const TypeDeclaration(baseName: 'String', isNullable: true),
|
||||
name: 'field1',
|
||||
offset: null),
|
||||
NamedType(
|
||||
type: TypeDeclaration(baseName: 'Enum1', isNullable: true),
|
||||
type:
|
||||
const TypeDeclaration(baseName: 'Enum1', isNullable: true),
|
||||
name: 'enum1',
|
||||
offset: null),
|
||||
],
|
||||
@ -152,22 +156,24 @@ void main() {
|
||||
name: 'doSomething',
|
||||
arguments: <NamedType>[
|
||||
NamedType(
|
||||
type: TypeDeclaration(baseName: 'Input', isNullable: false),
|
||||
type: const TypeDeclaration(
|
||||
baseName: 'Input', isNullable: false),
|
||||
name: '',
|
||||
offset: null)
|
||||
],
|
||||
returnType: TypeDeclaration(baseName: 'Output', isNullable: false))
|
||||
returnType:
|
||||
const TypeDeclaration(baseName: 'Output', isNullable: false))
|
||||
])
|
||||
], classes: <Class>[
|
||||
Class(name: 'Input', fields: <NamedType>[
|
||||
NamedType(
|
||||
type: TypeDeclaration(baseName: 'String', isNullable: true),
|
||||
type: const TypeDeclaration(baseName: 'String', isNullable: true),
|
||||
name: 'input',
|
||||
offset: null)
|
||||
]),
|
||||
Class(name: 'Output', fields: <NamedType>[
|
||||
NamedType(
|
||||
type: TypeDeclaration(baseName: 'String', isNullable: true),
|
||||
type: const TypeDeclaration(baseName: 'String', isNullable: true),
|
||||
name: 'output',
|
||||
offset: null)
|
||||
])
|
||||
@ -189,25 +195,26 @@ void main() {
|
||||
name: 'doSomething',
|
||||
arguments: <NamedType>[
|
||||
NamedType(
|
||||
type: TypeDeclaration(
|
||||
type: const TypeDeclaration(
|
||||
baseName: 'Input',
|
||||
isNullable: false,
|
||||
),
|
||||
name: '',
|
||||
offset: null)
|
||||
],
|
||||
returnType: TypeDeclaration(baseName: 'Output', isNullable: false))
|
||||
returnType:
|
||||
const TypeDeclaration(baseName: 'Output', isNullable: false))
|
||||
])
|
||||
], classes: <Class>[
|
||||
Class(name: 'Input', fields: <NamedType>[
|
||||
NamedType(
|
||||
type: TypeDeclaration(baseName: 'String', isNullable: true),
|
||||
type: const TypeDeclaration(baseName: 'String', isNullable: true),
|
||||
name: 'input',
|
||||
offset: null)
|
||||
]),
|
||||
Class(name: 'Output', fields: <NamedType>[
|
||||
NamedType(
|
||||
type: TypeDeclaration(baseName: 'String', isNullable: true),
|
||||
type: const TypeDeclaration(baseName: 'String', isNullable: true),
|
||||
name: 'output',
|
||||
offset: null)
|
||||
])
|
||||
@ -229,35 +236,39 @@ void main() {
|
||||
final Root root = Root(apis: <Api>[], classes: <Class>[
|
||||
Class(name: 'Foobar', fields: <NamedType>[
|
||||
NamedType(
|
||||
type: TypeDeclaration(baseName: 'bool', isNullable: true),
|
||||
type: const TypeDeclaration(baseName: 'bool', isNullable: true),
|
||||
name: 'aBool',
|
||||
offset: null),
|
||||
NamedType(
|
||||
type: TypeDeclaration(baseName: 'int', isNullable: true),
|
||||
type: const TypeDeclaration(baseName: 'int', isNullable: true),
|
||||
name: 'aInt',
|
||||
offset: null),
|
||||
NamedType(
|
||||
type: TypeDeclaration(baseName: 'double', isNullable: true),
|
||||
type: const TypeDeclaration(baseName: 'double', isNullable: true),
|
||||
name: 'aDouble',
|
||||
offset: null),
|
||||
NamedType(
|
||||
type: TypeDeclaration(baseName: 'String', isNullable: true),
|
||||
type: const TypeDeclaration(baseName: 'String', isNullable: true),
|
||||
name: 'aString',
|
||||
offset: null),
|
||||
NamedType(
|
||||
type: TypeDeclaration(baseName: 'Uint8List', isNullable: true),
|
||||
type:
|
||||
const TypeDeclaration(baseName: 'Uint8List', isNullable: true),
|
||||
name: 'aUint8List',
|
||||
offset: null),
|
||||
NamedType(
|
||||
type: TypeDeclaration(baseName: 'Int32List', isNullable: true),
|
||||
type:
|
||||
const TypeDeclaration(baseName: 'Int32List', isNullable: true),
|
||||
name: 'aInt32List',
|
||||
offset: null),
|
||||
NamedType(
|
||||
type: TypeDeclaration(baseName: 'Int64List', isNullable: true),
|
||||
type:
|
||||
const TypeDeclaration(baseName: 'Int64List', isNullable: true),
|
||||
name: 'aInt64List',
|
||||
offset: null),
|
||||
NamedType(
|
||||
type: TypeDeclaration(baseName: 'Float64List', isNullable: true),
|
||||
type: const TypeDeclaration(
|
||||
baseName: 'Float64List', isNullable: true),
|
||||
name: 'aFloat64List',
|
||||
offset: null),
|
||||
]),
|
||||
@ -286,7 +297,7 @@ void main() {
|
||||
final Root root = Root(apis: <Api>[], classes: <Class>[
|
||||
Class(name: 'Foobar', fields: <NamedType>[
|
||||
NamedType(
|
||||
type: TypeDeclaration(baseName: 'bool', isNullable: true),
|
||||
type: const TypeDeclaration(baseName: 'bool', isNullable: true),
|
||||
name: 'aBool',
|
||||
offset: null),
|
||||
]),
|
||||
@ -303,13 +314,13 @@ void main() {
|
||||
final Root root = Root(apis: <Api>[], classes: <Class>[
|
||||
Class(name: 'Input', fields: <NamedType>[
|
||||
NamedType(
|
||||
type: TypeDeclaration(baseName: 'String', isNullable: true),
|
||||
type: const TypeDeclaration(baseName: 'String', isNullable: true),
|
||||
name: 'input',
|
||||
offset: null)
|
||||
]),
|
||||
Class(name: 'Nested', fields: <NamedType>[
|
||||
NamedType(
|
||||
type: TypeDeclaration(baseName: 'Input', isNullable: true),
|
||||
type: const TypeDeclaration(baseName: 'Input', isNullable: true),
|
||||
name: 'nested',
|
||||
offset: null)
|
||||
])
|
||||
@ -325,13 +336,13 @@ void main() {
|
||||
final Root root = Root(apis: <Api>[], classes: <Class>[
|
||||
Class(name: 'Input', fields: <NamedType>[
|
||||
NamedType(
|
||||
type: TypeDeclaration(baseName: 'String', isNullable: true),
|
||||
type: const TypeDeclaration(baseName: 'String', isNullable: true),
|
||||
name: 'input',
|
||||
offset: null)
|
||||
]),
|
||||
Class(name: 'Nested', fields: <NamedType>[
|
||||
NamedType(
|
||||
type: TypeDeclaration(baseName: 'Input', isNullable: true),
|
||||
type: const TypeDeclaration(baseName: 'Input', isNullable: true),
|
||||
name: 'nested',
|
||||
offset: null)
|
||||
])
|
||||
@ -347,7 +358,7 @@ void main() {
|
||||
final Root root = Root(apis: <Api>[], classes: <Class>[
|
||||
Class(name: 'Foobar', fields: <NamedType>[
|
||||
NamedType(
|
||||
type: TypeDeclaration(baseName: 'String', isNullable: true),
|
||||
type: const TypeDeclaration(baseName: 'String', isNullable: true),
|
||||
name: 'field1',
|
||||
offset: null)
|
||||
]),
|
||||
@ -362,7 +373,7 @@ void main() {
|
||||
final Root root = Root(apis: <Api>[], classes: <Class>[
|
||||
Class(name: 'Foobar', fields: <NamedType>[
|
||||
NamedType(
|
||||
type: TypeDeclaration(baseName: 'String', isNullable: true),
|
||||
type: const TypeDeclaration(baseName: 'String', isNullable: true),
|
||||
name: 'field1',
|
||||
offset: null)
|
||||
]),
|
||||
@ -380,25 +391,26 @@ void main() {
|
||||
name: 'doSomething',
|
||||
arguments: <NamedType>[
|
||||
NamedType(
|
||||
type: TypeDeclaration(
|
||||
type: const TypeDeclaration(
|
||||
baseName: 'Input',
|
||||
isNullable: false,
|
||||
),
|
||||
name: '',
|
||||
offset: null)
|
||||
],
|
||||
returnType: TypeDeclaration(baseName: 'Nested', isNullable: false))
|
||||
returnType:
|
||||
const TypeDeclaration(baseName: 'Nested', isNullable: false))
|
||||
])
|
||||
], classes: <Class>[
|
||||
Class(name: 'Input', fields: <NamedType>[
|
||||
NamedType(
|
||||
type: TypeDeclaration(baseName: 'String', isNullable: true),
|
||||
type: const TypeDeclaration(baseName: 'String', isNullable: true),
|
||||
name: 'input',
|
||||
offset: null)
|
||||
]),
|
||||
Class(name: 'Nested', fields: <NamedType>[
|
||||
NamedType(
|
||||
type: TypeDeclaration(baseName: 'Input', isNullable: true),
|
||||
type: const TypeDeclaration(baseName: 'Input', isNullable: true),
|
||||
name: 'nested',
|
||||
offset: null)
|
||||
])
|
||||
@ -418,25 +430,26 @@ void main() {
|
||||
name: 'doSomething',
|
||||
arguments: <NamedType>[
|
||||
NamedType(
|
||||
type: TypeDeclaration(
|
||||
type: const TypeDeclaration(
|
||||
baseName: 'Input',
|
||||
isNullable: false,
|
||||
),
|
||||
name: '',
|
||||
offset: null)
|
||||
],
|
||||
returnType: TypeDeclaration(baseName: 'Nested', isNullable: false))
|
||||
returnType:
|
||||
const TypeDeclaration(baseName: 'Nested', isNullable: false))
|
||||
])
|
||||
], classes: <Class>[
|
||||
Class(name: 'Input', fields: <NamedType>[
|
||||
NamedType(
|
||||
type: TypeDeclaration(baseName: 'String', isNullable: true),
|
||||
type: const TypeDeclaration(baseName: 'String', isNullable: true),
|
||||
name: 'input',
|
||||
offset: null)
|
||||
]),
|
||||
Class(name: 'Nested', fields: <NamedType>[
|
||||
NamedType(
|
||||
type: TypeDeclaration(baseName: 'Input', isNullable: true),
|
||||
type: const TypeDeclaration(baseName: 'Input', isNullable: true),
|
||||
name: 'nested',
|
||||
offset: null)
|
||||
])
|
||||
@ -456,25 +469,26 @@ void main() {
|
||||
name: 'doSomething',
|
||||
arguments: <NamedType>[
|
||||
NamedType(
|
||||
type: TypeDeclaration(
|
||||
type: const TypeDeclaration(
|
||||
baseName: 'Input',
|
||||
isNullable: false,
|
||||
),
|
||||
name: '',
|
||||
offset: null)
|
||||
],
|
||||
returnType: TypeDeclaration(baseName: 'Output', isNullable: false))
|
||||
returnType:
|
||||
const TypeDeclaration(baseName: 'Output', isNullable: false))
|
||||
])
|
||||
], classes: <Class>[
|
||||
Class(name: 'Input', fields: <NamedType>[
|
||||
NamedType(
|
||||
type: TypeDeclaration(baseName: 'String', isNullable: true),
|
||||
type: const TypeDeclaration(baseName: 'String', isNullable: true),
|
||||
name: 'input',
|
||||
offset: null)
|
||||
]),
|
||||
Class(name: 'Output', fields: <NamedType>[
|
||||
NamedType(
|
||||
type: TypeDeclaration(baseName: 'String', isNullable: true),
|
||||
type: const TypeDeclaration(baseName: 'String', isNullable: true),
|
||||
name: 'output',
|
||||
offset: null)
|
||||
])
|
||||
@ -497,25 +511,26 @@ void main() {
|
||||
name: 'doSomething',
|
||||
arguments: <NamedType>[
|
||||
NamedType(
|
||||
type: TypeDeclaration(
|
||||
type: const TypeDeclaration(
|
||||
baseName: 'Input',
|
||||
isNullable: false,
|
||||
),
|
||||
name: '',
|
||||
offset: null)
|
||||
],
|
||||
returnType: TypeDeclaration(baseName: 'Output', isNullable: false))
|
||||
returnType:
|
||||
const TypeDeclaration(baseName: 'Output', isNullable: false))
|
||||
])
|
||||
], classes: <Class>[
|
||||
Class(name: 'Input', fields: <NamedType>[
|
||||
NamedType(
|
||||
type: TypeDeclaration(baseName: 'String', isNullable: true),
|
||||
type: const TypeDeclaration(baseName: 'String', isNullable: true),
|
||||
name: 'input',
|
||||
offset: null)
|
||||
]),
|
||||
Class(name: 'Output', fields: <NamedType>[
|
||||
NamedType(
|
||||
type: TypeDeclaration(baseName: 'String', isNullable: true),
|
||||
type: const TypeDeclaration(baseName: 'String', isNullable: true),
|
||||
name: 'output',
|
||||
offset: null)
|
||||
])
|
||||
@ -534,19 +549,19 @@ void main() {
|
||||
name: 'doSomething',
|
||||
arguments: <NamedType>[
|
||||
NamedType(
|
||||
type: TypeDeclaration(
|
||||
type: const TypeDeclaration(
|
||||
baseName: 'Input',
|
||||
isNullable: false,
|
||||
),
|
||||
name: '',
|
||||
offset: null)
|
||||
],
|
||||
returnType: TypeDeclaration.voidDeclaration())
|
||||
returnType: const TypeDeclaration.voidDeclaration())
|
||||
])
|
||||
], classes: <Class>[
|
||||
Class(name: 'Input', fields: <NamedType>[
|
||||
NamedType(
|
||||
type: TypeDeclaration(baseName: 'String', isNullable: true),
|
||||
type: const TypeDeclaration(baseName: 'String', isNullable: true),
|
||||
name: 'input',
|
||||
offset: null)
|
||||
]),
|
||||
@ -565,19 +580,19 @@ void main() {
|
||||
name: 'doSomething',
|
||||
arguments: <NamedType>[
|
||||
NamedType(
|
||||
type: TypeDeclaration(
|
||||
type: const TypeDeclaration(
|
||||
baseName: 'Input',
|
||||
isNullable: false,
|
||||
),
|
||||
name: '',
|
||||
offset: null)
|
||||
],
|
||||
returnType: TypeDeclaration.voidDeclaration())
|
||||
returnType: const TypeDeclaration.voidDeclaration())
|
||||
])
|
||||
], classes: <Class>[
|
||||
Class(name: 'Input', fields: <NamedType>[
|
||||
NamedType(
|
||||
type: TypeDeclaration(baseName: 'String', isNullable: true),
|
||||
type: const TypeDeclaration(baseName: 'String', isNullable: true),
|
||||
name: 'input',
|
||||
offset: null)
|
||||
]),
|
||||
@ -598,19 +613,19 @@ void main() {
|
||||
name: 'doSomething',
|
||||
arguments: <NamedType>[
|
||||
NamedType(
|
||||
type: TypeDeclaration(
|
||||
type: const TypeDeclaration(
|
||||
baseName: 'Input',
|
||||
isNullable: false,
|
||||
),
|
||||
name: '',
|
||||
offset: null)
|
||||
],
|
||||
returnType: TypeDeclaration.voidDeclaration())
|
||||
returnType: const TypeDeclaration.voidDeclaration())
|
||||
])
|
||||
], classes: <Class>[
|
||||
Class(name: 'Input', fields: <NamedType>[
|
||||
NamedType(
|
||||
type: TypeDeclaration(baseName: 'String', isNullable: true),
|
||||
type: const TypeDeclaration(baseName: 'String', isNullable: true),
|
||||
name: 'input',
|
||||
offset: null)
|
||||
]),
|
||||
@ -629,19 +644,19 @@ void main() {
|
||||
name: 'doSomething',
|
||||
arguments: <NamedType>[
|
||||
NamedType(
|
||||
type: TypeDeclaration(
|
||||
type: const TypeDeclaration(
|
||||
baseName: 'Input',
|
||||
isNullable: false,
|
||||
),
|
||||
name: '',
|
||||
offset: null)
|
||||
],
|
||||
returnType: TypeDeclaration.voidDeclaration())
|
||||
returnType: const TypeDeclaration.voidDeclaration())
|
||||
])
|
||||
], classes: <Class>[
|
||||
Class(name: 'Input', fields: <NamedType>[
|
||||
NamedType(
|
||||
type: TypeDeclaration(baseName: 'String', isNullable: true),
|
||||
type: const TypeDeclaration(baseName: 'String', isNullable: true),
|
||||
name: 'input',
|
||||
offset: null)
|
||||
]),
|
||||
@ -660,12 +675,13 @@ void main() {
|
||||
Method(
|
||||
name: 'doSomething',
|
||||
arguments: <NamedType>[],
|
||||
returnType: TypeDeclaration(baseName: 'Output', isNullable: false))
|
||||
returnType:
|
||||
const TypeDeclaration(baseName: 'Output', isNullable: false))
|
||||
])
|
||||
], classes: <Class>[
|
||||
Class(name: 'Output', fields: <NamedType>[
|
||||
NamedType(
|
||||
type: TypeDeclaration(baseName: 'String', isNullable: true),
|
||||
type: const TypeDeclaration(baseName: 'String', isNullable: true),
|
||||
name: 'output',
|
||||
offset: null)
|
||||
]),
|
||||
@ -683,12 +699,13 @@ void main() {
|
||||
Method(
|
||||
name: 'doSomething',
|
||||
arguments: <NamedType>[],
|
||||
returnType: TypeDeclaration(baseName: 'Output', isNullable: false))
|
||||
returnType:
|
||||
const TypeDeclaration(baseName: 'Output', isNullable: false))
|
||||
])
|
||||
], classes: <Class>[
|
||||
Class(name: 'Output', fields: <NamedType>[
|
||||
NamedType(
|
||||
type: TypeDeclaration(baseName: 'String', isNullable: true),
|
||||
type: const TypeDeclaration(baseName: 'String', isNullable: true),
|
||||
name: 'output',
|
||||
offset: null)
|
||||
]),
|
||||
@ -706,12 +723,13 @@ void main() {
|
||||
Method(
|
||||
name: 'doSomething',
|
||||
arguments: <NamedType>[],
|
||||
returnType: TypeDeclaration(baseName: 'Output', isNullable: false))
|
||||
returnType:
|
||||
const TypeDeclaration(baseName: 'Output', isNullable: false))
|
||||
])
|
||||
], classes: <Class>[
|
||||
Class(name: 'Output', fields: <NamedType>[
|
||||
NamedType(
|
||||
type: TypeDeclaration(baseName: 'String', isNullable: true),
|
||||
type: const TypeDeclaration(baseName: 'String', isNullable: true),
|
||||
name: 'output',
|
||||
offset: null)
|
||||
]),
|
||||
@ -732,12 +750,13 @@ void main() {
|
||||
Method(
|
||||
name: 'doSomething',
|
||||
arguments: <NamedType>[],
|
||||
returnType: TypeDeclaration(baseName: 'Output', isNullable: false))
|
||||
returnType:
|
||||
const TypeDeclaration(baseName: 'Output', isNullable: false))
|
||||
])
|
||||
], classes: <Class>[
|
||||
Class(name: 'Output', fields: <NamedType>[
|
||||
NamedType(
|
||||
type: TypeDeclaration(baseName: 'String', isNullable: true),
|
||||
type: const TypeDeclaration(baseName: 'String', isNullable: true),
|
||||
name: 'output',
|
||||
offset: null)
|
||||
]),
|
||||
@ -757,7 +776,7 @@ void main() {
|
||||
final Root root = Root(apis: <Api>[], classes: <Class>[
|
||||
Class(name: 'Foobar', fields: <NamedType>[
|
||||
NamedType(
|
||||
type: TypeDeclaration(baseName: 'List', isNullable: true),
|
||||
type: const TypeDeclaration(baseName: 'List', isNullable: true),
|
||||
name: 'field1',
|
||||
offset: null)
|
||||
]),
|
||||
@ -773,7 +792,7 @@ void main() {
|
||||
final Root root = Root(apis: <Api>[], classes: <Class>[
|
||||
Class(name: 'Foobar', fields: <NamedType>[
|
||||
NamedType(
|
||||
type: TypeDeclaration(baseName: 'Map', isNullable: true),
|
||||
type: const TypeDeclaration(baseName: 'Map', isNullable: true),
|
||||
name: 'field1',
|
||||
offset: null)
|
||||
]),
|
||||
@ -785,6 +804,56 @@ void main() {
|
||||
expect(code, matches('@property.*NSDictionary.*field1'));
|
||||
});
|
||||
|
||||
test('gen map field with object', () {
|
||||
final Root root = Root(apis: <Api>[], classes: <Class>[
|
||||
Class(name: 'Foobar', fields: <NamedType>[
|
||||
NamedType(
|
||||
type: const TypeDeclaration(
|
||||
baseName: 'Map',
|
||||
isNullable: true,
|
||||
typeArguments: <TypeDeclaration>[
|
||||
TypeDeclaration(baseName: 'String', isNullable: true),
|
||||
TypeDeclaration(baseName: 'Object', isNullable: true),
|
||||
]),
|
||||
name: 'field1',
|
||||
offset: null)
|
||||
]),
|
||||
], enums: <Enum>[]);
|
||||
final StringBuffer sink = StringBuffer();
|
||||
generateObjcHeader(const ObjcOptions(), root, sink);
|
||||
final String code = sink.toString();
|
||||
expect(code, contains('@interface Foobar'));
|
||||
expect(
|
||||
code,
|
||||
contains(
|
||||
'@property(nonatomic, strong, nullable) NSDictionary<NSString *, id> *'));
|
||||
});
|
||||
|
||||
test('gen map argument with object', () {
|
||||
final Root root = Root(apis: <Api>[
|
||||
Api(name: 'Api', location: ApiLocation.host, methods: <Method>[
|
||||
Method(
|
||||
name: 'doit',
|
||||
returnType: const TypeDeclaration.voidDeclaration(),
|
||||
arguments: <NamedType>[
|
||||
NamedType(
|
||||
name: 'foo',
|
||||
type: const TypeDeclaration(
|
||||
baseName: 'Map',
|
||||
isNullable: true,
|
||||
typeArguments: <TypeDeclaration>[
|
||||
TypeDeclaration(baseName: 'String', isNullable: true),
|
||||
TypeDeclaration(baseName: 'Object', isNullable: true),
|
||||
]))
|
||||
]),
|
||||
])
|
||||
], classes: <Class>[], enums: <Enum>[]);
|
||||
final StringBuffer sink = StringBuffer();
|
||||
generateObjcHeader(const ObjcOptions(), root, sink);
|
||||
final String code = sink.toString();
|
||||
expect(code, contains('(NSDictionary<NSString *, id> *)foo'));
|
||||
});
|
||||
|
||||
test('async void(input) HostApi header', () {
|
||||
final Root root = Root(apis: <Api>[
|
||||
Api(name: 'Api', location: ApiLocation.host, methods: <Method>[
|
||||
@ -792,26 +861,26 @@ void main() {
|
||||
name: 'doSomething',
|
||||
arguments: <NamedType>[
|
||||
NamedType(
|
||||
type: TypeDeclaration(
|
||||
type: const TypeDeclaration(
|
||||
baseName: 'Input',
|
||||
isNullable: false,
|
||||
),
|
||||
name: 'input',
|
||||
offset: null)
|
||||
],
|
||||
returnType: TypeDeclaration.voidDeclaration(),
|
||||
returnType: const TypeDeclaration.voidDeclaration(),
|
||||
isAsynchronous: true)
|
||||
])
|
||||
], classes: <Class>[
|
||||
Class(name: 'Input', fields: <NamedType>[
|
||||
NamedType(
|
||||
type: TypeDeclaration(baseName: 'String', isNullable: true),
|
||||
type: const TypeDeclaration(baseName: 'String', isNullable: true),
|
||||
name: 'input',
|
||||
offset: null)
|
||||
]),
|
||||
Class(name: 'Output', fields: <NamedType>[
|
||||
NamedType(
|
||||
type: TypeDeclaration(baseName: 'String', isNullable: true),
|
||||
type: const TypeDeclaration(baseName: 'String', isNullable: true),
|
||||
name: 'output',
|
||||
offset: null)
|
||||
]),
|
||||
@ -833,26 +902,27 @@ void main() {
|
||||
name: 'doSomething',
|
||||
arguments: <NamedType>[
|
||||
NamedType(
|
||||
type: TypeDeclaration(
|
||||
type: const TypeDeclaration(
|
||||
baseName: 'Input',
|
||||
isNullable: false,
|
||||
),
|
||||
name: 'input',
|
||||
offset: null)
|
||||
],
|
||||
returnType: TypeDeclaration(baseName: 'Output', isNullable: false),
|
||||
returnType:
|
||||
const TypeDeclaration(baseName: 'Output', isNullable: false),
|
||||
isAsynchronous: true)
|
||||
])
|
||||
], classes: <Class>[
|
||||
Class(name: 'Input', fields: <NamedType>[
|
||||
NamedType(
|
||||
type: TypeDeclaration(baseName: 'String', isNullable: true),
|
||||
type: const TypeDeclaration(baseName: 'String', isNullable: true),
|
||||
name: 'input',
|
||||
offset: null)
|
||||
]),
|
||||
Class(name: 'Output', fields: <NamedType>[
|
||||
NamedType(
|
||||
type: TypeDeclaration(baseName: 'String', isNullable: true),
|
||||
type: const TypeDeclaration(baseName: 'String', isNullable: true),
|
||||
name: 'output',
|
||||
offset: null)
|
||||
]),
|
||||
@ -873,13 +943,14 @@ void main() {
|
||||
Method(
|
||||
name: 'doSomething',
|
||||
arguments: <NamedType>[],
|
||||
returnType: TypeDeclaration(baseName: 'Output', isNullable: false),
|
||||
returnType:
|
||||
const TypeDeclaration(baseName: 'Output', isNullable: false),
|
||||
isAsynchronous: true)
|
||||
])
|
||||
], classes: <Class>[
|
||||
Class(name: 'Output', fields: <NamedType>[
|
||||
NamedType(
|
||||
type: TypeDeclaration(baseName: 'String', isNullable: true),
|
||||
type: const TypeDeclaration(baseName: 'String', isNullable: true),
|
||||
name: 'output',
|
||||
offset: null)
|
||||
]),
|
||||
@ -900,7 +971,7 @@ void main() {
|
||||
Method(
|
||||
name: 'doSomething',
|
||||
arguments: <NamedType>[],
|
||||
returnType: TypeDeclaration.voidDeclaration(),
|
||||
returnType: const TypeDeclaration.voidDeclaration(),
|
||||
isAsynchronous: true)
|
||||
])
|
||||
], classes: <Class>[], enums: <Enum>[]);
|
||||
@ -921,26 +992,27 @@ void main() {
|
||||
name: 'doSomething',
|
||||
arguments: <NamedType>[
|
||||
NamedType(
|
||||
type: TypeDeclaration(
|
||||
type: const TypeDeclaration(
|
||||
baseName: 'Input',
|
||||
isNullable: false,
|
||||
),
|
||||
name: '',
|
||||
offset: null)
|
||||
],
|
||||
returnType: TypeDeclaration(baseName: 'Output', isNullable: false),
|
||||
returnType:
|
||||
const TypeDeclaration(baseName: 'Output', isNullable: false),
|
||||
isAsynchronous: true)
|
||||
])
|
||||
], classes: <Class>[
|
||||
Class(name: 'Input', fields: <NamedType>[
|
||||
NamedType(
|
||||
type: TypeDeclaration(baseName: 'String', isNullable: true),
|
||||
type: const TypeDeclaration(baseName: 'String', isNullable: true),
|
||||
name: 'input',
|
||||
offset: null)
|
||||
]),
|
||||
Class(name: 'Output', fields: <NamedType>[
|
||||
NamedType(
|
||||
type: TypeDeclaration(baseName: 'String', isNullable: true),
|
||||
type: const TypeDeclaration(baseName: 'String', isNullable: true),
|
||||
name: 'output',
|
||||
offset: null)
|
||||
]),
|
||||
@ -962,26 +1034,26 @@ void main() {
|
||||
name: 'doSomething',
|
||||
arguments: <NamedType>[
|
||||
NamedType(
|
||||
type: TypeDeclaration(
|
||||
type: const TypeDeclaration(
|
||||
baseName: 'Input',
|
||||
isNullable: false,
|
||||
),
|
||||
name: 'foo',
|
||||
offset: null)
|
||||
],
|
||||
returnType: TypeDeclaration.voidDeclaration(),
|
||||
returnType: const TypeDeclaration.voidDeclaration(),
|
||||
isAsynchronous: true)
|
||||
])
|
||||
], classes: <Class>[
|
||||
Class(name: 'Input', fields: <NamedType>[
|
||||
NamedType(
|
||||
type: TypeDeclaration(baseName: 'String', isNullable: true),
|
||||
type: const TypeDeclaration(baseName: 'String', isNullable: true),
|
||||
name: 'input',
|
||||
offset: null)
|
||||
]),
|
||||
Class(name: 'Output', fields: <NamedType>[
|
||||
NamedType(
|
||||
type: TypeDeclaration(baseName: 'String', isNullable: true),
|
||||
type: const TypeDeclaration(baseName: 'String', isNullable: true),
|
||||
name: 'output',
|
||||
offset: null)
|
||||
]),
|
||||
@ -1002,7 +1074,7 @@ void main() {
|
||||
Method(
|
||||
name: 'doSomething',
|
||||
arguments: <NamedType>[],
|
||||
returnType: TypeDeclaration.voidDeclaration(),
|
||||
returnType: const TypeDeclaration.voidDeclaration(),
|
||||
isAsynchronous: true)
|
||||
])
|
||||
], classes: <Class>[], enums: <Enum>[]);
|
||||
@ -1022,13 +1094,14 @@ void main() {
|
||||
Method(
|
||||
name: 'doSomething',
|
||||
arguments: <NamedType>[],
|
||||
returnType: TypeDeclaration(baseName: 'Output', isNullable: false),
|
||||
returnType:
|
||||
const TypeDeclaration(baseName: 'Output', isNullable: false),
|
||||
isAsynchronous: true)
|
||||
])
|
||||
], classes: <Class>[
|
||||
Class(name: 'Output', fields: <NamedType>[
|
||||
NamedType(
|
||||
type: TypeDeclaration(baseName: 'String', isNullable: true),
|
||||
type: const TypeDeclaration(baseName: 'String', isNullable: true),
|
||||
name: 'output',
|
||||
offset: null)
|
||||
]),
|
||||
@ -1082,7 +1155,7 @@ void main() {
|
||||
name: 'Foobar',
|
||||
fields: <NamedType>[
|
||||
NamedType(
|
||||
type: TypeDeclaration(
|
||||
type: const TypeDeclaration(
|
||||
baseName: 'List',
|
||||
isNullable: true,
|
||||
typeArguments: <TypeDeclaration>[
|
||||
@ -1110,10 +1183,10 @@ void main() {
|
||||
Api(name: 'Api', location: ApiLocation.host, methods: <Method>[
|
||||
Method(
|
||||
name: 'doit',
|
||||
returnType: TypeDeclaration.voidDeclaration(),
|
||||
returnType: const TypeDeclaration.voidDeclaration(),
|
||||
arguments: <NamedType>[
|
||||
NamedType(
|
||||
type: TypeDeclaration(
|
||||
type: const TypeDeclaration(
|
||||
baseName: 'List',
|
||||
isNullable: false,
|
||||
typeArguments: <TypeDeclaration>[
|
||||
@ -1149,10 +1222,10 @@ void main() {
|
||||
Api(name: 'Api', location: ApiLocation.flutter, methods: <Method>[
|
||||
Method(
|
||||
name: 'doit',
|
||||
returnType: TypeDeclaration.voidDeclaration(),
|
||||
returnType: const TypeDeclaration.voidDeclaration(),
|
||||
arguments: <NamedType>[
|
||||
NamedType(
|
||||
type: TypeDeclaration(
|
||||
type: const TypeDeclaration(
|
||||
baseName: 'List',
|
||||
isNullable: false,
|
||||
typeArguments: <TypeDeclaration>[
|
||||
@ -1188,10 +1261,10 @@ void main() {
|
||||
Api(name: 'Api', location: ApiLocation.host, methods: <Method>[
|
||||
Method(
|
||||
name: 'doit',
|
||||
returnType: TypeDeclaration.voidDeclaration(),
|
||||
returnType: const TypeDeclaration.voidDeclaration(),
|
||||
arguments: <NamedType>[
|
||||
NamedType(
|
||||
type: TypeDeclaration(
|
||||
type: const TypeDeclaration(
|
||||
baseName: 'List',
|
||||
isNullable: false,
|
||||
typeArguments: <TypeDeclaration>[
|
||||
@ -1226,7 +1299,7 @@ void main() {
|
||||
Api(name: 'Api', location: ApiLocation.host, methods: <Method>[
|
||||
Method(
|
||||
name: 'doit',
|
||||
returnType: TypeDeclaration(
|
||||
returnType: const TypeDeclaration(
|
||||
baseName: 'List',
|
||||
isNullable: false,
|
||||
typeArguments: <TypeDeclaration>[
|
||||
@ -1261,7 +1334,7 @@ void main() {
|
||||
Api(name: 'Api', location: ApiLocation.flutter, methods: <Method>[
|
||||
Method(
|
||||
name: 'doit',
|
||||
returnType: TypeDeclaration(
|
||||
returnType: const TypeDeclaration(
|
||||
baseName: 'List',
|
||||
isNullable: false,
|
||||
typeArguments: <TypeDeclaration>[
|
||||
@ -1299,12 +1372,14 @@ void main() {
|
||||
arguments: <NamedType>[
|
||||
NamedType(
|
||||
name: 'x',
|
||||
type: TypeDeclaration(isNullable: false, baseName: 'int')),
|
||||
type:
|
||||
const TypeDeclaration(isNullable: false, baseName: 'int')),
|
||||
NamedType(
|
||||
name: 'y',
|
||||
type: TypeDeclaration(isNullable: false, baseName: 'int')),
|
||||
type:
|
||||
const TypeDeclaration(isNullable: false, baseName: 'int')),
|
||||
],
|
||||
returnType: TypeDeclaration(baseName: 'int', isNullable: false),
|
||||
returnType: const TypeDeclaration(baseName: 'int', isNullable: false),
|
||||
isAsynchronous: false,
|
||||
)
|
||||
])
|
||||
@ -1340,12 +1415,14 @@ void main() {
|
||||
arguments: <NamedType>[
|
||||
NamedType(
|
||||
name: 'x',
|
||||
type: TypeDeclaration(isNullable: false, baseName: 'int')),
|
||||
type:
|
||||
const TypeDeclaration(isNullable: false, baseName: 'int')),
|
||||
NamedType(
|
||||
name: 'y',
|
||||
type: TypeDeclaration(isNullable: false, baseName: 'int')),
|
||||
type:
|
||||
const TypeDeclaration(isNullable: false, baseName: 'int')),
|
||||
],
|
||||
returnType: TypeDeclaration(baseName: 'int', isNullable: false),
|
||||
returnType: const TypeDeclaration(baseName: 'int', isNullable: false),
|
||||
isAsynchronous: true,
|
||||
)
|
||||
])
|
||||
@ -1380,12 +1457,14 @@ void main() {
|
||||
arguments: <NamedType>[
|
||||
NamedType(
|
||||
name: 'x',
|
||||
type: TypeDeclaration(isNullable: false, baseName: 'int')),
|
||||
type:
|
||||
const TypeDeclaration(isNullable: false, baseName: 'int')),
|
||||
NamedType(
|
||||
name: 'y',
|
||||
type: TypeDeclaration(isNullable: false, baseName: 'int')),
|
||||
type:
|
||||
const TypeDeclaration(isNullable: false, baseName: 'int')),
|
||||
],
|
||||
returnType: TypeDeclaration(baseName: 'int', isNullable: false),
|
||||
returnType: const TypeDeclaration(baseName: 'int', isNullable: false),
|
||||
isAsynchronous: false,
|
||||
)
|
||||
])
|
||||
@ -1421,16 +1500,18 @@ void main() {
|
||||
objcSelector: 'divideValue:by:',
|
||||
arguments: <NamedType>[
|
||||
NamedType(
|
||||
type: TypeDeclaration(baseName: 'int', isNullable: false),
|
||||
type: const TypeDeclaration(
|
||||
baseName: 'int', isNullable: false),
|
||||
name: 'x',
|
||||
),
|
||||
NamedType(
|
||||
type: TypeDeclaration(baseName: 'int', isNullable: false),
|
||||
type: const TypeDeclaration(
|
||||
baseName: 'int', isNullable: false),
|
||||
name: 'y',
|
||||
),
|
||||
],
|
||||
returnType:
|
||||
TypeDeclaration(baseName: 'double', isNullable: false))
|
||||
returnType: const TypeDeclaration(
|
||||
baseName: 'double', isNullable: false))
|
||||
])
|
||||
],
|
||||
classes: <Class>[],
|
||||
|
@ -890,4 +890,15 @@ abstract class Api {
|
||||
expect(results.errors[0].lineNumber, 3);
|
||||
expect(results.errors[0].message, contains('Unknown type: Foo'));
|
||||
});
|
||||
|
||||
test('Object type argument', () {
|
||||
const String code = '''
|
||||
@HostApi()
|
||||
abstract class Api {
|
||||
void storeAll(List<Object?> foos);
|
||||
}
|
||||
''';
|
||||
final ParseResults results = _parseSource(code);
|
||||
expect(results.errors.length, 0);
|
||||
});
|
||||
}
|
||||
|
Reference in New Issue
Block a user