From d351f18afc26a3aecb39f061254b700f370ad437 Mon Sep 17 00:00:00 2001 From: Karol Czeryna Date: Wed, 4 Dec 2024 22:35:59 +0100 Subject: [PATCH 1/5] update tool/generate_* scripts and sync files generated by those scripts --- .../lib/metadata_converter.dart | 44 +- pkgs/dart_model/lib/src/macro_metadata.g.dart | 931 ++++++++---------- schemas/macro_metadata.schema.json | 114 ++- .../lib/generate_dart_model.dart | 5 + .../lib/macro_metadata_definitions.dart | 212 ++-- tool/generate_converter | 19 +- tool/generate_definitions | 24 +- 7 files changed, 648 insertions(+), 701 deletions(-) diff --git a/pkgs/_analyzer_cfe_macros/lib/metadata_converter.dart b/pkgs/_analyzer_cfe_macros/lib/metadata_converter.dart index 4c8a13e6..554f5663 100644 --- a/pkgs/_analyzer_cfe_macros/lib/metadata_converter.dart +++ b/pkgs/_analyzer_cfe_macros/lib/metadata_converter.dart @@ -186,6 +186,9 @@ dart_model.Reference? convertToReference(Object? object) => switch (object) { front_end.EnumReference o => dart_model.Reference.enumReference( convert(o)!, ), + front_end.MixinReference o => dart_model.Reference.mixinReference( + convert(o)!, + ), front_end.FunctionTypeParameterReference o => dart_model .Reference.functionTypeParameterReference( convert(o)!, @@ -250,6 +253,8 @@ T? convert(Object? object) => switch (object) { front_end.BinaryOperator o => o.name as T, front_end.LogicalOperator o => o.name as T, front_end.UnaryOperator o => o.name as T, + front_end.AdjacentStringLiterals o => + dart_model.AdjacentStringLiterals(expressions: convert(o.expressions)) as T, front_end.AsExpression o => dart_model.AsExpression( expression: convertToExpression(o.expression), @@ -264,8 +269,9 @@ T? convert(Object? object) => switch (object) { ) as T, front_end.BooleanLiteral o => - dart_model.BooleanLiteral(text: convert(o.value.toString())) as T, - front_end.ClassReference o => dart_model.ClassReference() as T, + dart_model.BooleanLiteral(value: convert(o.value)) as T, + front_end.ClassReference o => + dart_model.ClassReference(name: convert(o.name)) as T, front_end.ConditionalExpression o => dart_model.ConditionalExpression( condition: convertToExpression(o.condition), @@ -275,12 +281,13 @@ T? convert(Object? object) => switch (object) { as T, front_end.ConstructorInvocation o => dart_model.ConstructorInvocation( - type: convertToTypeAnnotation(o.type), + type: convert(o.type), constructor: convertToReference(o.constructor), arguments: convert(o.arguments), ) as T, - front_end.ConstructorReference o => dart_model.ConstructorReference() as T, + front_end.ConstructorReference o => + dart_model.ConstructorReference(name: convert(o.name)) as T, front_end.ConstructorTearOff o => dart_model.ConstructorTearOff( type: convert(o.type), @@ -288,11 +295,13 @@ T? convert(Object? object) => switch (object) { ) as T, front_end.DoubleLiteral o => - dart_model.DoubleLiteral(text: convert(o.text)) as T, + dart_model.DoubleLiteral(text: convert(o.text), value: convert(o.value)) + as T, front_end.DynamicTypeAnnotation o => dart_model.DynamicTypeAnnotation(reference: convertToReference(o.reference)) as T, - front_end.EnumReference o => dart_model.EnumReference() as T, + front_end.EnumReference o => + dart_model.EnumReference(name: convert(o.name)) as T, front_end.EqualityExpression o => dart_model.EqualityExpression( left: convertToExpression(o.left), @@ -306,13 +315,16 @@ T? convert(Object? object) => switch (object) { isNullAware: convert(o.isNullAware), ) as T, - front_end.ExtensionReference o => dart_model.ExtensionReference() as T, + front_end.ExtensionReference o => + dart_model.ExtensionReference(name: convert(o.name)) as T, front_end.ExtensionTypeReference o => - dart_model.ExtensionTypeReference() as T, - front_end.FieldReference o => dart_model.FieldReference() as T, + dart_model.ExtensionTypeReference(name: convert(o.name)) as T, + front_end.FieldReference o => + dart_model.FieldReference(name: convert(o.name)) as T, front_end.FormalParameter o => dart_model.FormalParameter() as T, front_end.FormalParameterGroup o => dart_model.FormalParameterGroup() as T, - front_end.FunctionReference o => dart_model.FunctionReference() as T, + front_end.FunctionReference o => + dart_model.FunctionReference(name: convert(o.name)) as T, front_end.FunctionTearOff o => dart_model.FunctionTearOff(reference: convert(o.reference)) as T, front_end.FunctionTypeAnnotation o => @@ -324,7 +336,7 @@ T? convert(Object? object) => switch (object) { as T, front_end.FunctionTypeParameter o => dart_model.FunctionTypeParameter() as T, front_end.FunctionTypeParameterReference o => - dart_model.FunctionTypeParameterReference() as T, + dart_model.FunctionTypeParameterReference(name: convert(o.name)) as T, front_end.FunctionTypeParameterType o => dart_model.FunctionTypeParameterType( functionTypeParameter: convert(o.functionTypeParameter), @@ -357,7 +369,8 @@ T? convert(Object? object) => switch (object) { ) as T, front_end.IntegerLiteral o => - dart_model.IntegerLiteral(text: convert(o.text)) as T, + dart_model.IntegerLiteral(text: convert(o.text), value: convert(o.value)) + as T, front_end.InterpolationPart o => dart_model.InterpolationPart(expression: convertToExpression(o.expression)) as T, @@ -399,6 +412,8 @@ T? convert(Object? object) => switch (object) { arguments: convert(o.arguments), ) as T, + front_end.MixinReference o => + dart_model.MixinReference(name: convert(o.name)) as T, front_end.NamedArgument o => dart_model.NamedArgument( name: convert(o.name), @@ -479,14 +494,13 @@ T? convert(Object? object) => switch (object) { arguments: convert(o.arguments), ) as T, - front_end.AdjacentStringLiterals o => - dart_model.AdjacentStringLiterals(expressions: convert(o.expressions)) as T, front_end.StringLiteral o => dart_model.StringLiteral(parts: convert(o.parts)) as T, front_end.StringPart o => dart_model.StringPart(text: convert(o.text)) as T, front_end.SymbolLiteral o => dart_model.SymbolLiteral(parts: convert(o.parts)) as T, - front_end.TypedefReference o => dart_model.TypedefReference() as T, + front_end.TypedefReference o => + dart_model.TypedefReference(name: convert(o.name)) as T, front_end.TypeLiteral o => dart_model.TypeLiteral(typeAnnotation: convert(o.typeAnnotation)) as T, front_end.TypeReference o => dart_model.TypeReference() as T, diff --git a/pkgs/dart_model/lib/src/macro_metadata.g.dart b/pkgs/dart_model/lib/src/macro_metadata.g.dart index 09108589..e43ebfa2 100644 --- a/pkgs/dart_model/lib/src/macro_metadata.g.dart +++ b/pkgs/dart_model/lib/src/macro_metadata.g.dart @@ -18,18 +18,13 @@ enum ArgumentType { } extension type Argument.fromJson(Map node) implements Object { - static final TypedMapSchema _schema = TypedMapSchema({ - 'type': Type.stringPointer, - 'value': Type.anyPointer, - }); static Argument positionalArgument(PositionalArgument positionalArgument) => - Argument.fromJson( - Scope.createMap(_schema, 'PositionalArgument', positionalArgument), - ); + Argument.fromJson({ + 'type': 'PositionalArgument', + 'value': positionalArgument, + }); static Argument namedArgument(NamedArgument namedArgument) => - Argument.fromJson( - Scope.createMap(_schema, 'NamedArgument', namedArgument), - ); + Argument.fromJson({'type': 'NamedArgument', 'value': namedArgument}); ArgumentType get type { switch (node['type'] as String) { case 'PositionalArgument': @@ -68,23 +63,17 @@ enum ElementType { } extension type Element.fromJson(Map node) implements Object { - static final TypedMapSchema _schema = TypedMapSchema({ - 'type': Type.stringPointer, - 'value': Type.anyPointer, - }); static Element expressionElement(ExpressionElement expressionElement) => - Element.fromJson( - Scope.createMap(_schema, 'ExpressionElement', expressionElement), - ); + Element.fromJson({ + 'type': 'ExpressionElement', + 'value': expressionElement, + }); static Element mapEntryElement(MapEntryElement mapEntryElement) => - Element.fromJson( - Scope.createMap(_schema, 'MapEntryElement', mapEntryElement), - ); - static Element spreadElement(SpreadElement spreadElement) => Element.fromJson( - Scope.createMap(_schema, 'SpreadElement', spreadElement), - ); + Element.fromJson({'type': 'MapEntryElement', 'value': mapEntryElement}); + static Element spreadElement(SpreadElement spreadElement) => + Element.fromJson({'type': 'SpreadElement', 'value': spreadElement}); static Element ifElement(IfElement ifElement) => - Element.fromJson(Scope.createMap(_schema, 'IfElement', ifElement)); + Element.fromJson({'type': 'IfElement', 'value': ifElement}); ElementType get type { switch (node['type'] as String) { case 'ExpressionElement': @@ -171,136 +160,129 @@ enum ExpressionType { extension type Expression.fromJson(Map node) implements Object { - static final TypedMapSchema _schema = TypedMapSchema({ - 'type': Type.stringPointer, - 'value': Type.anyPointer, - }); static Expression invalidExpression(InvalidExpression invalidExpression) => - Expression.fromJson( - Scope.createMap(_schema, 'InvalidExpression', invalidExpression), - ); + Expression.fromJson({ + 'type': 'InvalidExpression', + 'value': invalidExpression, + }); static Expression staticGet(StaticGet staticGet) => - Expression.fromJson(Scope.createMap(_schema, 'StaticGet', staticGet)); + Expression.fromJson({'type': 'StaticGet', 'value': staticGet}); static Expression functionTearOff(FunctionTearOff functionTearOff) => - Expression.fromJson( - Scope.createMap(_schema, 'FunctionTearOff', functionTearOff), - ); + Expression.fromJson({ + 'type': 'FunctionTearOff', + 'value': functionTearOff, + }); static Expression constructorTearOff(ConstructorTearOff constructorTearOff) => - Expression.fromJson( - Scope.createMap(_schema, 'ConstructorTearOff', constructorTearOff), - ); + Expression.fromJson({ + 'type': 'ConstructorTearOff', + 'value': constructorTearOff, + }); static Expression constructorInvocation( ConstructorInvocation constructorInvocation, - ) => Expression.fromJson( - Scope.createMap(_schema, 'ConstructorInvocation', constructorInvocation), - ); + ) => Expression.fromJson({ + 'type': 'ConstructorInvocation', + 'value': constructorInvocation, + }); static Expression integerLiteral(IntegerLiteral integerLiteral) => - Expression.fromJson( - Scope.createMap(_schema, 'IntegerLiteral', integerLiteral), - ); + Expression.fromJson({'type': 'IntegerLiteral', 'value': integerLiteral}); static Expression doubleLiteral(DoubleLiteral doubleLiteral) => - Expression.fromJson( - Scope.createMap(_schema, 'DoubleLiteral', doubleLiteral), - ); + Expression.fromJson({'type': 'DoubleLiteral', 'value': doubleLiteral}); static Expression booleanLiteral(BooleanLiteral booleanLiteral) => - Expression.fromJson( - Scope.createMap(_schema, 'BooleanLiteral', booleanLiteral), - ); + Expression.fromJson({'type': 'BooleanLiteral', 'value': booleanLiteral}); static Expression nullLiteral(NullLiteral nullLiteral) => - Expression.fromJson(Scope.createMap(_schema, 'NullLiteral', nullLiteral)); + Expression.fromJson({'type': 'NullLiteral', 'value': nullLiteral}); static Expression symbolLiteral(SymbolLiteral symbolLiteral) => - Expression.fromJson( - Scope.createMap(_schema, 'SymbolLiteral', symbolLiteral), - ); + Expression.fromJson({'type': 'SymbolLiteral', 'value': symbolLiteral}); static Expression stringLiteral(StringLiteral stringLiteral) => - Expression.fromJson( - Scope.createMap(_schema, 'StringLiteral', stringLiteral), - ); + Expression.fromJson({'type': 'StringLiteral', 'value': stringLiteral}); static Expression adjacentStringLiterals( AdjacentStringLiterals adjacentStringLiterals, - ) => Expression.fromJson( - Scope.createMap(_schema, 'AdjacentStringLiterals', adjacentStringLiterals), - ); + ) => Expression.fromJson({ + 'type': 'AdjacentStringLiterals', + 'value': adjacentStringLiterals, + }); static Expression implicitInvocation(ImplicitInvocation implicitInvocation) => - Expression.fromJson( - Scope.createMap(_schema, 'ImplicitInvocation', implicitInvocation), - ); + Expression.fromJson({ + 'type': 'ImplicitInvocation', + 'value': implicitInvocation, + }); static Expression staticInvocation(StaticInvocation staticInvocation) => - Expression.fromJson( - Scope.createMap(_schema, 'StaticInvocation', staticInvocation), - ); + Expression.fromJson({ + 'type': 'StaticInvocation', + 'value': staticInvocation, + }); static Expression instantiation(Instantiation instantiation) => - Expression.fromJson( - Scope.createMap(_schema, 'Instantiation', instantiation), - ); + Expression.fromJson({'type': 'Instantiation', 'value': instantiation}); static Expression methodInvocation(MethodInvocation methodInvocation) => - Expression.fromJson( - Scope.createMap(_schema, 'MethodInvocation', methodInvocation), - ); + Expression.fromJson({ + 'type': 'MethodInvocation', + 'value': methodInvocation, + }); static Expression propertyGet(PropertyGet propertyGet) => - Expression.fromJson(Scope.createMap(_schema, 'PropertyGet', propertyGet)); + Expression.fromJson({'type': 'PropertyGet', 'value': propertyGet}); static Expression nullAwarePropertyGet( NullAwarePropertyGet nullAwarePropertyGet, - ) => Expression.fromJson( - Scope.createMap(_schema, 'NullAwarePropertyGet', nullAwarePropertyGet), - ); + ) => Expression.fromJson({ + 'type': 'NullAwarePropertyGet', + 'value': nullAwarePropertyGet, + }); static Expression typeLiteral(TypeLiteral typeLiteral) => - Expression.fromJson(Scope.createMap(_schema, 'TypeLiteral', typeLiteral)); + Expression.fromJson({'type': 'TypeLiteral', 'value': typeLiteral}); static Expression parenthesizedExpression( ParenthesizedExpression parenthesizedExpression, - ) => Expression.fromJson( - Scope.createMap( - _schema, - 'ParenthesizedExpression', - parenthesizedExpression, - ), - ); + ) => Expression.fromJson({ + 'type': 'ParenthesizedExpression', + 'value': parenthesizedExpression, + }); static Expression conditionalExpression( ConditionalExpression conditionalExpression, - ) => Expression.fromJson( - Scope.createMap(_schema, 'ConditionalExpression', conditionalExpression), - ); + ) => Expression.fromJson({ + 'type': 'ConditionalExpression', + 'value': conditionalExpression, + }); static Expression listLiteral(ListLiteral listLiteral) => - Expression.fromJson(Scope.createMap(_schema, 'ListLiteral', listLiteral)); + Expression.fromJson({'type': 'ListLiteral', 'value': listLiteral}); static Expression setOrMapLiteral(SetOrMapLiteral setOrMapLiteral) => - Expression.fromJson( - Scope.createMap(_schema, 'SetOrMapLiteral', setOrMapLiteral), - ); + Expression.fromJson({ + 'type': 'SetOrMapLiteral', + 'value': setOrMapLiteral, + }); static Expression recordLiteral(RecordLiteral recordLiteral) => - Expression.fromJson( - Scope.createMap(_schema, 'RecordLiteral', recordLiteral), - ); + Expression.fromJson({'type': 'RecordLiteral', 'value': recordLiteral}); static Expression ifNull(IfNull ifNull) => - Expression.fromJson(Scope.createMap(_schema, 'IfNull', ifNull)); + Expression.fromJson({'type': 'IfNull', 'value': ifNull}); static Expression logicalExpression(LogicalExpression logicalExpression) => - Expression.fromJson( - Scope.createMap(_schema, 'LogicalExpression', logicalExpression), - ); + Expression.fromJson({ + 'type': 'LogicalExpression', + 'value': logicalExpression, + }); static Expression equalityExpression(EqualityExpression equalityExpression) => - Expression.fromJson( - Scope.createMap(_schema, 'EqualityExpression', equalityExpression), - ); + Expression.fromJson({ + 'type': 'EqualityExpression', + 'value': equalityExpression, + }); static Expression binaryExpression(BinaryExpression binaryExpression) => - Expression.fromJson( - Scope.createMap(_schema, 'BinaryExpression', binaryExpression), - ); + Expression.fromJson({ + 'type': 'BinaryExpression', + 'value': binaryExpression, + }); static Expression unaryExpression(UnaryExpression unaryExpression) => - Expression.fromJson( - Scope.createMap(_schema, 'UnaryExpression', unaryExpression), - ); + Expression.fromJson({ + 'type': 'UnaryExpression', + 'value': unaryExpression, + }); static Expression isTest(IsTest isTest) => - Expression.fromJson(Scope.createMap(_schema, 'IsTest', isTest)); + Expression.fromJson({'type': 'IsTest', 'value': isTest}); static Expression asExpression(AsExpression asExpression) => - Expression.fromJson( - Scope.createMap(_schema, 'AsExpression', asExpression), - ); + Expression.fromJson({'type': 'AsExpression', 'value': asExpression}); static Expression nullCheck(NullCheck nullCheck) => - Expression.fromJson(Scope.createMap(_schema, 'NullCheck', nullCheck)); + Expression.fromJson({'type': 'NullCheck', 'value': nullCheck}); static Expression unresolvedExpression( UnresolvedExpression unresolvedExpression, - ) => Expression.fromJson( - Scope.createMap(_schema, 'UnresolvedExpression', unresolvedExpression), - ); + ) => Expression.fromJson({ + 'type': 'UnresolvedExpression', + 'value': unresolvedExpression, + }); ExpressionType get type { switch (node['type'] as String) { case 'InvalidExpression': @@ -625,19 +607,17 @@ enum RecordFieldType { extension type RecordField.fromJson(Map node) implements Object { - static final TypedMapSchema _schema = TypedMapSchema({ - 'type': Type.stringPointer, - 'value': Type.anyPointer, - }); static RecordField recordNamedField(RecordNamedField recordNamedField) => - RecordField.fromJson( - Scope.createMap(_schema, 'RecordNamedField', recordNamedField), - ); + RecordField.fromJson({ + 'type': 'RecordNamedField', + 'value': recordNamedField, + }); static RecordField recordPositionalField( RecordPositionalField recordPositionalField, - ) => RecordField.fromJson( - Scope.createMap(_schema, 'RecordPositionalField', recordPositionalField), - ); + ) => RecordField.fromJson({ + 'type': 'RecordPositionalField', + 'value': recordPositionalField, + }); RecordFieldType get type { switch (node['type'] as String) { case 'RecordNamedField': @@ -678,63 +658,56 @@ enum ReferenceType { extensionReference, extensionTypeReference, enumReference, + mixinReference, functionTypeParameterReference; bool get isKnown => this != _unknown; } extension type Reference.fromJson(Map node) implements Object { - static final TypedMapSchema _schema = TypedMapSchema({ - 'type': Type.stringPointer, - 'value': Type.anyPointer, - }); static Reference fieldReference(FieldReference fieldReference) => - Reference.fromJson( - Scope.createMap(_schema, 'FieldReference', fieldReference), - ); + Reference.fromJson({'type': 'FieldReference', 'value': fieldReference}); static Reference functionReference(FunctionReference functionReference) => - Reference.fromJson( - Scope.createMap(_schema, 'FunctionReference', functionReference), - ); + Reference.fromJson({ + 'type': 'FunctionReference', + 'value': functionReference, + }); static Reference constructorReference( ConstructorReference constructorReference, - ) => Reference.fromJson( - Scope.createMap(_schema, 'ConstructorReference', constructorReference), - ); + ) => Reference.fromJson({ + 'type': 'ConstructorReference', + 'value': constructorReference, + }); static Reference typeReference(TypeReference typeReference) => - Reference.fromJson( - Scope.createMap(_schema, 'TypeReference', typeReference), - ); + Reference.fromJson({'type': 'TypeReference', 'value': typeReference}); static Reference classReference(ClassReference classReference) => - Reference.fromJson( - Scope.createMap(_schema, 'ClassReference', classReference), - ); + Reference.fromJson({'type': 'ClassReference', 'value': classReference}); static Reference typedefReference(TypedefReference typedefReference) => - Reference.fromJson( - Scope.createMap(_schema, 'TypedefReference', typedefReference), - ); + Reference.fromJson({ + 'type': 'TypedefReference', + 'value': typedefReference, + }); static Reference extensionReference(ExtensionReference extensionReference) => - Reference.fromJson( - Scope.createMap(_schema, 'ExtensionReference', extensionReference), - ); + Reference.fromJson({ + 'type': 'ExtensionReference', + 'value': extensionReference, + }); static Reference extensionTypeReference( ExtensionTypeReference extensionTypeReference, - ) => Reference.fromJson( - Scope.createMap(_schema, 'ExtensionTypeReference', extensionTypeReference), - ); + ) => Reference.fromJson({ + 'type': 'ExtensionTypeReference', + 'value': extensionTypeReference, + }); static Reference enumReference(EnumReference enumReference) => - Reference.fromJson( - Scope.createMap(_schema, 'EnumReference', enumReference), - ); + Reference.fromJson({'type': 'EnumReference', 'value': enumReference}); + static Reference mixinReference(MixinReference mixinReference) => + Reference.fromJson({'type': 'MixinReference', 'value': mixinReference}); static Reference functionTypeParameterReference( FunctionTypeParameterReference functionTypeParameterReference, - ) => Reference.fromJson( - Scope.createMap( - _schema, - 'FunctionTypeParameterReference', - functionTypeParameterReference, - ), - ); + ) => Reference.fromJson({ + 'type': 'FunctionTypeParameterReference', + 'value': functionTypeParameterReference, + }); ReferenceType get type { switch (node['type'] as String) { case 'FieldReference': @@ -755,6 +728,8 @@ extension type Reference.fromJson(Map node) implements Object { return ReferenceType.extensionTypeReference; case 'EnumReference': return ReferenceType.enumReference; + case 'MixinReference': + return ReferenceType.mixinReference; case 'FunctionTypeParameterReference': return ReferenceType.functionTypeParameterReference; default: @@ -827,6 +802,13 @@ extension type Reference.fromJson(Map node) implements Object { return EnumReference.fromJson(node['value'] as Map); } + MixinReference get asMixinReference { + if (node['type'] != 'MixinReference') { + throw StateError('Not a MixinReference.'); + } + return MixinReference.fromJson(node['value'] as Map); + } + FunctionTypeParameterReference get asFunctionTypeParameterReference { if (node['type'] != 'FunctionTypeParameterReference') { throw StateError('Not a FunctionTypeParameterReference.'); @@ -848,19 +830,14 @@ enum StringLiteralPartType { extension type StringLiteralPart.fromJson(Map node) implements Object { - static final TypedMapSchema _schema = TypedMapSchema({ - 'type': Type.stringPointer, - 'value': Type.anyPointer, - }); static StringLiteralPart stringPart(StringPart stringPart) => - StringLiteralPart.fromJson( - Scope.createMap(_schema, 'StringPart', stringPart), - ); + StringLiteralPart.fromJson({'type': 'StringPart', 'value': stringPart}); static StringLiteralPart interpolationPart( InterpolationPart interpolationPart, - ) => StringLiteralPart.fromJson( - Scope.createMap(_schema, 'InterpolationPart', interpolationPart), - ); + ) => StringLiteralPart.fromJson({ + 'type': 'InterpolationPart', + 'value': interpolationPart, + }); StringLiteralPartType get type { switch (node['type'] as String) { case 'StringPart': @@ -905,63 +882,60 @@ enum TypeAnnotationType { extension type TypeAnnotation.fromJson(Map node) implements Object { - static final TypedMapSchema _schema = TypedMapSchema({ - 'type': Type.stringPointer, - 'value': Type.anyPointer, - }); static TypeAnnotation namedTypeAnnotation( NamedTypeAnnotation namedTypeAnnotation, - ) => TypeAnnotation.fromJson( - Scope.createMap(_schema, 'NamedTypeAnnotation', namedTypeAnnotation), - ); + ) => TypeAnnotation.fromJson({ + 'type': 'NamedTypeAnnotation', + 'value': namedTypeAnnotation, + }); static TypeAnnotation nullableTypeAnnotation( NullableTypeAnnotation nullableTypeAnnotation, - ) => TypeAnnotation.fromJson( - Scope.createMap(_schema, 'NullableTypeAnnotation', nullableTypeAnnotation), - ); + ) => TypeAnnotation.fromJson({ + 'type': 'NullableTypeAnnotation', + 'value': nullableTypeAnnotation, + }); static TypeAnnotation voidTypeAnnotation( VoidTypeAnnotation voidTypeAnnotation, - ) => TypeAnnotation.fromJson( - Scope.createMap(_schema, 'VoidTypeAnnotation', voidTypeAnnotation), - ); + ) => TypeAnnotation.fromJson({ + 'type': 'VoidTypeAnnotation', + 'value': voidTypeAnnotation, + }); static TypeAnnotation dynamicTypeAnnotation( DynamicTypeAnnotation dynamicTypeAnnotation, - ) => TypeAnnotation.fromJson( - Scope.createMap(_schema, 'DynamicTypeAnnotation', dynamicTypeAnnotation), - ); + ) => TypeAnnotation.fromJson({ + 'type': 'DynamicTypeAnnotation', + 'value': dynamicTypeAnnotation, + }); static TypeAnnotation invalidTypeAnnotation( InvalidTypeAnnotation invalidTypeAnnotation, - ) => TypeAnnotation.fromJson( - Scope.createMap(_schema, 'InvalidTypeAnnotation', invalidTypeAnnotation), - ); + ) => TypeAnnotation.fromJson({ + 'type': 'InvalidTypeAnnotation', + 'value': invalidTypeAnnotation, + }); static TypeAnnotation unresolvedTypeAnnotation( UnresolvedTypeAnnotation unresolvedTypeAnnotation, - ) => TypeAnnotation.fromJson( - Scope.createMap( - _schema, - 'UnresolvedTypeAnnotation', - unresolvedTypeAnnotation, - ), - ); + ) => TypeAnnotation.fromJson({ + 'type': 'UnresolvedTypeAnnotation', + 'value': unresolvedTypeAnnotation, + }); static TypeAnnotation functionTypeAnnotation( FunctionTypeAnnotation functionTypeAnnotation, - ) => TypeAnnotation.fromJson( - Scope.createMap(_schema, 'FunctionTypeAnnotation', functionTypeAnnotation), - ); + ) => TypeAnnotation.fromJson({ + 'type': 'FunctionTypeAnnotation', + 'value': functionTypeAnnotation, + }); static TypeAnnotation functionTypeParameterType( FunctionTypeParameterType functionTypeParameterType, - ) => TypeAnnotation.fromJson( - Scope.createMap( - _schema, - 'FunctionTypeParameterType', - functionTypeParameterType, - ), - ); + ) => TypeAnnotation.fromJson({ + 'type': 'FunctionTypeParameterType', + 'value': functionTypeParameterType, + }); static TypeAnnotation recordTypeAnnotation( RecordTypeAnnotation recordTypeAnnotation, - ) => TypeAnnotation.fromJson( - Scope.createMap(_schema, 'RecordTypeAnnotation', recordTypeAnnotation), - ); + ) => TypeAnnotation.fromJson({ + 'type': 'RecordTypeAnnotation', + 'value': recordTypeAnnotation, + }); TypeAnnotationType get type { switch (node['type'] as String) { case 'NamedTypeAnnotation': @@ -1112,15 +1086,24 @@ extension type const UnaryOperator.fromJson(String string) implements Object { static const UnaryOperator tilde = UnaryOperator.fromJson('tilde'); } +/// +extension type AdjacentStringLiterals.fromJson(Map node) + implements Object { + AdjacentStringLiterals({List? expressions}) + : this.fromJson({if (expressions != null) 'expressions': expressions}); + + /// + List get expressions => (node['expressions'] as List).cast(); +} + /// extension type AsExpression.fromJson(Map node) implements Object { - static final TypedMapSchema _schema = TypedMapSchema({ - 'expression': Type.typedMapPointer, - 'type': Type.typedMapPointer, - }); AsExpression({Expression? expression, TypeAnnotation? type}) - : this.fromJson(Scope.createMap(_schema, expression, type)); + : this.fromJson({ + if (expression != null) 'expression': expression, + if (type != null) 'type': type, + }); /// Expression get expression => node['expression'] as Expression; @@ -1132,16 +1115,15 @@ extension type AsExpression.fromJson(Map node) /// extension type BinaryExpression.fromJson(Map node) implements Object { - static final TypedMapSchema _schema = TypedMapSchema({ - 'left': Type.typedMapPointer, - 'operator': Type.stringPointer, - 'right': Type.typedMapPointer, - }); BinaryExpression({ Expression? left, BinaryOperator? operator, Expression? right, - }) : this.fromJson(Scope.createMap(_schema, left, operator, right)); + }) : this.fromJson({ + if (left != null) 'left': left, + if (operator != null) 'operator': operator, + if (right != null) 'right': right, + }); /// Expression get left => node['left'] as Expression; @@ -1156,36 +1138,35 @@ extension type BinaryExpression.fromJson(Map node) /// extension type BooleanLiteral.fromJson(Map node) implements Object { - static final TypedMapSchema _schema = TypedMapSchema({ - 'text': Type.stringPointer, - }); - BooleanLiteral({String? text}) - : this.fromJson(Scope.createMap(_schema, text)); + BooleanLiteral({bool? value}) + : this.fromJson({if (value != null) 'value': value}); /// - String get text => node['text'] as String; + bool get value => node['value'] as bool; } /// extension type ClassReference.fromJson(Map node) implements Object { - static final TypedMapSchema _schema = TypedMapSchema({}); - ClassReference() : this.fromJson(Scope.createMap(_schema)); + ClassReference({String? name}) + : this.fromJson({if (name != null) 'name': name}); + + /// + String get name => node['name'] as String; } /// extension type ConditionalExpression.fromJson(Map node) implements Object { - static final TypedMapSchema _schema = TypedMapSchema({ - 'condition': Type.typedMapPointer, - 'then': Type.typedMapPointer, - 'otherwise': Type.typedMapPointer, - }); ConditionalExpression({ Expression? condition, Expression? then, Expression? otherwise, - }) : this.fromJson(Scope.createMap(_schema, condition, then, otherwise)); + }) : this.fromJson({ + if (condition != null) 'condition': condition, + if (then != null) 'then': then, + if (otherwise != null) 'otherwise': otherwise, + }); /// Expression get condition => node['condition'] as Expression; @@ -1200,16 +1181,15 @@ extension type ConditionalExpression.fromJson(Map node) /// extension type ConstructorInvocation.fromJson(Map node) implements Object { - static final TypedMapSchema _schema = TypedMapSchema({ - 'type': Type.typedMapPointer, - 'constructor': Type.typedMapPointer, - 'arguments': Type.closedListPointer, - }); ConstructorInvocation({ TypeAnnotation? type, Reference? constructor, List? arguments, - }) : this.fromJson(Scope.createMap(_schema, type, constructor, arguments)); + }) : this.fromJson({ + if (type != null) 'type': type, + if (constructor != null) 'constructor': constructor, + if (arguments != null) 'arguments': arguments, + }); /// TypeAnnotation get type => node['type'] as TypeAnnotation; @@ -1224,19 +1204,21 @@ extension type ConstructorInvocation.fromJson(Map node) /// extension type ConstructorReference.fromJson(Map node) implements Object { - static final TypedMapSchema _schema = TypedMapSchema({}); - ConstructorReference() : this.fromJson(Scope.createMap(_schema)); + ConstructorReference({String? name}) + : this.fromJson({if (name != null) 'name': name}); + + /// + String get name => node['name'] as String; } /// extension type ConstructorTearOff.fromJson(Map node) implements Object { - static final TypedMapSchema _schema = TypedMapSchema({ - 'type': Type.typedMapPointer, - 'reference': Type.typedMapPointer, - }); ConstructorTearOff({TypeAnnotation? type, ConstructorReference? reference}) - : this.fromJson(Scope.createMap(_schema, type, reference)); + : this.fromJson({ + if (type != null) 'type': type, + if (reference != null) 'reference': reference, + }); /// TypeAnnotation get type => node['type'] as TypeAnnotation; @@ -1249,23 +1231,24 @@ extension type ConstructorTearOff.fromJson(Map node) /// extension type DoubleLiteral.fromJson(Map node) implements Object { - static final TypedMapSchema _schema = TypedMapSchema({ - 'text': Type.stringPointer, - }); - DoubleLiteral({String? text}) : this.fromJson(Scope.createMap(_schema, text)); + DoubleLiteral({String? text, double? value}) + : this.fromJson({ + if (text != null) 'text': text, + if (value != null) 'value': value, + }); /// String get text => node['text'] as String; + + /// + double get value => node['value'] as double; } /// extension type DynamicTypeAnnotation.fromJson(Map node) implements Object { - static final TypedMapSchema _schema = TypedMapSchema({ - 'reference': Type.typedMapPointer, - }); DynamicTypeAnnotation({Reference? reference}) - : this.fromJson(Scope.createMap(_schema, reference)); + : this.fromJson({if (reference != null) 'reference': reference}); /// Reference get reference => node['reference'] as Reference; @@ -1274,20 +1257,22 @@ extension type DynamicTypeAnnotation.fromJson(Map node) /// extension type EnumReference.fromJson(Map node) implements Object { - static final TypedMapSchema _schema = TypedMapSchema({}); - EnumReference() : this.fromJson(Scope.createMap(_schema)); + EnumReference({String? name}) + : this.fromJson({if (name != null) 'name': name}); + + /// + String get name => node['name'] as String; } /// extension type EqualityExpression.fromJson(Map node) implements Object { - static final TypedMapSchema _schema = TypedMapSchema({ - 'left': Type.typedMapPointer, - 'right': Type.typedMapPointer, - 'isNotEquals': Type.boolean, - }); EqualityExpression({Expression? left, Expression? right, bool? isNotEquals}) - : this.fromJson(Scope.createMap(_schema, left, right, isNotEquals)); + : this.fromJson({ + if (left != null) 'left': left, + if (right != null) 'right': right, + if (isNotEquals != null) 'isNotEquals': isNotEquals, + }); /// Expression get left => node['left'] as Expression; @@ -1302,12 +1287,11 @@ extension type EqualityExpression.fromJson(Map node) /// extension type ExpressionElement.fromJson(Map node) implements Object { - static final TypedMapSchema _schema = TypedMapSchema({ - 'expression': Type.typedMapPointer, - 'isNullAware': Type.boolean, - }); ExpressionElement({Expression? expression, bool? isNullAware}) - : this.fromJson(Scope.createMap(_schema, expression, isNullAware)); + : this.fromJson({ + if (expression != null) 'expression': expression, + if (isNullAware != null) 'isNullAware': isNullAware, + }); /// Expression get expression => node['expression'] as Expression; @@ -1319,53 +1303,60 @@ extension type ExpressionElement.fromJson(Map node) /// extension type ExtensionReference.fromJson(Map node) implements Object { - static final TypedMapSchema _schema = TypedMapSchema({}); - ExtensionReference() : this.fromJson(Scope.createMap(_schema)); + ExtensionReference({String? name}) + : this.fromJson({if (name != null) 'name': name}); + + /// + String get name => node['name'] as String; } /// extension type ExtensionTypeReference.fromJson(Map node) implements Object { - static final TypedMapSchema _schema = TypedMapSchema({}); - ExtensionTypeReference() : this.fromJson(Scope.createMap(_schema)); + ExtensionTypeReference({String? name}) + : this.fromJson({if (name != null) 'name': name}); + + /// + String get name => node['name'] as String; } /// extension type FieldReference.fromJson(Map node) implements Object { - static final TypedMapSchema _schema = TypedMapSchema({}); - FieldReference() : this.fromJson(Scope.createMap(_schema)); + FieldReference({String? name}) + : this.fromJson({if (name != null) 'name': name}); + + /// + String get name => node['name'] as String; } /// extension type FormalParameter.fromJson(Map node) implements Object { - static final TypedMapSchema _schema = TypedMapSchema({}); - FormalParameter() : this.fromJson(Scope.createMap(_schema)); + FormalParameter() : this.fromJson({}); } /// extension type FormalParameterGroup.fromJson(Map node) implements Object { - static final TypedMapSchema _schema = TypedMapSchema({}); - FormalParameterGroup() : this.fromJson(Scope.createMap(_schema)); + FormalParameterGroup() : this.fromJson({}); } /// extension type FunctionReference.fromJson(Map node) implements Object { - static final TypedMapSchema _schema = TypedMapSchema({}); - FunctionReference() : this.fromJson(Scope.createMap(_schema)); + FunctionReference({String? name}) + : this.fromJson({if (name != null) 'name': name}); + + /// + String get name => node['name'] as String; } /// extension type FunctionTearOff.fromJson(Map node) implements Object { - static final TypedMapSchema _schema = TypedMapSchema({ - 'reference': Type.typedMapPointer, - }); FunctionTearOff({FunctionReference? reference}) - : this.fromJson(Scope.createMap(_schema, reference)); + : this.fromJson({if (reference != null) 'reference': reference}); /// FunctionReference get reference => node['reference'] as FunctionReference; @@ -1374,18 +1365,15 @@ extension type FunctionTearOff.fromJson(Map node) /// extension type FunctionTypeAnnotation.fromJson(Map node) implements Object { - static final TypedMapSchema _schema = TypedMapSchema({ - 'returnType': Type.typedMapPointer, - 'typeParameters': Type.closedListPointer, - 'formalParameters': Type.closedListPointer, - }); FunctionTypeAnnotation({ TypeAnnotation? returnType, List? typeParameters, List? formalParameters, - }) : this.fromJson( - Scope.createMap(_schema, returnType, typeParameters, formalParameters), - ); + }) : this.fromJson({ + if (returnType != null) 'returnType': returnType, + if (typeParameters != null) 'typeParameters': typeParameters, + if (formalParameters != null) 'formalParameters': formalParameters, + }); /// TypeAnnotation? get returnType => node['returnType'] as TypeAnnotation?; @@ -1402,8 +1390,7 @@ extension type FunctionTypeAnnotation.fromJson(Map node) /// extension type FunctionTypeParameter.fromJson(Map node) implements Object { - static final TypedMapSchema _schema = TypedMapSchema({}); - FunctionTypeParameter() : this.fromJson(Scope.createMap(_schema)); + FunctionTypeParameter() : this.fromJson({}); } /// @@ -1411,18 +1398,21 @@ extension type FunctionTypeParameterReference.fromJson( Map node ) implements Object { - static final TypedMapSchema _schema = TypedMapSchema({}); - FunctionTypeParameterReference() : this.fromJson(Scope.createMap(_schema)); + FunctionTypeParameterReference({String? name}) + : this.fromJson({if (name != null) 'name': name}); + + /// + String get name => node['name'] as String; } /// extension type FunctionTypeParameterType.fromJson(Map node) implements Object { - static final TypedMapSchema _schema = TypedMapSchema({ - 'functionTypeParameter': Type.typedMapPointer, - }); FunctionTypeParameterType({FunctionTypeParameter? functionTypeParameter}) - : this.fromJson(Scope.createMap(_schema, functionTypeParameter)); + : this.fromJson({ + if (functionTypeParameter != null) + 'functionTypeParameter': functionTypeParameter, + }); /// FunctionTypeParameter get functionTypeParameter => @@ -1431,13 +1421,12 @@ extension type FunctionTypeParameterType.fromJson(Map node) /// extension type IfElement.fromJson(Map node) implements Object { - static final TypedMapSchema _schema = TypedMapSchema({ - 'condition': Type.typedMapPointer, - 'then': Type.typedMapPointer, - 'otherwise': Type.typedMapPointer, - }); IfElement({Expression? condition, Element? then, Element? otherwise}) - : this.fromJson(Scope.createMap(_schema, condition, then, otherwise)); + : this.fromJson({ + if (condition != null) 'condition': condition, + if (then != null) 'then': then, + if (otherwise != null) 'otherwise': otherwise, + }); /// Expression get condition => node['condition'] as Expression; @@ -1451,12 +1440,11 @@ extension type IfElement.fromJson(Map node) implements Object { /// extension type IfNull.fromJson(Map node) implements Object { - static final TypedMapSchema _schema = TypedMapSchema({ - 'left': Type.typedMapPointer, - 'right': Type.typedMapPointer, - }); IfNull({Expression? left, Expression? right}) - : this.fromJson(Scope.createMap(_schema, left, right)); + : this.fromJson({ + if (left != null) 'left': left, + if (right != null) 'right': right, + }); /// Expression get left => node['left'] as Expression; @@ -1468,18 +1456,15 @@ extension type IfNull.fromJson(Map node) implements Object { /// extension type ImplicitInvocation.fromJson(Map node) implements Object { - static final TypedMapSchema _schema = TypedMapSchema({ - 'receiver': Type.typedMapPointer, - 'typeArguments': Type.closedListPointer, - 'arguments': Type.closedListPointer, - }); ImplicitInvocation({ Expression? receiver, List? typeArguments, List? arguments, - }) : this.fromJson( - Scope.createMap(_schema, receiver, typeArguments, arguments), - ); + }) : this.fromJson({ + if (receiver != null) 'receiver': receiver, + if (typeArguments != null) 'typeArguments': typeArguments, + if (arguments != null) 'arguments': arguments, + }); /// Expression get receiver => node['receiver'] as Expression; @@ -1495,12 +1480,11 @@ extension type ImplicitInvocation.fromJson(Map node) /// extension type Instantiation.fromJson(Map node) implements Object { - static final TypedMapSchema _schema = TypedMapSchema({ - 'receiver': Type.typedMapPointer, - 'typeArguments': Type.closedListPointer, - }); Instantiation({Expression? receiver, List? typeArguments}) - : this.fromJson(Scope.createMap(_schema, receiver, typeArguments)); + : this.fromJson({ + if (receiver != null) 'receiver': receiver, + if (typeArguments != null) 'typeArguments': typeArguments, + }); /// Expression get receiver => node['receiver'] as Expression; @@ -1513,24 +1497,24 @@ extension type Instantiation.fromJson(Map node) /// extension type IntegerLiteral.fromJson(Map node) implements Object { - static final TypedMapSchema _schema = TypedMapSchema({ - 'text': Type.stringPointer, - }); - IntegerLiteral({String? text}) - : this.fromJson(Scope.createMap(_schema, text)); + IntegerLiteral({String? text, int? value}) + : this.fromJson({ + if (text != null) 'text': text, + if (value != null) 'value': value, + }); /// - String get text => node['text'] as String; + String? get text => node['text'] as String?; + + /// + int? get value => node['value'] as int?; } /// extension type InterpolationPart.fromJson(Map node) implements Object { - static final TypedMapSchema _schema = TypedMapSchema({ - 'expression': Type.typedMapPointer, - }); InterpolationPart({Expression? expression}) - : this.fromJson(Scope.createMap(_schema, expression)); + : this.fromJson({if (expression != null) 'expression': expression}); /// Expression get expression => node['expression'] as Expression; @@ -1539,26 +1523,23 @@ extension type InterpolationPart.fromJson(Map node) /// extension type InvalidExpression.fromJson(Map node) implements Object { - static final TypedMapSchema _schema = TypedMapSchema({}); - InvalidExpression() : this.fromJson(Scope.createMap(_schema)); + InvalidExpression() : this.fromJson({}); } /// extension type InvalidTypeAnnotation.fromJson(Map node) implements Object { - static final TypedMapSchema _schema = TypedMapSchema({}); - InvalidTypeAnnotation() : this.fromJson(Scope.createMap(_schema)); + InvalidTypeAnnotation() : this.fromJson({}); } /// extension type IsTest.fromJson(Map node) implements Object { - static final TypedMapSchema _schema = TypedMapSchema({ - 'expression': Type.typedMapPointer, - 'type': Type.typedMapPointer, - 'isNot': Type.boolean, - }); IsTest({Expression? expression, TypeAnnotation? type, bool? isNot}) - : this.fromJson(Scope.createMap(_schema, expression, type, isNot)); + : this.fromJson({ + if (expression != null) 'expression': expression, + if (type != null) 'type': type, + if (isNot != null) 'isNot': isNot, + }); /// Expression get expression => node['expression'] as Expression; @@ -1573,12 +1554,11 @@ extension type IsTest.fromJson(Map node) implements Object { /// extension type ListLiteral.fromJson(Map node) implements Object { - static final TypedMapSchema _schema = TypedMapSchema({ - 'typeArguments': Type.closedListPointer, - 'elements': Type.closedListPointer, - }); ListLiteral({List? typeArguments, List? elements}) - : this.fromJson(Scope.createMap(_schema, typeArguments, elements)); + : this.fromJson({ + if (typeArguments != null) 'typeArguments': typeArguments, + if (elements != null) 'elements': elements, + }); /// List get typeArguments => @@ -1591,16 +1571,15 @@ extension type ListLiteral.fromJson(Map node) /// extension type LogicalExpression.fromJson(Map node) implements Object { - static final TypedMapSchema _schema = TypedMapSchema({ - 'left': Type.typedMapPointer, - 'operator': Type.stringPointer, - 'right': Type.typedMapPointer, - }); LogicalExpression({ Expression? left, LogicalOperator? operator, Expression? right, - }) : this.fromJson(Scope.createMap(_schema, left, operator, right)); + }) : this.fromJson({ + if (left != null) 'left': left, + if (operator != null) 'operator': operator, + if (right != null) 'right': right, + }); /// Expression get left => node['left'] as Expression; @@ -1615,20 +1594,17 @@ extension type LogicalExpression.fromJson(Map node) /// extension type MapEntryElement.fromJson(Map node) implements Object { - static final TypedMapSchema _schema = TypedMapSchema({ - 'key': Type.typedMapPointer, - 'value': Type.typedMapPointer, - 'isNullAwareKey': Type.boolean, - 'isNullAwareValue': Type.boolean, - }); MapEntryElement({ Expression? key, Expression? value, bool? isNullAwareKey, bool? isNullAwareValue, - }) : this.fromJson( - Scope.createMap(_schema, key, value, isNullAwareKey, isNullAwareValue), - ); + }) : this.fromJson({ + if (key != null) 'key': key, + if (value != null) 'value': value, + if (isNullAwareKey != null) 'isNullAwareKey': isNullAwareKey, + if (isNullAwareValue != null) 'isNullAwareValue': isNullAwareValue, + }); /// Expression get key => node['key'] as Expression; @@ -1646,20 +1622,17 @@ extension type MapEntryElement.fromJson(Map node) /// extension type MethodInvocation.fromJson(Map node) implements Object { - static final TypedMapSchema _schema = TypedMapSchema({ - 'receiver': Type.typedMapPointer, - 'name': Type.stringPointer, - 'typeArguments': Type.closedListPointer, - 'arguments': Type.closedListPointer, - }); MethodInvocation({ Expression? receiver, String? name, List? typeArguments, List? arguments, - }) : this.fromJson( - Scope.createMap(_schema, receiver, name, typeArguments, arguments), - ); + }) : this.fromJson({ + if (receiver != null) 'receiver': receiver, + if (name != null) 'name': name, + if (typeArguments != null) 'typeArguments': typeArguments, + if (arguments != null) 'arguments': arguments, + }); /// Expression get receiver => node['receiver'] as Expression; @@ -1675,15 +1648,24 @@ extension type MethodInvocation.fromJson(Map node) List get arguments => (node['arguments'] as List).cast(); } +/// +extension type MixinReference.fromJson(Map node) + implements Object { + MixinReference({String? name}) + : this.fromJson({if (name != null) 'name': name}); + + /// + String get name => node['name'] as String; +} + /// extension type NamedArgument.fromJson(Map node) implements Object { - static final TypedMapSchema _schema = TypedMapSchema({ - 'name': Type.stringPointer, - 'expression': Type.typedMapPointer, - }); NamedArgument({String? name, Expression? expression}) - : this.fromJson(Scope.createMap(_schema, name, expression)); + : this.fromJson({ + if (name != null) 'name': name, + if (expression != null) 'expression': expression, + }); /// String get name => node['name'] as String; @@ -1695,14 +1677,13 @@ extension type NamedArgument.fromJson(Map node) /// extension type NamedTypeAnnotation.fromJson(Map node) implements Object { - static final TypedMapSchema _schema = TypedMapSchema({ - 'reference': Type.typedMapPointer, - 'typeArguments': Type.closedListPointer, - }); NamedTypeAnnotation({ Reference? reference, List? typeArguments, - }) : this.fromJson(Scope.createMap(_schema, reference, typeArguments)); + }) : this.fromJson({ + if (reference != null) 'reference': reference, + if (typeArguments != null) 'typeArguments': typeArguments, + }); /// Reference get reference => node['reference'] as Reference; @@ -1715,11 +1696,10 @@ extension type NamedTypeAnnotation.fromJson(Map node) /// extension type NullableTypeAnnotation.fromJson(Map node) implements Object { - static final TypedMapSchema _schema = TypedMapSchema({ - 'typeAnnotation': Type.typedMapPointer, - }); NullableTypeAnnotation({TypeAnnotation? typeAnnotation}) - : this.fromJson(Scope.createMap(_schema, typeAnnotation)); + : this.fromJson({ + if (typeAnnotation != null) 'typeAnnotation': typeAnnotation, + }); /// TypeAnnotation get typeAnnotation => node['typeAnnotation'] as TypeAnnotation; @@ -1728,12 +1708,11 @@ extension type NullableTypeAnnotation.fromJson(Map node) /// extension type NullAwarePropertyGet.fromJson(Map node) implements Object { - static final TypedMapSchema _schema = TypedMapSchema({ - 'receiver': Type.typedMapPointer, - 'name': Type.stringPointer, - }); NullAwarePropertyGet({Expression? receiver, String? name}) - : this.fromJson(Scope.createMap(_schema, receiver, name)); + : this.fromJson({ + if (receiver != null) 'receiver': receiver, + if (name != null) 'name': name, + }); /// Expression get receiver => node['receiver'] as Expression; @@ -1744,11 +1723,8 @@ extension type NullAwarePropertyGet.fromJson(Map node) /// extension type NullCheck.fromJson(Map node) implements Object { - static final TypedMapSchema _schema = TypedMapSchema({ - 'expression': Type.typedMapPointer, - }); NullCheck({Expression? expression}) - : this.fromJson(Scope.createMap(_schema, expression)); + : this.fromJson({if (expression != null) 'expression': expression}); /// Expression get expression => node['expression'] as Expression; @@ -1757,18 +1733,14 @@ extension type NullCheck.fromJson(Map node) implements Object { /// extension type NullLiteral.fromJson(Map node) implements Object { - static final TypedMapSchema _schema = TypedMapSchema({}); - NullLiteral() : this.fromJson(Scope.createMap(_schema)); + NullLiteral() : this.fromJson({}); } /// extension type ParenthesizedExpression.fromJson(Map node) implements Object { - static final TypedMapSchema _schema = TypedMapSchema({ - 'expression': Type.typedMapPointer, - }); ParenthesizedExpression({Expression? expression}) - : this.fromJson(Scope.createMap(_schema, expression)); + : this.fromJson({if (expression != null) 'expression': expression}); /// Expression get expression => node['expression'] as Expression; @@ -1777,11 +1749,8 @@ extension type ParenthesizedExpression.fromJson(Map node) /// extension type PositionalArgument.fromJson(Map node) implements Object { - static final TypedMapSchema _schema = TypedMapSchema({ - 'expression': Type.typedMapPointer, - }); PositionalArgument({Expression? expression}) - : this.fromJson(Scope.createMap(_schema, expression)); + : this.fromJson({if (expression != null) 'expression': expression}); /// Expression get expression => node['expression'] as Expression; @@ -1790,12 +1759,11 @@ extension type PositionalArgument.fromJson(Map node) /// extension type PropertyGet.fromJson(Map node) implements Object { - static final TypedMapSchema _schema = TypedMapSchema({ - 'receiver': Type.typedMapPointer, - 'name': Type.stringPointer, - }); PropertyGet({Expression? receiver, String? name}) - : this.fromJson(Scope.createMap(_schema, receiver, name)); + : this.fromJson({ + if (receiver != null) 'receiver': receiver, + if (name != null) 'name': name, + }); /// Expression get receiver => node['receiver'] as Expression; @@ -1807,11 +1775,8 @@ extension type PropertyGet.fromJson(Map node) /// extension type RecordLiteral.fromJson(Map node) implements Object { - static final TypedMapSchema _schema = TypedMapSchema({ - 'fields': Type.closedListPointer, - }); RecordLiteral({List? fields}) - : this.fromJson(Scope.createMap(_schema, fields)); + : this.fromJson({if (fields != null) 'fields': fields}); /// List get fields => (node['fields'] as List).cast(); @@ -1820,12 +1785,11 @@ extension type RecordLiteral.fromJson(Map node) /// extension type RecordNamedField.fromJson(Map node) implements Object { - static final TypedMapSchema _schema = TypedMapSchema({ - 'name': Type.stringPointer, - 'expression': Type.typedMapPointer, - }); RecordNamedField({String? name, Expression? expression}) - : this.fromJson(Scope.createMap(_schema, name, expression)); + : this.fromJson({ + if (name != null) 'name': name, + if (expression != null) 'expression': expression, + }); /// String get name => node['name'] as String; @@ -1837,11 +1801,8 @@ extension type RecordNamedField.fromJson(Map node) /// extension type RecordPositionalField.fromJson(Map node) implements Object { - static final TypedMapSchema _schema = TypedMapSchema({ - 'expression': Type.typedMapPointer, - }); RecordPositionalField({Expression? expression}) - : this.fromJson(Scope.createMap(_schema, expression)); + : this.fromJson({if (expression != null) 'expression': expression}); /// Expression get expression => node['expression'] as Expression; @@ -1850,14 +1811,13 @@ extension type RecordPositionalField.fromJson(Map node) /// extension type RecordTypeAnnotation.fromJson(Map node) implements Object { - static final TypedMapSchema _schema = TypedMapSchema({ - 'positional': Type.closedListPointer, - 'named': Type.closedListPointer, - }); RecordTypeAnnotation({ List? positional, List? named, - }) : this.fromJson(Scope.createMap(_schema, positional, named)); + }) : this.fromJson({ + if (positional != null) 'positional': positional, + if (named != null) 'named': named, + }); /// List get positional => (node['positional'] as List).cast(); @@ -1869,28 +1829,25 @@ extension type RecordTypeAnnotation.fromJson(Map node) /// extension type RecordTypeEntry.fromJson(Map node) implements Object { - static final TypedMapSchema _schema = TypedMapSchema({}); - RecordTypeEntry() : this.fromJson(Scope.createMap(_schema)); + RecordTypeEntry() : this.fromJson({}); } /// extension type References.fromJson(Map node) implements Object { - static final TypedMapSchema _schema = TypedMapSchema({}); - References() : this.fromJson(Scope.createMap(_schema)); + References() : this.fromJson({}); } /// extension type SetOrMapLiteral.fromJson(Map node) implements Object { - static final TypedMapSchema _schema = TypedMapSchema({ - 'typeArguments': Type.closedListPointer, - 'elements': Type.closedListPointer, - }); SetOrMapLiteral({ List? typeArguments, List? elements, - }) : this.fromJson(Scope.createMap(_schema, typeArguments, elements)); + }) : this.fromJson({ + if (typeArguments != null) 'typeArguments': typeArguments, + if (elements != null) 'elements': elements, + }); /// List get typeArguments => @@ -1903,12 +1860,11 @@ extension type SetOrMapLiteral.fromJson(Map node) /// extension type SpreadElement.fromJson(Map node) implements Object { - static final TypedMapSchema _schema = TypedMapSchema({ - 'expression': Type.typedMapPointer, - 'isNullAware': Type.boolean, - }); SpreadElement({Expression? expression, bool? isNullAware}) - : this.fromJson(Scope.createMap(_schema, expression, isNullAware)); + : this.fromJson({ + if (expression != null) 'expression': expression, + if (isNullAware != null) 'isNullAware': isNullAware, + }); /// Expression get expression => node['expression'] as Expression; @@ -1919,11 +1875,8 @@ extension type SpreadElement.fromJson(Map node) /// extension type StaticGet.fromJson(Map node) implements Object { - static final TypedMapSchema _schema = TypedMapSchema({ - 'reference': Type.typedMapPointer, - }); StaticGet({FieldReference? reference}) - : this.fromJson(Scope.createMap(_schema, reference)); + : this.fromJson({if (reference != null) 'reference': reference}); /// FieldReference get reference => node['reference'] as FieldReference; @@ -1932,18 +1885,15 @@ extension type StaticGet.fromJson(Map node) implements Object { /// extension type StaticInvocation.fromJson(Map node) implements Object { - static final TypedMapSchema _schema = TypedMapSchema({ - 'function': Type.typedMapPointer, - 'typeArguments': Type.closedListPointer, - 'arguments': Type.closedListPointer, - }); StaticInvocation({ FunctionReference? function, List? typeArguments, List? arguments, - }) : this.fromJson( - Scope.createMap(_schema, function, typeArguments, arguments), - ); + }) : this.fromJson({ + if (function != null) 'function': function, + if (typeArguments != null) 'typeArguments': typeArguments, + if (arguments != null) 'arguments': arguments, + }); /// FunctionReference get function => node['function'] as FunctionReference; @@ -1956,27 +1906,11 @@ extension type StaticInvocation.fromJson(Map node) List get arguments => (node['arguments'] as List).cast(); } -/// -extension type AdjacentStringLiterals.fromJson(Map node) - implements Object { - static final TypedMapSchema _schema = TypedMapSchema({ - 'expressions': Type.closedListPointer, - }); - AdjacentStringLiterals({List? expressions}) - : this.fromJson(Scope.createMap(_schema, expressions)); - - /// - List get expressions => (node['expressions'] as List).cast(); -} - /// extension type StringLiteral.fromJson(Map node) implements Object { - static final TypedMapSchema _schema = TypedMapSchema({ - 'parts': Type.closedListPointer, - }); StringLiteral({List? parts}) - : this.fromJson(Scope.createMap(_schema, parts)); + : this.fromJson({if (parts != null) 'parts': parts}); /// List get parts => (node['parts'] as List).cast(); @@ -1985,10 +1919,7 @@ extension type StringLiteral.fromJson(Map node) /// extension type StringPart.fromJson(Map node) implements Object { - static final TypedMapSchema _schema = TypedMapSchema({ - 'text': Type.stringPointer, - }); - StringPart({String? text}) : this.fromJson(Scope.createMap(_schema, text)); + StringPart({String? text}) : this.fromJson({if (text != null) 'text': text}); /// String get text => node['text'] as String; @@ -1997,11 +1928,8 @@ extension type StringPart.fromJson(Map node) /// extension type SymbolLiteral.fromJson(Map node) implements Object { - static final TypedMapSchema _schema = TypedMapSchema({ - 'parts': Type.closedListPointer, - }); SymbolLiteral({List? parts}) - : this.fromJson(Scope.createMap(_schema, parts)); + : this.fromJson({if (parts != null) 'parts': parts}); /// List get parts => (node['parts'] as List).cast(); @@ -2010,18 +1938,20 @@ extension type SymbolLiteral.fromJson(Map node) /// extension type TypedefReference.fromJson(Map node) implements Object { - static final TypedMapSchema _schema = TypedMapSchema({}); - TypedefReference() : this.fromJson(Scope.createMap(_schema)); + TypedefReference({String? name}) + : this.fromJson({if (name != null) 'name': name}); + + /// + String get name => node['name'] as String; } /// extension type TypeLiteral.fromJson(Map node) implements Object { - static final TypedMapSchema _schema = TypedMapSchema({ - 'typeAnnotation': Type.typedMapPointer, - }); TypeLiteral({TypeAnnotation? typeAnnotation}) - : this.fromJson(Scope.createMap(_schema, typeAnnotation)); + : this.fromJson({ + if (typeAnnotation != null) 'typeAnnotation': typeAnnotation, + }); /// TypeAnnotation get typeAnnotation => node['typeAnnotation'] as TypeAnnotation; @@ -2030,19 +1960,17 @@ extension type TypeLiteral.fromJson(Map node) /// extension type TypeReference.fromJson(Map node) implements Object { - static final TypedMapSchema _schema = TypedMapSchema({}); - TypeReference() : this.fromJson(Scope.createMap(_schema)); + TypeReference() : this.fromJson({}); } /// extension type UnaryExpression.fromJson(Map node) implements Object { - static final TypedMapSchema _schema = TypedMapSchema({ - 'operator': Type.stringPointer, - 'expression': Type.typedMapPointer, - }); UnaryExpression({UnaryOperator? operator, Expression? expression}) - : this.fromJson(Scope.createMap(_schema, operator, expression)); + : this.fromJson({ + if (operator != null) 'operator': operator, + if (expression != null) 'expression': expression, + }); /// UnaryOperator get operator => node['operator'] as UnaryOperator; @@ -2054,25 +1982,20 @@ extension type UnaryExpression.fromJson(Map node) /// extension type UnresolvedExpression.fromJson(Map node) implements Object { - static final TypedMapSchema _schema = TypedMapSchema({}); - UnresolvedExpression() : this.fromJson(Scope.createMap(_schema)); + UnresolvedExpression() : this.fromJson({}); } /// extension type UnresolvedTypeAnnotation.fromJson(Map node) implements Object { - static final TypedMapSchema _schema = TypedMapSchema({}); - UnresolvedTypeAnnotation() : this.fromJson(Scope.createMap(_schema)); + UnresolvedTypeAnnotation() : this.fromJson({}); } /// extension type VoidTypeAnnotation.fromJson(Map node) implements Object { - static final TypedMapSchema _schema = TypedMapSchema({ - 'reference': Type.typedMapPointer, - }); VoidTypeAnnotation({Reference? reference}) - : this.fromJson(Scope.createMap(_schema, reference)); + : this.fromJson({if (reference != null) 'reference': reference}); /// Reference get reference => node['reference'] as Reference; diff --git a/schemas/macro_metadata.schema.json b/schemas/macro_metadata.schema.json index 5547e426..c39283ea 100644 --- a/schemas/macro_metadata.schema.json +++ b/schemas/macro_metadata.schema.json @@ -229,6 +229,9 @@ { "$ref": "#/$defs/EnumReference" }, + { + "$ref": "#/$defs/MixinReference" + }, { "$ref": "#/$defs/FunctionTypeParameterReference" } @@ -319,6 +322,19 @@ "type": "string", "description": "" }, + "AdjacentStringLiterals": { + "type": "object", + "description": "", + "properties": { + "expressions": { + "type": "array", + "description": "", + "items": { + "$ref": "#/$defs/Expression" + } + } + } + }, "AsExpression": { "type": "object", "description": "", @@ -355,8 +371,8 @@ "type": "object", "description": "", "properties": { - "text": { - "type": "string", + "value": { + "type": "boolean", "description": "" } } @@ -364,7 +380,12 @@ "ClassReference": { "type": "object", "description": "", - "properties": {} + "properties": { + "name": { + "type": "string", + "description": "" + } + } }, "ConditionalExpression": { "type": "object", @@ -408,7 +429,12 @@ "ConstructorReference": { "type": "object", "description": "", - "properties": {} + "properties": { + "name": { + "type": "string", + "description": "" + } + } }, "ConstructorTearOff": { "type": "object", @@ -431,6 +457,10 @@ "text": { "type": "string", "description": "" + }, + "value": { + "type": "double", + "description": "" } } }, @@ -447,7 +477,12 @@ "EnumReference": { "type": "object", "description": "", - "properties": {} + "properties": { + "name": { + "type": "string", + "description": "" + } + } }, "EqualityExpression": { "type": "object", @@ -484,17 +519,32 @@ "ExtensionReference": { "type": "object", "description": "", - "properties": {} + "properties": { + "name": { + "type": "string", + "description": "" + } + } }, "ExtensionTypeReference": { "type": "object", "description": "", - "properties": {} + "properties": { + "name": { + "type": "string", + "description": "" + } + } }, "FieldReference": { "type": "object", "description": "", - "properties": {} + "properties": { + "name": { + "type": "string", + "description": "" + } + } }, "FormalParameter": { "type": "object", @@ -509,7 +559,12 @@ "FunctionReference": { "type": "object", "description": "", - "properties": {} + "properties": { + "name": { + "type": "string", + "description": "" + } + } }, "FunctionTearOff": { "type": "object", @@ -553,7 +608,12 @@ "FunctionTypeParameterReference": { "type": "object", "description": "", - "properties": {} + "properties": { + "name": { + "type": "string", + "description": "" + } + } }, "FunctionTypeParameterType": { "type": "object", @@ -645,6 +705,10 @@ "text": { "type": "string", "description": "" + }, + "value": { + "type": "integer", + "description": "" } } }, @@ -774,6 +838,16 @@ } } }, + "MixinReference": { + "type": "object", + "description": "", + "properties": { + "name": { + "type": "string", + "description": "" + } + } + }, "NamedArgument": { "type": "object", "description": "", @@ -1013,19 +1087,6 @@ } } }, - "AdjacentStringLiterals": { - "type": "object", - "description": "", - "properties": { - "expressions": { - "type": "array", - "description": "", - "items": { - "$ref": "#/$defs/Expression" - } - } - } - }, "StringLiteral": { "type": "object", "description": "", @@ -1065,7 +1126,12 @@ "TypedefReference": { "type": "object", "description": "", - "properties": {} + "properties": { + "name": { + "type": "string", + "description": "" + } + } }, "TypeLiteral": { "type": "object", diff --git a/tool/dart_model_generator/lib/generate_dart_model.dart b/tool/dart_model_generator/lib/generate_dart_model.dart index 6839b178..552dcfe9 100644 --- a/tool/dart_model_generator/lib/generate_dart_model.dart +++ b/tool/dart_model_generator/lib/generate_dart_model.dart @@ -459,6 +459,11 @@ class TypeReference { 'type': 'integer', if (description != null) 'description': description, }; + } else if (name == 'double') { + return { + 'type': 'double', + if (description != null) 'description': description, + }; } // Not a built-in type, look up a user-defined type. This throws if there // is no such type defined. diff --git a/tool/dart_model_generator/lib/macro_metadata_definitions.dart b/tool/dart_model_generator/lib/macro_metadata_definitions.dart index 488406c0..43096a40 100644 --- a/tool/dart_model_generator/lib/macro_metadata_definitions.dart +++ b/tool/dart_model_generator/lib/macro_metadata_definitions.dart @@ -11,14 +11,12 @@ import 'generate_dart_model.dart'; final definitions = [ Definition.union( 'Argument', - createInBuffer: true, description: '', types: ['PositionalArgument', 'NamedArgument'], properties: [], ), Definition.union( 'Element', - createInBuffer: true, description: '', types: [ 'ExpressionElement', @@ -30,7 +28,6 @@ final definitions = [ ), Definition.union( 'Expression', - createInBuffer: true, description: '', types: [ 'InvalidExpression', @@ -71,14 +68,12 @@ final definitions = [ ), Definition.union( 'RecordField', - createInBuffer: true, description: '', types: ['RecordNamedField', 'RecordPositionalField'], properties: [], ), Definition.union( 'Reference', - createInBuffer: true, description: '', types: [ 'FieldReference', @@ -90,20 +85,19 @@ final definitions = [ 'ExtensionReference', 'ExtensionTypeReference', 'EnumReference', + 'MixinReference', 'FunctionTypeParameterReference', ], properties: [], ), Definition.union( 'StringLiteralPart', - createInBuffer: true, description: '', types: ['StringPart', 'InterpolationPart'], properties: [], ), Definition.union( 'TypeAnnotation', - createInBuffer: true, description: '', types: [ 'NamedTypeAnnotation', @@ -146,9 +140,15 @@ final definitions = [ description: '', values: ['minus', 'bang', 'tilde'], ), + Definition.clazz( + 'AdjacentStringLiterals', + description: '', + properties: [ + Property('expressions', type: 'List', description: ''), + ], + ), Definition.clazz( 'AsExpression', - createInBuffer: true, description: '', properties: [ Property('expression', type: 'Expression', description: ''), @@ -157,7 +157,6 @@ final definitions = [ ), Definition.clazz( 'BinaryExpression', - createInBuffer: true, description: '', properties: [ Property('left', type: 'Expression', description: ''), @@ -167,19 +166,16 @@ final definitions = [ ), Definition.clazz( 'BooleanLiteral', - createInBuffer: true, description: '', - properties: [Property('text', type: 'String', description: '')], + properties: [Property('value', type: 'bool', description: '')], ), Definition.clazz( 'ClassReference', - createInBuffer: true, description: '', - properties: [], + properties: [Property('name', type: 'String', description: '')], ), Definition.clazz( 'ConditionalExpression', - createInBuffer: true, description: '', properties: [ Property('condition', type: 'Expression', description: ''), @@ -189,7 +185,6 @@ final definitions = [ ), Definition.clazz( 'ConstructorInvocation', - createInBuffer: true, description: '', properties: [ Property('type', type: 'TypeAnnotation', description: ''), @@ -199,13 +194,11 @@ final definitions = [ ), Definition.clazz( 'ConstructorReference', - createInBuffer: true, description: '', - properties: [], + properties: [Property('name', type: 'String', description: '')], ), Definition.clazz( 'ConstructorTearOff', - createInBuffer: true, description: '', properties: [ Property('type', type: 'TypeAnnotation', description: ''), @@ -214,25 +207,24 @@ final definitions = [ ), Definition.clazz( 'DoubleLiteral', - createInBuffer: true, description: '', - properties: [Property('text', type: 'String', description: '')], + properties: [ + Property('text', type: 'String', description: ''), + Property('value', type: 'double', description: ''), + ], ), Definition.clazz( 'DynamicTypeAnnotation', - createInBuffer: true, description: '', properties: [Property('reference', type: 'Reference', description: '')], ), Definition.clazz( 'EnumReference', - createInBuffer: true, description: '', - properties: [], + properties: [Property('name', type: 'String', description: '')], ), Definition.clazz( 'EqualityExpression', - createInBuffer: true, description: '', properties: [ Property('left', type: 'Expression', description: ''), @@ -242,7 +234,6 @@ final definitions = [ ), Definition.clazz( 'ExpressionElement', - createInBuffer: true, description: '', properties: [ Property('expression', type: 'Expression', description: ''), @@ -251,43 +242,32 @@ final definitions = [ ), Definition.clazz( 'ExtensionReference', - createInBuffer: true, description: '', - properties: [], + properties: [Property('name', type: 'String', description: '')], ), Definition.clazz( 'ExtensionTypeReference', - createInBuffer: true, description: '', - properties: [], + properties: [Property('name', type: 'String', description: '')], ), Definition.clazz( 'FieldReference', - createInBuffer: true, description: '', - properties: [], - ), - Definition.clazz( - 'FormalParameter', - createInBuffer: true, - description: '', - properties: [], - ), - Definition.clazz( - 'FormalParameterGroup', - createInBuffer: true, - description: '', - properties: [], + properties: [Property('name', type: 'String', description: '')], ), + Definition.clazz('FormalParameter', description: '', properties: [ + ], +), + Definition.clazz('FormalParameterGroup', description: '', properties: [ + ], +), Definition.clazz( 'FunctionReference', - createInBuffer: true, description: '', - properties: [], + properties: [Property('name', type: 'String', description: '')], ), Definition.clazz( 'FunctionTearOff', - createInBuffer: true, description: '', properties: [ Property('reference', type: 'FunctionReference', description: ''), @@ -295,7 +275,6 @@ final definitions = [ ), Definition.clazz( 'FunctionTypeAnnotation', - createInBuffer: true, description: '', properties: [ Property( @@ -316,21 +295,16 @@ final definitions = [ ), ], ), - Definition.clazz( - 'FunctionTypeParameter', - createInBuffer: true, - description: '', - properties: [], - ), + Definition.clazz('FunctionTypeParameter', description: '', properties: [ + ], +), Definition.clazz( 'FunctionTypeParameterReference', - createInBuffer: true, description: '', - properties: [], + properties: [Property('name', type: 'String', description: '')], ), Definition.clazz( 'FunctionTypeParameterType', - createInBuffer: true, description: '', properties: [ Property( @@ -342,7 +316,6 @@ final definitions = [ ), Definition.clazz( 'IfElement', - createInBuffer: true, description: '', properties: [ Property('condition', type: 'Expression', description: ''), @@ -352,7 +325,6 @@ final definitions = [ ), Definition.clazz( 'IfNull', - createInBuffer: true, description: '', properties: [ Property('left', type: 'Expression', description: ''), @@ -361,7 +333,6 @@ final definitions = [ ), Definition.clazz( 'ImplicitInvocation', - createInBuffer: true, description: '', properties: [ Property('receiver', type: 'Expression', description: ''), @@ -371,7 +342,6 @@ final definitions = [ ), Definition.clazz( 'Instantiation', - createInBuffer: true, description: '', properties: [ Property('receiver', type: 'Expression', description: ''), @@ -380,31 +350,25 @@ final definitions = [ ), Definition.clazz( 'IntegerLiteral', - createInBuffer: true, description: '', - properties: [Property('text', type: 'String', description: '')], + properties: [ + Property('text', type: 'String', description: '', nullable: true), + Property('value', type: 'int', description: '', nullable: true), + ], ), Definition.clazz( 'InterpolationPart', - createInBuffer: true, description: '', properties: [Property('expression', type: 'Expression', description: '')], ), - Definition.clazz( - 'InvalidExpression', - createInBuffer: true, - description: '', - properties: [], - ), - Definition.clazz( - 'InvalidTypeAnnotation', - createInBuffer: true, - description: '', - properties: [], - ), + Definition.clazz('InvalidExpression', description: '', properties: [ + ], +), + Definition.clazz('InvalidTypeAnnotation', description: '', properties: [ + ], +), Definition.clazz( 'IsTest', - createInBuffer: true, description: '', properties: [ Property('expression', type: 'Expression', description: ''), @@ -414,7 +378,6 @@ final definitions = [ ), Definition.clazz( 'ListLiteral', - createInBuffer: true, description: '', properties: [ Property('typeArguments', type: 'List', description: ''), @@ -423,7 +386,6 @@ final definitions = [ ), Definition.clazz( 'LogicalExpression', - createInBuffer: true, description: '', properties: [ Property('left', type: 'Expression', description: ''), @@ -433,7 +395,6 @@ final definitions = [ ), Definition.clazz( 'MapEntryElement', - createInBuffer: true, description: '', properties: [ Property('key', type: 'Expression', description: ''), @@ -444,7 +405,6 @@ final definitions = [ ), Definition.clazz( 'MethodInvocation', - createInBuffer: true, description: '', properties: [ Property('receiver', type: 'Expression', description: ''), @@ -453,9 +413,13 @@ final definitions = [ Property('arguments', type: 'List', description: ''), ], ), + Definition.clazz( + 'MixinReference', + description: '', + properties: [Property('name', type: 'String', description: '')], + ), Definition.clazz( 'NamedArgument', - createInBuffer: true, description: '', properties: [ Property('name', type: 'String', description: ''), @@ -464,7 +428,6 @@ final definitions = [ ), Definition.clazz( 'NamedTypeAnnotation', - createInBuffer: true, description: '', properties: [ Property('reference', type: 'Reference', description: ''), @@ -473,7 +436,6 @@ final definitions = [ ), Definition.clazz( 'NullableTypeAnnotation', - createInBuffer: true, description: '', properties: [ Property('typeAnnotation', type: 'TypeAnnotation', description: ''), @@ -481,7 +443,6 @@ final definitions = [ ), Definition.clazz( 'NullAwarePropertyGet', - createInBuffer: true, description: '', properties: [ Property('receiver', type: 'Expression', description: ''), @@ -490,31 +451,24 @@ final definitions = [ ), Definition.clazz( 'NullCheck', - createInBuffer: true, description: '', properties: [Property('expression', type: 'Expression', description: '')], ), - Definition.clazz( - 'NullLiteral', - createInBuffer: true, - description: '', - properties: [], - ), + Definition.clazz('NullLiteral', description: '', properties: [ + ], +), Definition.clazz( 'ParenthesizedExpression', - createInBuffer: true, description: '', properties: [Property('expression', type: 'Expression', description: '')], ), Definition.clazz( 'PositionalArgument', - createInBuffer: true, description: '', properties: [Property('expression', type: 'Expression', description: '')], ), Definition.clazz( 'PropertyGet', - createInBuffer: true, description: '', properties: [ Property('receiver', type: 'Expression', description: ''), @@ -523,7 +477,6 @@ final definitions = [ ), Definition.clazz( 'RecordLiteral', - createInBuffer: true, description: '', properties: [ Property('fields', type: 'List', description: ''), @@ -531,7 +484,6 @@ final definitions = [ ), Definition.clazz( 'RecordNamedField', - createInBuffer: true, description: '', properties: [ Property('name', type: 'String', description: ''), @@ -540,34 +492,25 @@ final definitions = [ ), Definition.clazz( 'RecordPositionalField', - createInBuffer: true, description: '', properties: [Property('expression', type: 'Expression', description: '')], ), Definition.clazz( 'RecordTypeAnnotation', - createInBuffer: true, description: '', properties: [ Property('positional', type: 'List', description: ''), Property('named', type: 'List', description: ''), ], ), - Definition.clazz( - 'RecordTypeEntry', - createInBuffer: true, - description: '', - properties: [], - ), - Definition.clazz( - 'References', - createInBuffer: true, - description: '', - properties: [], - ), + Definition.clazz('RecordTypeEntry', description: '', properties: [ + ], +), + Definition.clazz('References', description: '', properties: [ + ], +), Definition.clazz( 'SetOrMapLiteral', - createInBuffer: true, description: '', properties: [ Property('typeArguments', type: 'List', description: ''), @@ -576,7 +519,6 @@ final definitions = [ ), Definition.clazz( 'SpreadElement', - createInBuffer: true, description: '', properties: [ Property('expression', type: 'Expression', description: ''), @@ -585,7 +527,6 @@ final definitions = [ ), Definition.clazz( 'StaticGet', - createInBuffer: true, description: '', properties: [ Property('reference', type: 'FieldReference', description: ''), @@ -593,7 +534,6 @@ final definitions = [ ), Definition.clazz( 'StaticInvocation', - createInBuffer: true, description: '', properties: [ Property('function', type: 'FunctionReference', description: ''), @@ -601,17 +541,8 @@ final definitions = [ Property('arguments', type: 'List', description: ''), ], ), - Definition.clazz( - 'AdjacentStringLiterals', - createInBuffer: true, - description: '', - properties: [ - Property('expressions', type: 'List', description: ''), - ], - ), Definition.clazz( 'StringLiteral', - createInBuffer: true, description: '', properties: [ Property('parts', type: 'List', description: ''), @@ -619,60 +550,45 @@ final definitions = [ ), Definition.clazz( 'StringPart', - createInBuffer: true, description: '', properties: [Property('text', type: 'String', description: '')], ), Definition.clazz( 'SymbolLiteral', - createInBuffer: true, description: '', properties: [Property('parts', type: 'List', description: '')], ), Definition.clazz( 'TypedefReference', - createInBuffer: true, description: '', - properties: [], + properties: [Property('name', type: 'String', description: '')], ), Definition.clazz( 'TypeLiteral', - createInBuffer: true, description: '', properties: [ Property('typeAnnotation', type: 'TypeAnnotation', description: ''), ], ), - Definition.clazz( - 'TypeReference', - createInBuffer: true, - description: '', - properties: [], - ), + Definition.clazz('TypeReference', description: '', properties: [ + ], +), Definition.clazz( 'UnaryExpression', - createInBuffer: true, description: '', properties: [ Property('operator', type: 'UnaryOperator', description: ''), Property('expression', type: 'Expression', description: ''), ], ), - Definition.clazz( - 'UnresolvedExpression', - createInBuffer: true, - description: '', - properties: [], - ), - Definition.clazz( - 'UnresolvedTypeAnnotation', - createInBuffer: true, - description: '', - properties: [], - ), + Definition.clazz('UnresolvedExpression', description: '', properties: [ + ], +), + Definition.clazz('UnresolvedTypeAnnotation', description: '', properties: [ + ], +), Definition.clazz( 'VoidTypeAnnotation', - createInBuffer: true, description: '', properties: [Property('reference', type: 'Reference', description: '')], ), diff --git a/tool/generate_converter b/tool/generate_converter index 38974b6a..1825bf45 100755 --- a/tool/generate_converter +++ b/tool/generate_converter @@ -7,7 +7,7 @@ # # mkdir /tmp/inputs # cp ~/git/dart-sdk/sdk/pkg/_fe_analyzer_shared/lib/src/metadata/* /tmp/inputs -# rm /tmp/inputs/proto.dart /tmp/inputs/parser.dart /tmp/inputs/scope.dart +# rm /tmp/inputs/proto.dart /tmp/inputs/parser.dart /tmp/inputs/scope.dart /tmp/inputs/evaluate.dart # tool/generate_converter /tmp/inputs path="$1" @@ -39,7 +39,7 @@ echo "T? convert(Object? object) => switch (object) {" # Enums. for type in $(echo "$source" \ - | egrep '^enum [A-Z]' \ + | grep -E '^enum [A-Z]' \ | sed -e 's#enum ##' \ | sed -e 's# .*##' \ | sort); do @@ -48,7 +48,7 @@ done # Classes. for type in $(echo "$source" \ - | egrep '^[a-z ]*class ' \ + | grep -E '^[a-z ]*class ' \ | grep -v 'sealed' \ | sed -e 's#abstract ##' \ | sed -e 's#class ##' \ @@ -65,7 +65,18 @@ for type in $(echo "$source" \ continue fi field_type=$(echo $line | sed -e 's# final ##' | sed -e 's# .*##') - if echo "$field_type" | egrep -q '^(Argument|Element|Expression|RecordField|Reference|StringLiteralPart)$'; then + if echo "$field_type" | grep -E -q '^(Argument|Element|Expression|RecordField|Reference|StringLiteralPart)$'; then + echo " $field_name: convertTo$field_type(o.$field_name)," + else + echo " $field_name: convert(o.$field_name)," + fi + elif echo "$line" | grep -q ' get '; then + field_name=$(echo $line | sed -e 's#.* get ##' | sed -e 's#;##') + if test "$field_name" == "unresolved"; then + continue + fi + field_type=$(echo $line | sed -e 's# ##' | sed -e 's# get .*##') + if echo "$field_type" | grep -E -q '^(Argument|Element|Expression|RecordField|Reference|StringLiteralPart)$'; then echo " $field_name: convertTo$field_type(o.$field_name)," else echo " $field_name: convert(o.$field_name)," diff --git a/tool/generate_definitions b/tool/generate_definitions index 78f59e57..1ff315f7 100755 --- a/tool/generate_definitions +++ b/tool/generate_definitions @@ -7,7 +7,7 @@ # # mkdir /tmp/inputs # cp ~/git/dart-sdk/sdk/pkg/_fe_analyzer_shared/lib/src/metadata/* /tmp/inputs -# rm /tmp/inputs/proto.dart /tmp/inputs/parser.dart /tmp/inputs/scope.dart +# rm /tmp/inputs/proto.dart /tmp/inputs/parser.dart /tmp/inputs/scope.dart /tmp/inputs/evaluate.dart # tool/generate_definitions /tmp/inputs path="$1" @@ -40,7 +40,7 @@ done # Enums. for type in $(echo "$source" \ - | egrep '^enum [A-Z]' \ + | grep -E '^enum [A-Z]' \ | sed -e 's#enum ##' \ | sed -e 's# .*##' \ | sort); do @@ -50,10 +50,10 @@ for type in $(echo "$source" \ for line in $(echo "$source" \ | grep -A1000000 "enum $type " \ | tail -n +2); do - if echo "$line" | grep -q ';'; then + if echo "$line" | grep -q -e ';' -e '}'; then break else - value=$(echo $line | sed -e 's# ##' | sed -e 's#(.*##') + value=$(echo $line | sed -e 's# ##' | sed -e 's#(.*##' | sed -e 's#,##') echo " '$value'," fi done @@ -63,7 +63,7 @@ done # Classes. for type in $(echo "$source" \ - | egrep '^[a-z ]*class ' \ + | grep -E '^[a-z ]*class ' \ | grep -v 'sealed' \ | sed -e 's#abstract ##' \ | sed -e 's#class ##' \ @@ -82,7 +82,19 @@ for type in $(echo "$source" \ continue fi field_type=$(echo $line | sed -e 's# final ##' | sed -e 's# .*##') - if echo "$field_type" | fgrep -q '?'; then + if echo "$field_type" | grep -F -q '?'; then + field_type=$(echo "$field_type" | sed -e 's#?##') + echo " Property('$field_name', type: '$field_type', description: '', nullable: true)," + else + echo " Property('$field_name', type: '$field_type', description: '')," + fi + elif echo "$line" | grep -q ' get '; then + field_name=$(echo $line | sed -e 's#.* get ##' | sed -e 's#;##') + if test "$field_name" == "unresolved"; then + continue + fi + field_type=$(echo $line | sed -e 's# ##' | sed -e 's# get .*##') + if echo "$field_type" | grep -F -q '?'; then field_type=$(echo "$field_type" | sed -e 's#?##') echo " Property('$field_name', type: '$field_type', description: '', nullable: true)," else From 210929f5c79afeae55ae94dde147fe094a9d556b Mon Sep 17 00:00:00 2001 From: Karol Czeryna Date: Mon, 9 Dec 2024 23:14:16 +0100 Subject: [PATCH 2/5] add double converter support, fix related tests --- goldens/foo/lib/foo.analyzer.json | 16 +- .../lib/literal_params.analyzer.augmentations | 4 +- goldens/foo/lib/metadata.analyzer.json | 21 +- .../lib/metadata_converter.dart | 2 +- .../test/metadata_converter_test.dart | 8 +- pkgs/_test_macros/lib/literal_params.dart | 4 +- .../src/json_buffer/json_buffer_builder.dart | 26 + pkgs/dart_model/lib/src/json_buffer/type.dart | 5 + pkgs/dart_model/lib/src/macro_metadata.g.dart | 870 +++++++++++------- schemas/macro_metadata.schema.json | 2 +- .../lib/generate_dart_model.dart | 4 +- .../lib/macro_metadata_definitions.dart | 165 +++- tool/generate_definitions | 2 + 13 files changed, 721 insertions(+), 408 deletions(-) diff --git a/goldens/foo/lib/foo.analyzer.json b/goldens/foo/lib/foo.analyzer.json index 15f24c4b..1195bbbd 100644 --- a/goldens/foo/lib/foo.analyzer.json +++ b/goldens/foo/lib/foo.analyzer.json @@ -208,14 +208,18 @@ "value": { "reference": { "type": "ClassReference", - "value": {} + "value": { + "name": "QueryClass" + } }, "typeArguments": [] } }, "constructor": { "type": "ConstructorReference", - "value": {} + "value": { + "name": "new" + } }, "arguments": [] } @@ -272,14 +276,18 @@ "value": { "reference": { "type": "ClassReference", - "value": {} + "value": { + "name": "QueryClass" + } }, "typeArguments": [] } }, "constructor": { "type": "ConstructorReference", - "value": {} + "value": { + "name": "new" + } }, "arguments": [] } diff --git a/goldens/foo/lib/literal_params.analyzer.augmentations b/goldens/foo/lib/literal_params.analyzer.augmentations index b0a3057c..75f63cf0 100644 --- a/goldens/foo/lib/literal_params.analyzer.augmentations +++ b/goldens/foo/lib/literal_params.analyzer.augmentations @@ -5,10 +5,10 @@ augment class Foo { // aNum: 8.0, double // aDouble: 9.0, double // aString: 10, String - // anObject: {type: {type: NamedTypeAnnotation, value: {reference: {type: ClassReference, value: {}}, typeArguments: []}}, constructor: {type: ConstructorReference, value: {}}, arguments: [{type: NamedArgument, value: {name: a, expression: {type: BooleanLiteral, value: {text: true}}}}, {type: NamedArgument, value: {name: b, expression: {type: BooleanLiteral, value: {text: false}}}}]}, String + // anObject: {type: {type: NamedTypeAnnotation, value: {reference: {type: ClassReference, value: {name: Bar}}, typeArguments: []}}, constructor: {type: ConstructorReference, value: {name: new}}, arguments: [{type: NamedArgument, value: {name: a, expression: {type: BooleanLiteral, value: {value: true}}}}, {type: NamedArgument, value: {name: b, expression: {type: BooleanLiteral, value: {value: false}}}}]}, String // ints: [11, 12], List // nums: [13.0, 14], List // doubles: [15.0, 16], List // strings: [17, eighteen], List - // objects: [19, {type: {type: NamedTypeAnnotation, value: {reference: {type: ClassReference, value: {}}, typeArguments: []}}, constructor: {type: ConstructorReference, value: {}}, arguments: [{type: NamedArgument, value: {name: a, expression: {type: BooleanLiteral, value: {text: true}}}}, {type: NamedArgument, value: {name: b, expression: {type: BooleanLiteral, value: {text: false}}}}]}], List + // objects: [19, {type: {type: NamedTypeAnnotation, value: {reference: {type: ClassReference, value: {name: Bar}}, typeArguments: []}}, constructor: {type: ConstructorReference, value: {name: new}}, arguments: [{type: NamedArgument, value: {name: a, expression: {type: BooleanLiteral, value: {value: true}}}}, {type: NamedArgument, value: {name: b, expression: {type: BooleanLiteral, value: {value: false}}}}]}], List } diff --git a/goldens/foo/lib/metadata.analyzer.json b/goldens/foo/lib/metadata.analyzer.json index a1a4ec6c..71d9be48 100644 --- a/goldens/foo/lib/metadata.analyzer.json +++ b/goldens/foo/lib/metadata.analyzer.json @@ -28,14 +28,18 @@ "value": { "reference": { "type": "ClassReference", - "value": {} + "value": { + "name": "QueryClass" + } }, "typeArguments": [] } }, "constructor": { "type": "ConstructorReference", - "value": {} + "value": { + "name": "new" + } }, "arguments": [] } @@ -50,14 +54,18 @@ "value": { "reference": { "type": "ClassReference", - "value": {} + "value": { + "name": "Annotation" + } }, "typeArguments": [] } }, "constructor": { "type": "ConstructorReference", - "value": {} + "value": { + "name": "new" + } }, "arguments": [ { @@ -67,7 +75,7 @@ "expression": { "type": "BooleanLiteral", "value": { - "text": "true" + "value": true } } } @@ -79,7 +87,8 @@ "expression": { "type": "IntegerLiteral", "value": { - "text": "23" + "text": "23", + "value": 23 } } } diff --git a/pkgs/_analyzer_cfe_macros/lib/metadata_converter.dart b/pkgs/_analyzer_cfe_macros/lib/metadata_converter.dart index 554f5663..e203f6b9 100644 --- a/pkgs/_analyzer_cfe_macros/lib/metadata_converter.dart +++ b/pkgs/_analyzer_cfe_macros/lib/metadata_converter.dart @@ -281,7 +281,7 @@ T? convert(Object? object) => switch (object) { as T, front_end.ConstructorInvocation o => dart_model.ConstructorInvocation( - type: convert(o.type), + type: convertToTypeAnnotation(o.type), constructor: convertToReference(o.constructor), arguments: convert(o.arguments), ) diff --git a/pkgs/_analyzer_cfe_macros/test/metadata_converter_test.dart b/pkgs/_analyzer_cfe_macros/test/metadata_converter_test.dart index 00237200..71539279 100644 --- a/pkgs/_analyzer_cfe_macros/test/metadata_converter_test.dart +++ b/pkgs/_analyzer_cfe_macros/test/metadata_converter_test.dart @@ -20,7 +20,7 @@ void main() { expect(convert(invocation), { 'receiver': { 'type': 'DoubleLiteral', - 'value': {'text': '1.23'}, + 'value': {'text': '1.23', 'value': 1.23}, }, 'name': 'round', 'typeArguments': [], @@ -40,12 +40,12 @@ void main() { expect(convert(expression), { 'left': { 'type': 'DoubleLiteral', - 'value': {'text': '1.23'}, + 'value': {'text': '1.23', 'value': 1.23}, }, 'operator': 'minus', 'right': { 'type': 'DoubleLiteral', - 'value': {'text': '1.24'}, + 'value': {'text': '1.24', 'value': 1.24}, }, }); }); @@ -63,7 +63,7 @@ void main() { expect(convert(invocation), { 'receiver': { 'type': 'DoubleLiteral', - 'value': {'text': '1.23'}, + 'value': {'text': '1.23', 'value': 1.23}, }, 'name': 'round', 'typeArguments': [], diff --git a/pkgs/_test_macros/lib/literal_params.dart b/pkgs/_test_macros/lib/literal_params.dart index 9bbeae20..d12c7f94 100644 --- a/pkgs/_test_macros/lib/literal_params.dart +++ b/pkgs/_test_macros/lib/literal_params.dart @@ -93,9 +93,9 @@ class LiteralParamsImplementation implements ClassDeclarationsMacro { extension ExpressionExtension on Expression { Object get evaluate => switch (type) { ExpressionType.integerLiteral => int.parse(asIntegerLiteral.text), - ExpressionType.doubleLiteral => double.parse(asDoubleLiteral.text), + ExpressionType.doubleLiteral => asDoubleLiteral.value, ExpressionType.stringLiteral => asStringLiteral.evaluate, - ExpressionType.booleanLiteral => bool.parse(asBooleanLiteral.text), + ExpressionType.booleanLiteral => asBooleanLiteral.value, ExpressionType.listLiteral => asListLiteral.elements.map((e) => e.evaluate).toList(), // TODO(davidmorgan): need the type name to do something useful here, diff --git a/pkgs/dart_model/lib/src/json_buffer/json_buffer_builder.dart b/pkgs/dart_model/lib/src/json_buffer/json_buffer_builder.dart index 629db4ec..5bf0898e 100644 --- a/pkgs/dart_model/lib/src/json_buffer/json_buffer_builder.dart +++ b/pkgs/dart_model/lib/src/json_buffer/json_buffer_builder.dart @@ -4,6 +4,7 @@ import 'dart:collection'; import 'dart:convert'; +import 'dart:io'; import 'dart:typed_data'; import 'package:convert/convert.dart'; @@ -104,6 +105,8 @@ class JsonBufferBuilder { _buildDigest(pointer, byteSink); case Type.uint32: byteSink.addSlice(_buffer, pointer, pointer + 4, false); + case Type.float64: + byteSink.addSlice(_buffer, pointer, pointer + 8, false); case Type.boolean: // We use [1] and [2] because [0] is `null`. byteSink.add(_readBoolean(pointer) ? const [2] : const [1]); @@ -151,6 +154,8 @@ class JsonBufferBuilder { return _readPointer(pointer); case Type.uint32: return _readUint32(pointer); + case Type.float64: + return _readFloat64(pointer); case Type.boolean: return _readBoolean(pointer); case Type.anyPointer: @@ -206,6 +211,9 @@ class JsonBufferBuilder { case Type.uint32: _writeUint32(pointer, value as int); + case Type.float64: + _writeFloat64(pointer, value as double); + case Type.boolean: _writeBoolean(pointer, value as bool); @@ -325,6 +333,24 @@ class JsonBufferBuilder { (_buffer[pointer + 2] << 16) + (_buffer[pointer + 3] << 24); + /// Writes [value] at [pointer]. + void _writeFloat64(_Pointer pointer, double value) { + _explanations?.push('_writeFloat64 $value'); + __writeFloat64(pointer, value); + _explanations?.pop(); + } + + void __writeFloat64(_Pointer pointer, double value) { + final byteData = ByteData(8); + byteData.setFloat64(0, value, Endian.big); + _setRange(pointer, pointer + 8, byteData.buffer.asUint8List()); + } + + /// Reads the float64 at [_Pointer]. + double _readFloat64(_Pointer pointer) { + return ByteData.sublistView(_buffer).getFloat64(pointer, Endian.big); + } + /// Writes [boolean] at [pointer]. void _writeBoolean(_Pointer pointer, bool boolean) { _explanations?.push('_writeBoolean $boolean'); diff --git a/pkgs/dart_model/lib/src/json_buffer/type.dart b/pkgs/dart_model/lib/src/json_buffer/type.dart index 3ada111c..5472ecb9 100644 --- a/pkgs/dart_model/lib/src/json_buffer/type.dart +++ b/pkgs/dart_model/lib/src/json_buffer/type.dart @@ -27,6 +27,7 @@ enum Type { type(false), pointer(true), uint32(false), + float64(false), boolean(false), anyPointer(false), // This is actually a type followed by a pointer. stringPointer(true), @@ -52,6 +53,8 @@ enum Type { return Type.stringPointer; case int(): return Type.uint32; + case double(): + return Type.float64; case bool(): return Type.boolean; case Type(): @@ -92,6 +95,8 @@ enum Type { return 4; case anyPointer: return 5; + case float64: + return 8; } } } diff --git a/pkgs/dart_model/lib/src/macro_metadata.g.dart b/pkgs/dart_model/lib/src/macro_metadata.g.dart index e43ebfa2..c8b386b7 100644 --- a/pkgs/dart_model/lib/src/macro_metadata.g.dart +++ b/pkgs/dart_model/lib/src/macro_metadata.g.dart @@ -18,13 +18,18 @@ enum ArgumentType { } extension type Argument.fromJson(Map node) implements Object { + static final TypedMapSchema _schema = TypedMapSchema({ + 'type': Type.stringPointer, + 'value': Type.anyPointer, + }); static Argument positionalArgument(PositionalArgument positionalArgument) => - Argument.fromJson({ - 'type': 'PositionalArgument', - 'value': positionalArgument, - }); + Argument.fromJson( + Scope.createMap(_schema, 'PositionalArgument', positionalArgument), + ); static Argument namedArgument(NamedArgument namedArgument) => - Argument.fromJson({'type': 'NamedArgument', 'value': namedArgument}); + Argument.fromJson( + Scope.createMap(_schema, 'NamedArgument', namedArgument), + ); ArgumentType get type { switch (node['type'] as String) { case 'PositionalArgument': @@ -63,17 +68,23 @@ enum ElementType { } extension type Element.fromJson(Map node) implements Object { + static final TypedMapSchema _schema = TypedMapSchema({ + 'type': Type.stringPointer, + 'value': Type.anyPointer, + }); static Element expressionElement(ExpressionElement expressionElement) => - Element.fromJson({ - 'type': 'ExpressionElement', - 'value': expressionElement, - }); + Element.fromJson( + Scope.createMap(_schema, 'ExpressionElement', expressionElement), + ); static Element mapEntryElement(MapEntryElement mapEntryElement) => - Element.fromJson({'type': 'MapEntryElement', 'value': mapEntryElement}); - static Element spreadElement(SpreadElement spreadElement) => - Element.fromJson({'type': 'SpreadElement', 'value': spreadElement}); + Element.fromJson( + Scope.createMap(_schema, 'MapEntryElement', mapEntryElement), + ); + static Element spreadElement(SpreadElement spreadElement) => Element.fromJson( + Scope.createMap(_schema, 'SpreadElement', spreadElement), + ); static Element ifElement(IfElement ifElement) => - Element.fromJson({'type': 'IfElement', 'value': ifElement}); + Element.fromJson(Scope.createMap(_schema, 'IfElement', ifElement)); ElementType get type { switch (node['type'] as String) { case 'ExpressionElement': @@ -160,129 +171,136 @@ enum ExpressionType { extension type Expression.fromJson(Map node) implements Object { + static final TypedMapSchema _schema = TypedMapSchema({ + 'type': Type.stringPointer, + 'value': Type.anyPointer, + }); static Expression invalidExpression(InvalidExpression invalidExpression) => - Expression.fromJson({ - 'type': 'InvalidExpression', - 'value': invalidExpression, - }); + Expression.fromJson( + Scope.createMap(_schema, 'InvalidExpression', invalidExpression), + ); static Expression staticGet(StaticGet staticGet) => - Expression.fromJson({'type': 'StaticGet', 'value': staticGet}); + Expression.fromJson(Scope.createMap(_schema, 'StaticGet', staticGet)); static Expression functionTearOff(FunctionTearOff functionTearOff) => - Expression.fromJson({ - 'type': 'FunctionTearOff', - 'value': functionTearOff, - }); + Expression.fromJson( + Scope.createMap(_schema, 'FunctionTearOff', functionTearOff), + ); static Expression constructorTearOff(ConstructorTearOff constructorTearOff) => - Expression.fromJson({ - 'type': 'ConstructorTearOff', - 'value': constructorTearOff, - }); + Expression.fromJson( + Scope.createMap(_schema, 'ConstructorTearOff', constructorTearOff), + ); static Expression constructorInvocation( ConstructorInvocation constructorInvocation, - ) => Expression.fromJson({ - 'type': 'ConstructorInvocation', - 'value': constructorInvocation, - }); + ) => Expression.fromJson( + Scope.createMap(_schema, 'ConstructorInvocation', constructorInvocation), + ); static Expression integerLiteral(IntegerLiteral integerLiteral) => - Expression.fromJson({'type': 'IntegerLiteral', 'value': integerLiteral}); + Expression.fromJson( + Scope.createMap(_schema, 'IntegerLiteral', integerLiteral), + ); static Expression doubleLiteral(DoubleLiteral doubleLiteral) => - Expression.fromJson({'type': 'DoubleLiteral', 'value': doubleLiteral}); + Expression.fromJson( + Scope.createMap(_schema, 'DoubleLiteral', doubleLiteral), + ); static Expression booleanLiteral(BooleanLiteral booleanLiteral) => - Expression.fromJson({'type': 'BooleanLiteral', 'value': booleanLiteral}); + Expression.fromJson( + Scope.createMap(_schema, 'BooleanLiteral', booleanLiteral), + ); static Expression nullLiteral(NullLiteral nullLiteral) => - Expression.fromJson({'type': 'NullLiteral', 'value': nullLiteral}); + Expression.fromJson(Scope.createMap(_schema, 'NullLiteral', nullLiteral)); static Expression symbolLiteral(SymbolLiteral symbolLiteral) => - Expression.fromJson({'type': 'SymbolLiteral', 'value': symbolLiteral}); + Expression.fromJson( + Scope.createMap(_schema, 'SymbolLiteral', symbolLiteral), + ); static Expression stringLiteral(StringLiteral stringLiteral) => - Expression.fromJson({'type': 'StringLiteral', 'value': stringLiteral}); + Expression.fromJson( + Scope.createMap(_schema, 'StringLiteral', stringLiteral), + ); static Expression adjacentStringLiterals( AdjacentStringLiterals adjacentStringLiterals, - ) => Expression.fromJson({ - 'type': 'AdjacentStringLiterals', - 'value': adjacentStringLiterals, - }); + ) => Expression.fromJson( + Scope.createMap(_schema, 'AdjacentStringLiterals', adjacentStringLiterals), + ); static Expression implicitInvocation(ImplicitInvocation implicitInvocation) => - Expression.fromJson({ - 'type': 'ImplicitInvocation', - 'value': implicitInvocation, - }); + Expression.fromJson( + Scope.createMap(_schema, 'ImplicitInvocation', implicitInvocation), + ); static Expression staticInvocation(StaticInvocation staticInvocation) => - Expression.fromJson({ - 'type': 'StaticInvocation', - 'value': staticInvocation, - }); + Expression.fromJson( + Scope.createMap(_schema, 'StaticInvocation', staticInvocation), + ); static Expression instantiation(Instantiation instantiation) => - Expression.fromJson({'type': 'Instantiation', 'value': instantiation}); + Expression.fromJson( + Scope.createMap(_schema, 'Instantiation', instantiation), + ); static Expression methodInvocation(MethodInvocation methodInvocation) => - Expression.fromJson({ - 'type': 'MethodInvocation', - 'value': methodInvocation, - }); + Expression.fromJson( + Scope.createMap(_schema, 'MethodInvocation', methodInvocation), + ); static Expression propertyGet(PropertyGet propertyGet) => - Expression.fromJson({'type': 'PropertyGet', 'value': propertyGet}); + Expression.fromJson(Scope.createMap(_schema, 'PropertyGet', propertyGet)); static Expression nullAwarePropertyGet( NullAwarePropertyGet nullAwarePropertyGet, - ) => Expression.fromJson({ - 'type': 'NullAwarePropertyGet', - 'value': nullAwarePropertyGet, - }); + ) => Expression.fromJson( + Scope.createMap(_schema, 'NullAwarePropertyGet', nullAwarePropertyGet), + ); static Expression typeLiteral(TypeLiteral typeLiteral) => - Expression.fromJson({'type': 'TypeLiteral', 'value': typeLiteral}); + Expression.fromJson(Scope.createMap(_schema, 'TypeLiteral', typeLiteral)); static Expression parenthesizedExpression( ParenthesizedExpression parenthesizedExpression, - ) => Expression.fromJson({ - 'type': 'ParenthesizedExpression', - 'value': parenthesizedExpression, - }); + ) => Expression.fromJson( + Scope.createMap( + _schema, + 'ParenthesizedExpression', + parenthesizedExpression, + ), + ); static Expression conditionalExpression( ConditionalExpression conditionalExpression, - ) => Expression.fromJson({ - 'type': 'ConditionalExpression', - 'value': conditionalExpression, - }); + ) => Expression.fromJson( + Scope.createMap(_schema, 'ConditionalExpression', conditionalExpression), + ); static Expression listLiteral(ListLiteral listLiteral) => - Expression.fromJson({'type': 'ListLiteral', 'value': listLiteral}); + Expression.fromJson(Scope.createMap(_schema, 'ListLiteral', listLiteral)); static Expression setOrMapLiteral(SetOrMapLiteral setOrMapLiteral) => - Expression.fromJson({ - 'type': 'SetOrMapLiteral', - 'value': setOrMapLiteral, - }); + Expression.fromJson( + Scope.createMap(_schema, 'SetOrMapLiteral', setOrMapLiteral), + ); static Expression recordLiteral(RecordLiteral recordLiteral) => - Expression.fromJson({'type': 'RecordLiteral', 'value': recordLiteral}); + Expression.fromJson( + Scope.createMap(_schema, 'RecordLiteral', recordLiteral), + ); static Expression ifNull(IfNull ifNull) => - Expression.fromJson({'type': 'IfNull', 'value': ifNull}); + Expression.fromJson(Scope.createMap(_schema, 'IfNull', ifNull)); static Expression logicalExpression(LogicalExpression logicalExpression) => - Expression.fromJson({ - 'type': 'LogicalExpression', - 'value': logicalExpression, - }); + Expression.fromJson( + Scope.createMap(_schema, 'LogicalExpression', logicalExpression), + ); static Expression equalityExpression(EqualityExpression equalityExpression) => - Expression.fromJson({ - 'type': 'EqualityExpression', - 'value': equalityExpression, - }); + Expression.fromJson( + Scope.createMap(_schema, 'EqualityExpression', equalityExpression), + ); static Expression binaryExpression(BinaryExpression binaryExpression) => - Expression.fromJson({ - 'type': 'BinaryExpression', - 'value': binaryExpression, - }); + Expression.fromJson( + Scope.createMap(_schema, 'BinaryExpression', binaryExpression), + ); static Expression unaryExpression(UnaryExpression unaryExpression) => - Expression.fromJson({ - 'type': 'UnaryExpression', - 'value': unaryExpression, - }); + Expression.fromJson( + Scope.createMap(_schema, 'UnaryExpression', unaryExpression), + ); static Expression isTest(IsTest isTest) => - Expression.fromJson({'type': 'IsTest', 'value': isTest}); + Expression.fromJson(Scope.createMap(_schema, 'IsTest', isTest)); static Expression asExpression(AsExpression asExpression) => - Expression.fromJson({'type': 'AsExpression', 'value': asExpression}); + Expression.fromJson( + Scope.createMap(_schema, 'AsExpression', asExpression), + ); static Expression nullCheck(NullCheck nullCheck) => - Expression.fromJson({'type': 'NullCheck', 'value': nullCheck}); + Expression.fromJson(Scope.createMap(_schema, 'NullCheck', nullCheck)); static Expression unresolvedExpression( UnresolvedExpression unresolvedExpression, - ) => Expression.fromJson({ - 'type': 'UnresolvedExpression', - 'value': unresolvedExpression, - }); + ) => Expression.fromJson( + Scope.createMap(_schema, 'UnresolvedExpression', unresolvedExpression), + ); ExpressionType get type { switch (node['type'] as String) { case 'InvalidExpression': @@ -607,17 +625,19 @@ enum RecordFieldType { extension type RecordField.fromJson(Map node) implements Object { + static final TypedMapSchema _schema = TypedMapSchema({ + 'type': Type.stringPointer, + 'value': Type.anyPointer, + }); static RecordField recordNamedField(RecordNamedField recordNamedField) => - RecordField.fromJson({ - 'type': 'RecordNamedField', - 'value': recordNamedField, - }); + RecordField.fromJson( + Scope.createMap(_schema, 'RecordNamedField', recordNamedField), + ); static RecordField recordPositionalField( RecordPositionalField recordPositionalField, - ) => RecordField.fromJson({ - 'type': 'RecordPositionalField', - 'value': recordPositionalField, - }); + ) => RecordField.fromJson( + Scope.createMap(_schema, 'RecordPositionalField', recordPositionalField), + ); RecordFieldType get type { switch (node['type'] as String) { case 'RecordNamedField': @@ -665,49 +685,61 @@ enum ReferenceType { } extension type Reference.fromJson(Map node) implements Object { + static final TypedMapSchema _schema = TypedMapSchema({ + 'type': Type.stringPointer, + 'value': Type.anyPointer, + }); static Reference fieldReference(FieldReference fieldReference) => - Reference.fromJson({'type': 'FieldReference', 'value': fieldReference}); + Reference.fromJson( + Scope.createMap(_schema, 'FieldReference', fieldReference), + ); static Reference functionReference(FunctionReference functionReference) => - Reference.fromJson({ - 'type': 'FunctionReference', - 'value': functionReference, - }); + Reference.fromJson( + Scope.createMap(_schema, 'FunctionReference', functionReference), + ); static Reference constructorReference( ConstructorReference constructorReference, - ) => Reference.fromJson({ - 'type': 'ConstructorReference', - 'value': constructorReference, - }); + ) => Reference.fromJson( + Scope.createMap(_schema, 'ConstructorReference', constructorReference), + ); static Reference typeReference(TypeReference typeReference) => - Reference.fromJson({'type': 'TypeReference', 'value': typeReference}); + Reference.fromJson( + Scope.createMap(_schema, 'TypeReference', typeReference), + ); static Reference classReference(ClassReference classReference) => - Reference.fromJson({'type': 'ClassReference', 'value': classReference}); + Reference.fromJson( + Scope.createMap(_schema, 'ClassReference', classReference), + ); static Reference typedefReference(TypedefReference typedefReference) => - Reference.fromJson({ - 'type': 'TypedefReference', - 'value': typedefReference, - }); + Reference.fromJson( + Scope.createMap(_schema, 'TypedefReference', typedefReference), + ); static Reference extensionReference(ExtensionReference extensionReference) => - Reference.fromJson({ - 'type': 'ExtensionReference', - 'value': extensionReference, - }); + Reference.fromJson( + Scope.createMap(_schema, 'ExtensionReference', extensionReference), + ); static Reference extensionTypeReference( ExtensionTypeReference extensionTypeReference, - ) => Reference.fromJson({ - 'type': 'ExtensionTypeReference', - 'value': extensionTypeReference, - }); + ) => Reference.fromJson( + Scope.createMap(_schema, 'ExtensionTypeReference', extensionTypeReference), + ); static Reference enumReference(EnumReference enumReference) => - Reference.fromJson({'type': 'EnumReference', 'value': enumReference}); + Reference.fromJson( + Scope.createMap(_schema, 'EnumReference', enumReference), + ); static Reference mixinReference(MixinReference mixinReference) => - Reference.fromJson({'type': 'MixinReference', 'value': mixinReference}); + Reference.fromJson( + Scope.createMap(_schema, 'MixinReference', mixinReference), + ); static Reference functionTypeParameterReference( FunctionTypeParameterReference functionTypeParameterReference, - ) => Reference.fromJson({ - 'type': 'FunctionTypeParameterReference', - 'value': functionTypeParameterReference, - }); + ) => Reference.fromJson( + Scope.createMap( + _schema, + 'FunctionTypeParameterReference', + functionTypeParameterReference, + ), + ); ReferenceType get type { switch (node['type'] as String) { case 'FieldReference': @@ -830,14 +862,19 @@ enum StringLiteralPartType { extension type StringLiteralPart.fromJson(Map node) implements Object { + static final TypedMapSchema _schema = TypedMapSchema({ + 'type': Type.stringPointer, + 'value': Type.anyPointer, + }); static StringLiteralPart stringPart(StringPart stringPart) => - StringLiteralPart.fromJson({'type': 'StringPart', 'value': stringPart}); + StringLiteralPart.fromJson( + Scope.createMap(_schema, 'StringPart', stringPart), + ); static StringLiteralPart interpolationPart( InterpolationPart interpolationPart, - ) => StringLiteralPart.fromJson({ - 'type': 'InterpolationPart', - 'value': interpolationPart, - }); + ) => StringLiteralPart.fromJson( + Scope.createMap(_schema, 'InterpolationPart', interpolationPart), + ); StringLiteralPartType get type { switch (node['type'] as String) { case 'StringPart': @@ -882,60 +919,63 @@ enum TypeAnnotationType { extension type TypeAnnotation.fromJson(Map node) implements Object { + static final TypedMapSchema _schema = TypedMapSchema({ + 'type': Type.stringPointer, + 'value': Type.anyPointer, + }); static TypeAnnotation namedTypeAnnotation( NamedTypeAnnotation namedTypeAnnotation, - ) => TypeAnnotation.fromJson({ - 'type': 'NamedTypeAnnotation', - 'value': namedTypeAnnotation, - }); + ) => TypeAnnotation.fromJson( + Scope.createMap(_schema, 'NamedTypeAnnotation', namedTypeAnnotation), + ); static TypeAnnotation nullableTypeAnnotation( NullableTypeAnnotation nullableTypeAnnotation, - ) => TypeAnnotation.fromJson({ - 'type': 'NullableTypeAnnotation', - 'value': nullableTypeAnnotation, - }); + ) => TypeAnnotation.fromJson( + Scope.createMap(_schema, 'NullableTypeAnnotation', nullableTypeAnnotation), + ); static TypeAnnotation voidTypeAnnotation( VoidTypeAnnotation voidTypeAnnotation, - ) => TypeAnnotation.fromJson({ - 'type': 'VoidTypeAnnotation', - 'value': voidTypeAnnotation, - }); + ) => TypeAnnotation.fromJson( + Scope.createMap(_schema, 'VoidTypeAnnotation', voidTypeAnnotation), + ); static TypeAnnotation dynamicTypeAnnotation( DynamicTypeAnnotation dynamicTypeAnnotation, - ) => TypeAnnotation.fromJson({ - 'type': 'DynamicTypeAnnotation', - 'value': dynamicTypeAnnotation, - }); + ) => TypeAnnotation.fromJson( + Scope.createMap(_schema, 'DynamicTypeAnnotation', dynamicTypeAnnotation), + ); static TypeAnnotation invalidTypeAnnotation( InvalidTypeAnnotation invalidTypeAnnotation, - ) => TypeAnnotation.fromJson({ - 'type': 'InvalidTypeAnnotation', - 'value': invalidTypeAnnotation, - }); + ) => TypeAnnotation.fromJson( + Scope.createMap(_schema, 'InvalidTypeAnnotation', invalidTypeAnnotation), + ); static TypeAnnotation unresolvedTypeAnnotation( UnresolvedTypeAnnotation unresolvedTypeAnnotation, - ) => TypeAnnotation.fromJson({ - 'type': 'UnresolvedTypeAnnotation', - 'value': unresolvedTypeAnnotation, - }); + ) => TypeAnnotation.fromJson( + Scope.createMap( + _schema, + 'UnresolvedTypeAnnotation', + unresolvedTypeAnnotation, + ), + ); static TypeAnnotation functionTypeAnnotation( FunctionTypeAnnotation functionTypeAnnotation, - ) => TypeAnnotation.fromJson({ - 'type': 'FunctionTypeAnnotation', - 'value': functionTypeAnnotation, - }); + ) => TypeAnnotation.fromJson( + Scope.createMap(_schema, 'FunctionTypeAnnotation', functionTypeAnnotation), + ); static TypeAnnotation functionTypeParameterType( FunctionTypeParameterType functionTypeParameterType, - ) => TypeAnnotation.fromJson({ - 'type': 'FunctionTypeParameterType', - 'value': functionTypeParameterType, - }); + ) => TypeAnnotation.fromJson( + Scope.createMap( + _schema, + 'FunctionTypeParameterType', + functionTypeParameterType, + ), + ); static TypeAnnotation recordTypeAnnotation( RecordTypeAnnotation recordTypeAnnotation, - ) => TypeAnnotation.fromJson({ - 'type': 'RecordTypeAnnotation', - 'value': recordTypeAnnotation, - }); + ) => TypeAnnotation.fromJson( + Scope.createMap(_schema, 'RecordTypeAnnotation', recordTypeAnnotation), + ); TypeAnnotationType get type { switch (node['type'] as String) { case 'NamedTypeAnnotation': @@ -1089,8 +1129,11 @@ extension type const UnaryOperator.fromJson(String string) implements Object { /// extension type AdjacentStringLiterals.fromJson(Map node) implements Object { + static final TypedMapSchema _schema = TypedMapSchema({ + 'expressions': Type.closedListPointer, + }); AdjacentStringLiterals({List? expressions}) - : this.fromJson({if (expressions != null) 'expressions': expressions}); + : this.fromJson(Scope.createMap(_schema, expressions)); /// List get expressions => (node['expressions'] as List).cast(); @@ -1099,11 +1142,12 @@ extension type AdjacentStringLiterals.fromJson(Map node) /// extension type AsExpression.fromJson(Map node) implements Object { + static final TypedMapSchema _schema = TypedMapSchema({ + 'expression': Type.typedMapPointer, + 'type': Type.typedMapPointer, + }); AsExpression({Expression? expression, TypeAnnotation? type}) - : this.fromJson({ - if (expression != null) 'expression': expression, - if (type != null) 'type': type, - }); + : this.fromJson(Scope.createMap(_schema, expression, type)); /// Expression get expression => node['expression'] as Expression; @@ -1115,15 +1159,16 @@ extension type AsExpression.fromJson(Map node) /// extension type BinaryExpression.fromJson(Map node) implements Object { + static final TypedMapSchema _schema = TypedMapSchema({ + 'left': Type.typedMapPointer, + 'operator': Type.stringPointer, + 'right': Type.typedMapPointer, + }); BinaryExpression({ Expression? left, BinaryOperator? operator, Expression? right, - }) : this.fromJson({ - if (left != null) 'left': left, - if (operator != null) 'operator': operator, - if (right != null) 'right': right, - }); + }) : this.fromJson(Scope.createMap(_schema, left, operator, right)); /// Expression get left => node['left'] as Expression; @@ -1138,8 +1183,9 @@ extension type BinaryExpression.fromJson(Map node) /// extension type BooleanLiteral.fromJson(Map node) implements Object { + static final TypedMapSchema _schema = TypedMapSchema({'value': Type.boolean}); BooleanLiteral({bool? value}) - : this.fromJson({if (value != null) 'value': value}); + : this.fromJson(Scope.createMap(_schema, value)); /// bool get value => node['value'] as bool; @@ -1148,8 +1194,11 @@ extension type BooleanLiteral.fromJson(Map node) /// extension type ClassReference.fromJson(Map node) implements Object { + static final TypedMapSchema _schema = TypedMapSchema({ + 'name': Type.stringPointer, + }); ClassReference({String? name}) - : this.fromJson({if (name != null) 'name': name}); + : this.fromJson(Scope.createMap(_schema, name)); /// String get name => node['name'] as String; @@ -1158,15 +1207,16 @@ extension type ClassReference.fromJson(Map node) /// extension type ConditionalExpression.fromJson(Map node) implements Object { + static final TypedMapSchema _schema = TypedMapSchema({ + 'condition': Type.typedMapPointer, + 'then': Type.typedMapPointer, + 'otherwise': Type.typedMapPointer, + }); ConditionalExpression({ Expression? condition, Expression? then, Expression? otherwise, - }) : this.fromJson({ - if (condition != null) 'condition': condition, - if (then != null) 'then': then, - if (otherwise != null) 'otherwise': otherwise, - }); + }) : this.fromJson(Scope.createMap(_schema, condition, then, otherwise)); /// Expression get condition => node['condition'] as Expression; @@ -1181,15 +1231,16 @@ extension type ConditionalExpression.fromJson(Map node) /// extension type ConstructorInvocation.fromJson(Map node) implements Object { + static final TypedMapSchema _schema = TypedMapSchema({ + 'type': Type.typedMapPointer, + 'constructor': Type.typedMapPointer, + 'arguments': Type.closedListPointer, + }); ConstructorInvocation({ TypeAnnotation? type, Reference? constructor, List? arguments, - }) : this.fromJson({ - if (type != null) 'type': type, - if (constructor != null) 'constructor': constructor, - if (arguments != null) 'arguments': arguments, - }); + }) : this.fromJson(Scope.createMap(_schema, type, constructor, arguments)); /// TypeAnnotation get type => node['type'] as TypeAnnotation; @@ -1204,8 +1255,11 @@ extension type ConstructorInvocation.fromJson(Map node) /// extension type ConstructorReference.fromJson(Map node) implements Object { + static final TypedMapSchema _schema = TypedMapSchema({ + 'name': Type.stringPointer, + }); ConstructorReference({String? name}) - : this.fromJson({if (name != null) 'name': name}); + : this.fromJson(Scope.createMap(_schema, name)); /// String get name => node['name'] as String; @@ -1214,11 +1268,12 @@ extension type ConstructorReference.fromJson(Map node) /// extension type ConstructorTearOff.fromJson(Map node) implements Object { + static final TypedMapSchema _schema = TypedMapSchema({ + 'type': Type.typedMapPointer, + 'reference': Type.typedMapPointer, + }); ConstructorTearOff({TypeAnnotation? type, ConstructorReference? reference}) - : this.fromJson({ - if (type != null) 'type': type, - if (reference != null) 'reference': reference, - }); + : this.fromJson(Scope.createMap(_schema, type, reference)); /// TypeAnnotation get type => node['type'] as TypeAnnotation; @@ -1231,11 +1286,12 @@ extension type ConstructorTearOff.fromJson(Map node) /// extension type DoubleLiteral.fromJson(Map node) implements Object { + static final TypedMapSchema _schema = TypedMapSchema({ + 'text': Type.stringPointer, + 'value': Type.float64, + }); DoubleLiteral({String? text, double? value}) - : this.fromJson({ - if (text != null) 'text': text, - if (value != null) 'value': value, - }); + : this.fromJson(Scope.createMap(_schema, text, value)); /// String get text => node['text'] as String; @@ -1247,8 +1303,11 @@ extension type DoubleLiteral.fromJson(Map node) /// extension type DynamicTypeAnnotation.fromJson(Map node) implements Object { + static final TypedMapSchema _schema = TypedMapSchema({ + 'reference': Type.typedMapPointer, + }); DynamicTypeAnnotation({Reference? reference}) - : this.fromJson({if (reference != null) 'reference': reference}); + : this.fromJson(Scope.createMap(_schema, reference)); /// Reference get reference => node['reference'] as Reference; @@ -1257,8 +1316,10 @@ extension type DynamicTypeAnnotation.fromJson(Map node) /// extension type EnumReference.fromJson(Map node) implements Object { - EnumReference({String? name}) - : this.fromJson({if (name != null) 'name': name}); + static final TypedMapSchema _schema = TypedMapSchema({ + 'name': Type.stringPointer, + }); + EnumReference({String? name}) : this.fromJson(Scope.createMap(_schema, name)); /// String get name => node['name'] as String; @@ -1267,12 +1328,13 @@ extension type EnumReference.fromJson(Map node) /// extension type EqualityExpression.fromJson(Map node) implements Object { + static final TypedMapSchema _schema = TypedMapSchema({ + 'left': Type.typedMapPointer, + 'right': Type.typedMapPointer, + 'isNotEquals': Type.boolean, + }); EqualityExpression({Expression? left, Expression? right, bool? isNotEquals}) - : this.fromJson({ - if (left != null) 'left': left, - if (right != null) 'right': right, - if (isNotEquals != null) 'isNotEquals': isNotEquals, - }); + : this.fromJson(Scope.createMap(_schema, left, right, isNotEquals)); /// Expression get left => node['left'] as Expression; @@ -1287,11 +1349,12 @@ extension type EqualityExpression.fromJson(Map node) /// extension type ExpressionElement.fromJson(Map node) implements Object { + static final TypedMapSchema _schema = TypedMapSchema({ + 'expression': Type.typedMapPointer, + 'isNullAware': Type.boolean, + }); ExpressionElement({Expression? expression, bool? isNullAware}) - : this.fromJson({ - if (expression != null) 'expression': expression, - if (isNullAware != null) 'isNullAware': isNullAware, - }); + : this.fromJson(Scope.createMap(_schema, expression, isNullAware)); /// Expression get expression => node['expression'] as Expression; @@ -1303,8 +1366,11 @@ extension type ExpressionElement.fromJson(Map node) /// extension type ExtensionReference.fromJson(Map node) implements Object { + static final TypedMapSchema _schema = TypedMapSchema({ + 'name': Type.stringPointer, + }); ExtensionReference({String? name}) - : this.fromJson({if (name != null) 'name': name}); + : this.fromJson(Scope.createMap(_schema, name)); /// String get name => node['name'] as String; @@ -1313,8 +1379,11 @@ extension type ExtensionReference.fromJson(Map node) /// extension type ExtensionTypeReference.fromJson(Map node) implements Object { + static final TypedMapSchema _schema = TypedMapSchema({ + 'name': Type.stringPointer, + }); ExtensionTypeReference({String? name}) - : this.fromJson({if (name != null) 'name': name}); + : this.fromJson(Scope.createMap(_schema, name)); /// String get name => node['name'] as String; @@ -1323,8 +1392,11 @@ extension type ExtensionTypeReference.fromJson(Map node) /// extension type FieldReference.fromJson(Map node) implements Object { + static final TypedMapSchema _schema = TypedMapSchema({ + 'name': Type.stringPointer, + }); FieldReference({String? name}) - : this.fromJson({if (name != null) 'name': name}); + : this.fromJson(Scope.createMap(_schema, name)); /// String get name => node['name'] as String; @@ -1333,20 +1405,25 @@ extension type FieldReference.fromJson(Map node) /// extension type FormalParameter.fromJson(Map node) implements Object { - FormalParameter() : this.fromJson({}); + static final TypedMapSchema _schema = TypedMapSchema({}); + FormalParameter() : this.fromJson(Scope.createMap(_schema)); } /// extension type FormalParameterGroup.fromJson(Map node) implements Object { - FormalParameterGroup() : this.fromJson({}); + static final TypedMapSchema _schema = TypedMapSchema({}); + FormalParameterGroup() : this.fromJson(Scope.createMap(_schema)); } /// extension type FunctionReference.fromJson(Map node) implements Object { + static final TypedMapSchema _schema = TypedMapSchema({ + 'name': Type.stringPointer, + }); FunctionReference({String? name}) - : this.fromJson({if (name != null) 'name': name}); + : this.fromJson(Scope.createMap(_schema, name)); /// String get name => node['name'] as String; @@ -1355,8 +1432,11 @@ extension type FunctionReference.fromJson(Map node) /// extension type FunctionTearOff.fromJson(Map node) implements Object { + static final TypedMapSchema _schema = TypedMapSchema({ + 'reference': Type.typedMapPointer, + }); FunctionTearOff({FunctionReference? reference}) - : this.fromJson({if (reference != null) 'reference': reference}); + : this.fromJson(Scope.createMap(_schema, reference)); /// FunctionReference get reference => node['reference'] as FunctionReference; @@ -1365,15 +1445,18 @@ extension type FunctionTearOff.fromJson(Map node) /// extension type FunctionTypeAnnotation.fromJson(Map node) implements Object { + static final TypedMapSchema _schema = TypedMapSchema({ + 'returnType': Type.typedMapPointer, + 'typeParameters': Type.closedListPointer, + 'formalParameters': Type.closedListPointer, + }); FunctionTypeAnnotation({ TypeAnnotation? returnType, List? typeParameters, List? formalParameters, - }) : this.fromJson({ - if (returnType != null) 'returnType': returnType, - if (typeParameters != null) 'typeParameters': typeParameters, - if (formalParameters != null) 'formalParameters': formalParameters, - }); + }) : this.fromJson( + Scope.createMap(_schema, returnType, typeParameters, formalParameters), + ); /// TypeAnnotation? get returnType => node['returnType'] as TypeAnnotation?; @@ -1390,7 +1473,8 @@ extension type FunctionTypeAnnotation.fromJson(Map node) /// extension type FunctionTypeParameter.fromJson(Map node) implements Object { - FunctionTypeParameter() : this.fromJson({}); + static final TypedMapSchema _schema = TypedMapSchema({}); + FunctionTypeParameter() : this.fromJson(Scope.createMap(_schema)); } /// @@ -1398,8 +1482,11 @@ extension type FunctionTypeParameterReference.fromJson( Map node ) implements Object { + static final TypedMapSchema _schema = TypedMapSchema({ + 'name': Type.stringPointer, + }); FunctionTypeParameterReference({String? name}) - : this.fromJson({if (name != null) 'name': name}); + : this.fromJson(Scope.createMap(_schema, name)); /// String get name => node['name'] as String; @@ -1408,11 +1495,11 @@ extension type FunctionTypeParameterReference.fromJson( /// extension type FunctionTypeParameterType.fromJson(Map node) implements Object { + static final TypedMapSchema _schema = TypedMapSchema({ + 'functionTypeParameter': Type.typedMapPointer, + }); FunctionTypeParameterType({FunctionTypeParameter? functionTypeParameter}) - : this.fromJson({ - if (functionTypeParameter != null) - 'functionTypeParameter': functionTypeParameter, - }); + : this.fromJson(Scope.createMap(_schema, functionTypeParameter)); /// FunctionTypeParameter get functionTypeParameter => @@ -1421,12 +1508,13 @@ extension type FunctionTypeParameterType.fromJson(Map node) /// extension type IfElement.fromJson(Map node) implements Object { + static final TypedMapSchema _schema = TypedMapSchema({ + 'condition': Type.typedMapPointer, + 'then': Type.typedMapPointer, + 'otherwise': Type.typedMapPointer, + }); IfElement({Expression? condition, Element? then, Element? otherwise}) - : this.fromJson({ - if (condition != null) 'condition': condition, - if (then != null) 'then': then, - if (otherwise != null) 'otherwise': otherwise, - }); + : this.fromJson(Scope.createMap(_schema, condition, then, otherwise)); /// Expression get condition => node['condition'] as Expression; @@ -1440,11 +1528,12 @@ extension type IfElement.fromJson(Map node) implements Object { /// extension type IfNull.fromJson(Map node) implements Object { + static final TypedMapSchema _schema = TypedMapSchema({ + 'left': Type.typedMapPointer, + 'right': Type.typedMapPointer, + }); IfNull({Expression? left, Expression? right}) - : this.fromJson({ - if (left != null) 'left': left, - if (right != null) 'right': right, - }); + : this.fromJson(Scope.createMap(_schema, left, right)); /// Expression get left => node['left'] as Expression; @@ -1456,15 +1545,18 @@ extension type IfNull.fromJson(Map node) implements Object { /// extension type ImplicitInvocation.fromJson(Map node) implements Object { + static final TypedMapSchema _schema = TypedMapSchema({ + 'receiver': Type.typedMapPointer, + 'typeArguments': Type.closedListPointer, + 'arguments': Type.closedListPointer, + }); ImplicitInvocation({ Expression? receiver, List? typeArguments, List? arguments, - }) : this.fromJson({ - if (receiver != null) 'receiver': receiver, - if (typeArguments != null) 'typeArguments': typeArguments, - if (arguments != null) 'arguments': arguments, - }); + }) : this.fromJson( + Scope.createMap(_schema, receiver, typeArguments, arguments), + ); /// Expression get receiver => node['receiver'] as Expression; @@ -1480,11 +1572,12 @@ extension type ImplicitInvocation.fromJson(Map node) /// extension type Instantiation.fromJson(Map node) implements Object { + static final TypedMapSchema _schema = TypedMapSchema({ + 'receiver': Type.typedMapPointer, + 'typeArguments': Type.closedListPointer, + }); Instantiation({Expression? receiver, List? typeArguments}) - : this.fromJson({ - if (receiver != null) 'receiver': receiver, - if (typeArguments != null) 'typeArguments': typeArguments, - }); + : this.fromJson(Scope.createMap(_schema, receiver, typeArguments)); /// Expression get receiver => node['receiver'] as Expression; @@ -1497,14 +1590,15 @@ extension type Instantiation.fromJson(Map node) /// extension type IntegerLiteral.fromJson(Map node) implements Object { + static final TypedMapSchema _schema = TypedMapSchema({ + 'text': Type.stringPointer, + 'value': Type.uint32, + }); IntegerLiteral({String? text, int? value}) - : this.fromJson({ - if (text != null) 'text': text, - if (value != null) 'value': value, - }); + : this.fromJson(Scope.createMap(_schema, text, value)); /// - String? get text => node['text'] as String?; + String get text => node['text'] as String; /// int? get value => node['value'] as int?; @@ -1513,8 +1607,11 @@ extension type IntegerLiteral.fromJson(Map node) /// extension type InterpolationPart.fromJson(Map node) implements Object { + static final TypedMapSchema _schema = TypedMapSchema({ + 'expression': Type.typedMapPointer, + }); InterpolationPart({Expression? expression}) - : this.fromJson({if (expression != null) 'expression': expression}); + : this.fromJson(Scope.createMap(_schema, expression)); /// Expression get expression => node['expression'] as Expression; @@ -1523,23 +1620,26 @@ extension type InterpolationPart.fromJson(Map node) /// extension type InvalidExpression.fromJson(Map node) implements Object { - InvalidExpression() : this.fromJson({}); + static final TypedMapSchema _schema = TypedMapSchema({}); + InvalidExpression() : this.fromJson(Scope.createMap(_schema)); } /// extension type InvalidTypeAnnotation.fromJson(Map node) implements Object { - InvalidTypeAnnotation() : this.fromJson({}); + static final TypedMapSchema _schema = TypedMapSchema({}); + InvalidTypeAnnotation() : this.fromJson(Scope.createMap(_schema)); } /// extension type IsTest.fromJson(Map node) implements Object { + static final TypedMapSchema _schema = TypedMapSchema({ + 'expression': Type.typedMapPointer, + 'type': Type.typedMapPointer, + 'isNot': Type.boolean, + }); IsTest({Expression? expression, TypeAnnotation? type, bool? isNot}) - : this.fromJson({ - if (expression != null) 'expression': expression, - if (type != null) 'type': type, - if (isNot != null) 'isNot': isNot, - }); + : this.fromJson(Scope.createMap(_schema, expression, type, isNot)); /// Expression get expression => node['expression'] as Expression; @@ -1554,11 +1654,12 @@ extension type IsTest.fromJson(Map node) implements Object { /// extension type ListLiteral.fromJson(Map node) implements Object { + static final TypedMapSchema _schema = TypedMapSchema({ + 'typeArguments': Type.closedListPointer, + 'elements': Type.closedListPointer, + }); ListLiteral({List? typeArguments, List? elements}) - : this.fromJson({ - if (typeArguments != null) 'typeArguments': typeArguments, - if (elements != null) 'elements': elements, - }); + : this.fromJson(Scope.createMap(_schema, typeArguments, elements)); /// List get typeArguments => @@ -1571,15 +1672,16 @@ extension type ListLiteral.fromJson(Map node) /// extension type LogicalExpression.fromJson(Map node) implements Object { + static final TypedMapSchema _schema = TypedMapSchema({ + 'left': Type.typedMapPointer, + 'operator': Type.stringPointer, + 'right': Type.typedMapPointer, + }); LogicalExpression({ Expression? left, LogicalOperator? operator, Expression? right, - }) : this.fromJson({ - if (left != null) 'left': left, - if (operator != null) 'operator': operator, - if (right != null) 'right': right, - }); + }) : this.fromJson(Scope.createMap(_schema, left, operator, right)); /// Expression get left => node['left'] as Expression; @@ -1594,17 +1696,20 @@ extension type LogicalExpression.fromJson(Map node) /// extension type MapEntryElement.fromJson(Map node) implements Object { + static final TypedMapSchema _schema = TypedMapSchema({ + 'key': Type.typedMapPointer, + 'value': Type.typedMapPointer, + 'isNullAwareKey': Type.boolean, + 'isNullAwareValue': Type.boolean, + }); MapEntryElement({ Expression? key, Expression? value, bool? isNullAwareKey, bool? isNullAwareValue, - }) : this.fromJson({ - if (key != null) 'key': key, - if (value != null) 'value': value, - if (isNullAwareKey != null) 'isNullAwareKey': isNullAwareKey, - if (isNullAwareValue != null) 'isNullAwareValue': isNullAwareValue, - }); + }) : this.fromJson( + Scope.createMap(_schema, key, value, isNullAwareKey, isNullAwareValue), + ); /// Expression get key => node['key'] as Expression; @@ -1622,17 +1727,20 @@ extension type MapEntryElement.fromJson(Map node) /// extension type MethodInvocation.fromJson(Map node) implements Object { + static final TypedMapSchema _schema = TypedMapSchema({ + 'receiver': Type.typedMapPointer, + 'name': Type.stringPointer, + 'typeArguments': Type.closedListPointer, + 'arguments': Type.closedListPointer, + }); MethodInvocation({ Expression? receiver, String? name, List? typeArguments, List? arguments, - }) : this.fromJson({ - if (receiver != null) 'receiver': receiver, - if (name != null) 'name': name, - if (typeArguments != null) 'typeArguments': typeArguments, - if (arguments != null) 'arguments': arguments, - }); + }) : this.fromJson( + Scope.createMap(_schema, receiver, name, typeArguments, arguments), + ); /// Expression get receiver => node['receiver'] as Expression; @@ -1651,8 +1759,11 @@ extension type MethodInvocation.fromJson(Map node) /// extension type MixinReference.fromJson(Map node) implements Object { + static final TypedMapSchema _schema = TypedMapSchema({ + 'name': Type.stringPointer, + }); MixinReference({String? name}) - : this.fromJson({if (name != null) 'name': name}); + : this.fromJson(Scope.createMap(_schema, name)); /// String get name => node['name'] as String; @@ -1661,11 +1772,12 @@ extension type MixinReference.fromJson(Map node) /// extension type NamedArgument.fromJson(Map node) implements Object { + static final TypedMapSchema _schema = TypedMapSchema({ + 'name': Type.stringPointer, + 'expression': Type.typedMapPointer, + }); NamedArgument({String? name, Expression? expression}) - : this.fromJson({ - if (name != null) 'name': name, - if (expression != null) 'expression': expression, - }); + : this.fromJson(Scope.createMap(_schema, name, expression)); /// String get name => node['name'] as String; @@ -1677,13 +1789,14 @@ extension type NamedArgument.fromJson(Map node) /// extension type NamedTypeAnnotation.fromJson(Map node) implements Object { + static final TypedMapSchema _schema = TypedMapSchema({ + 'reference': Type.typedMapPointer, + 'typeArguments': Type.closedListPointer, + }); NamedTypeAnnotation({ Reference? reference, List? typeArguments, - }) : this.fromJson({ - if (reference != null) 'reference': reference, - if (typeArguments != null) 'typeArguments': typeArguments, - }); + }) : this.fromJson(Scope.createMap(_schema, reference, typeArguments)); /// Reference get reference => node['reference'] as Reference; @@ -1696,10 +1809,11 @@ extension type NamedTypeAnnotation.fromJson(Map node) /// extension type NullableTypeAnnotation.fromJson(Map node) implements Object { + static final TypedMapSchema _schema = TypedMapSchema({ + 'typeAnnotation': Type.typedMapPointer, + }); NullableTypeAnnotation({TypeAnnotation? typeAnnotation}) - : this.fromJson({ - if (typeAnnotation != null) 'typeAnnotation': typeAnnotation, - }); + : this.fromJson(Scope.createMap(_schema, typeAnnotation)); /// TypeAnnotation get typeAnnotation => node['typeAnnotation'] as TypeAnnotation; @@ -1708,11 +1822,12 @@ extension type NullableTypeAnnotation.fromJson(Map node) /// extension type NullAwarePropertyGet.fromJson(Map node) implements Object { + static final TypedMapSchema _schema = TypedMapSchema({ + 'receiver': Type.typedMapPointer, + 'name': Type.stringPointer, + }); NullAwarePropertyGet({Expression? receiver, String? name}) - : this.fromJson({ - if (receiver != null) 'receiver': receiver, - if (name != null) 'name': name, - }); + : this.fromJson(Scope.createMap(_schema, receiver, name)); /// Expression get receiver => node['receiver'] as Expression; @@ -1723,8 +1838,11 @@ extension type NullAwarePropertyGet.fromJson(Map node) /// extension type NullCheck.fromJson(Map node) implements Object { + static final TypedMapSchema _schema = TypedMapSchema({ + 'expression': Type.typedMapPointer, + }); NullCheck({Expression? expression}) - : this.fromJson({if (expression != null) 'expression': expression}); + : this.fromJson(Scope.createMap(_schema, expression)); /// Expression get expression => node['expression'] as Expression; @@ -1733,14 +1851,18 @@ extension type NullCheck.fromJson(Map node) implements Object { /// extension type NullLiteral.fromJson(Map node) implements Object { - NullLiteral() : this.fromJson({}); + static final TypedMapSchema _schema = TypedMapSchema({}); + NullLiteral() : this.fromJson(Scope.createMap(_schema)); } /// extension type ParenthesizedExpression.fromJson(Map node) implements Object { + static final TypedMapSchema _schema = TypedMapSchema({ + 'expression': Type.typedMapPointer, + }); ParenthesizedExpression({Expression? expression}) - : this.fromJson({if (expression != null) 'expression': expression}); + : this.fromJson(Scope.createMap(_schema, expression)); /// Expression get expression => node['expression'] as Expression; @@ -1749,8 +1871,11 @@ extension type ParenthesizedExpression.fromJson(Map node) /// extension type PositionalArgument.fromJson(Map node) implements Object { + static final TypedMapSchema _schema = TypedMapSchema({ + 'expression': Type.typedMapPointer, + }); PositionalArgument({Expression? expression}) - : this.fromJson({if (expression != null) 'expression': expression}); + : this.fromJson(Scope.createMap(_schema, expression)); /// Expression get expression => node['expression'] as Expression; @@ -1759,11 +1884,12 @@ extension type PositionalArgument.fromJson(Map node) /// extension type PropertyGet.fromJson(Map node) implements Object { + static final TypedMapSchema _schema = TypedMapSchema({ + 'receiver': Type.typedMapPointer, + 'name': Type.stringPointer, + }); PropertyGet({Expression? receiver, String? name}) - : this.fromJson({ - if (receiver != null) 'receiver': receiver, - if (name != null) 'name': name, - }); + : this.fromJson(Scope.createMap(_schema, receiver, name)); /// Expression get receiver => node['receiver'] as Expression; @@ -1775,8 +1901,11 @@ extension type PropertyGet.fromJson(Map node) /// extension type RecordLiteral.fromJson(Map node) implements Object { + static final TypedMapSchema _schema = TypedMapSchema({ + 'fields': Type.closedListPointer, + }); RecordLiteral({List? fields}) - : this.fromJson({if (fields != null) 'fields': fields}); + : this.fromJson(Scope.createMap(_schema, fields)); /// List get fields => (node['fields'] as List).cast(); @@ -1785,11 +1914,12 @@ extension type RecordLiteral.fromJson(Map node) /// extension type RecordNamedField.fromJson(Map node) implements Object { + static final TypedMapSchema _schema = TypedMapSchema({ + 'name': Type.stringPointer, + 'expression': Type.typedMapPointer, + }); RecordNamedField({String? name, Expression? expression}) - : this.fromJson({ - if (name != null) 'name': name, - if (expression != null) 'expression': expression, - }); + : this.fromJson(Scope.createMap(_schema, name, expression)); /// String get name => node['name'] as String; @@ -1801,8 +1931,11 @@ extension type RecordNamedField.fromJson(Map node) /// extension type RecordPositionalField.fromJson(Map node) implements Object { + static final TypedMapSchema _schema = TypedMapSchema({ + 'expression': Type.typedMapPointer, + }); RecordPositionalField({Expression? expression}) - : this.fromJson({if (expression != null) 'expression': expression}); + : this.fromJson(Scope.createMap(_schema, expression)); /// Expression get expression => node['expression'] as Expression; @@ -1811,13 +1944,14 @@ extension type RecordPositionalField.fromJson(Map node) /// extension type RecordTypeAnnotation.fromJson(Map node) implements Object { + static final TypedMapSchema _schema = TypedMapSchema({ + 'positional': Type.closedListPointer, + 'named': Type.closedListPointer, + }); RecordTypeAnnotation({ List? positional, List? named, - }) : this.fromJson({ - if (positional != null) 'positional': positional, - if (named != null) 'named': named, - }); + }) : this.fromJson(Scope.createMap(_schema, positional, named)); /// List get positional => (node['positional'] as List).cast(); @@ -1829,25 +1963,28 @@ extension type RecordTypeAnnotation.fromJson(Map node) /// extension type RecordTypeEntry.fromJson(Map node) implements Object { - RecordTypeEntry() : this.fromJson({}); + static final TypedMapSchema _schema = TypedMapSchema({}); + RecordTypeEntry() : this.fromJson(Scope.createMap(_schema)); } /// extension type References.fromJson(Map node) implements Object { - References() : this.fromJson({}); + static final TypedMapSchema _schema = TypedMapSchema({}); + References() : this.fromJson(Scope.createMap(_schema)); } /// extension type SetOrMapLiteral.fromJson(Map node) implements Object { + static final TypedMapSchema _schema = TypedMapSchema({ + 'typeArguments': Type.closedListPointer, + 'elements': Type.closedListPointer, + }); SetOrMapLiteral({ List? typeArguments, List? elements, - }) : this.fromJson({ - if (typeArguments != null) 'typeArguments': typeArguments, - if (elements != null) 'elements': elements, - }); + }) : this.fromJson(Scope.createMap(_schema, typeArguments, elements)); /// List get typeArguments => @@ -1860,11 +1997,12 @@ extension type SetOrMapLiteral.fromJson(Map node) /// extension type SpreadElement.fromJson(Map node) implements Object { + static final TypedMapSchema _schema = TypedMapSchema({ + 'expression': Type.typedMapPointer, + 'isNullAware': Type.boolean, + }); SpreadElement({Expression? expression, bool? isNullAware}) - : this.fromJson({ - if (expression != null) 'expression': expression, - if (isNullAware != null) 'isNullAware': isNullAware, - }); + : this.fromJson(Scope.createMap(_schema, expression, isNullAware)); /// Expression get expression => node['expression'] as Expression; @@ -1875,8 +2013,11 @@ extension type SpreadElement.fromJson(Map node) /// extension type StaticGet.fromJson(Map node) implements Object { + static final TypedMapSchema _schema = TypedMapSchema({ + 'reference': Type.typedMapPointer, + }); StaticGet({FieldReference? reference}) - : this.fromJson({if (reference != null) 'reference': reference}); + : this.fromJson(Scope.createMap(_schema, reference)); /// FieldReference get reference => node['reference'] as FieldReference; @@ -1885,15 +2026,18 @@ extension type StaticGet.fromJson(Map node) implements Object { /// extension type StaticInvocation.fromJson(Map node) implements Object { + static final TypedMapSchema _schema = TypedMapSchema({ + 'function': Type.typedMapPointer, + 'typeArguments': Type.closedListPointer, + 'arguments': Type.closedListPointer, + }); StaticInvocation({ FunctionReference? function, List? typeArguments, List? arguments, - }) : this.fromJson({ - if (function != null) 'function': function, - if (typeArguments != null) 'typeArguments': typeArguments, - if (arguments != null) 'arguments': arguments, - }); + }) : this.fromJson( + Scope.createMap(_schema, function, typeArguments, arguments), + ); /// FunctionReference get function => node['function'] as FunctionReference; @@ -1909,8 +2053,11 @@ extension type StaticInvocation.fromJson(Map node) /// extension type StringLiteral.fromJson(Map node) implements Object { + static final TypedMapSchema _schema = TypedMapSchema({ + 'parts': Type.closedListPointer, + }); StringLiteral({List? parts}) - : this.fromJson({if (parts != null) 'parts': parts}); + : this.fromJson(Scope.createMap(_schema, parts)); /// List get parts => (node['parts'] as List).cast(); @@ -1919,7 +2066,10 @@ extension type StringLiteral.fromJson(Map node) /// extension type StringPart.fromJson(Map node) implements Object { - StringPart({String? text}) : this.fromJson({if (text != null) 'text': text}); + static final TypedMapSchema _schema = TypedMapSchema({ + 'text': Type.stringPointer, + }); + StringPart({String? text}) : this.fromJson(Scope.createMap(_schema, text)); /// String get text => node['text'] as String; @@ -1928,8 +2078,11 @@ extension type StringPart.fromJson(Map node) /// extension type SymbolLiteral.fromJson(Map node) implements Object { + static final TypedMapSchema _schema = TypedMapSchema({ + 'parts': Type.closedListPointer, + }); SymbolLiteral({List? parts}) - : this.fromJson({if (parts != null) 'parts': parts}); + : this.fromJson(Scope.createMap(_schema, parts)); /// List get parts => (node['parts'] as List).cast(); @@ -1938,8 +2091,11 @@ extension type SymbolLiteral.fromJson(Map node) /// extension type TypedefReference.fromJson(Map node) implements Object { + static final TypedMapSchema _schema = TypedMapSchema({ + 'name': Type.stringPointer, + }); TypedefReference({String? name}) - : this.fromJson({if (name != null) 'name': name}); + : this.fromJson(Scope.createMap(_schema, name)); /// String get name => node['name'] as String; @@ -1948,10 +2104,11 @@ extension type TypedefReference.fromJson(Map node) /// extension type TypeLiteral.fromJson(Map node) implements Object { + static final TypedMapSchema _schema = TypedMapSchema({ + 'typeAnnotation': Type.typedMapPointer, + }); TypeLiteral({TypeAnnotation? typeAnnotation}) - : this.fromJson({ - if (typeAnnotation != null) 'typeAnnotation': typeAnnotation, - }); + : this.fromJson(Scope.createMap(_schema, typeAnnotation)); /// TypeAnnotation get typeAnnotation => node['typeAnnotation'] as TypeAnnotation; @@ -1960,17 +2117,19 @@ extension type TypeLiteral.fromJson(Map node) /// extension type TypeReference.fromJson(Map node) implements Object { - TypeReference() : this.fromJson({}); + static final TypedMapSchema _schema = TypedMapSchema({}); + TypeReference() : this.fromJson(Scope.createMap(_schema)); } /// extension type UnaryExpression.fromJson(Map node) implements Object { + static final TypedMapSchema _schema = TypedMapSchema({ + 'operator': Type.stringPointer, + 'expression': Type.typedMapPointer, + }); UnaryExpression({UnaryOperator? operator, Expression? expression}) - : this.fromJson({ - if (operator != null) 'operator': operator, - if (expression != null) 'expression': expression, - }); + : this.fromJson(Scope.createMap(_schema, operator, expression)); /// UnaryOperator get operator => node['operator'] as UnaryOperator; @@ -1982,20 +2141,25 @@ extension type UnaryExpression.fromJson(Map node) /// extension type UnresolvedExpression.fromJson(Map node) implements Object { - UnresolvedExpression() : this.fromJson({}); + static final TypedMapSchema _schema = TypedMapSchema({}); + UnresolvedExpression() : this.fromJson(Scope.createMap(_schema)); } /// extension type UnresolvedTypeAnnotation.fromJson(Map node) implements Object { - UnresolvedTypeAnnotation() : this.fromJson({}); + static final TypedMapSchema _schema = TypedMapSchema({}); + UnresolvedTypeAnnotation() : this.fromJson(Scope.createMap(_schema)); } /// extension type VoidTypeAnnotation.fromJson(Map node) implements Object { + static final TypedMapSchema _schema = TypedMapSchema({ + 'reference': Type.typedMapPointer, + }); VoidTypeAnnotation({Reference? reference}) - : this.fromJson({if (reference != null) 'reference': reference}); + : this.fromJson(Scope.createMap(_schema, reference)); /// Reference get reference => node['reference'] as Reference; diff --git a/schemas/macro_metadata.schema.json b/schemas/macro_metadata.schema.json index c39283ea..c7ee70d2 100644 --- a/schemas/macro_metadata.schema.json +++ b/schemas/macro_metadata.schema.json @@ -459,7 +459,7 @@ "description": "" }, "value": { - "type": "double", + "type": "number", "description": "" } } diff --git a/tool/dart_model_generator/lib/generate_dart_model.dart b/tool/dart_model_generator/lib/generate_dart_model.dart index 552dcfe9..0077eccd 100644 --- a/tool/dart_model_generator/lib/generate_dart_model.dart +++ b/tool/dart_model_generator/lib/generate_dart_model.dart @@ -414,6 +414,8 @@ class TypeReference { return 'Type.boolean'; } else if (name == 'int') { return 'Type.uint32'; + } else if (name == 'double') { + return 'Type.float64'; } else { final representationType = context.lookupDefinition(name).representationTypeName; @@ -461,7 +463,7 @@ class TypeReference { }; } else if (name == 'double') { return { - 'type': 'double', + 'type': 'number', if (description != null) 'description': description, }; } diff --git a/tool/dart_model_generator/lib/macro_metadata_definitions.dart b/tool/dart_model_generator/lib/macro_metadata_definitions.dart index 43096a40..b26a56ae 100644 --- a/tool/dart_model_generator/lib/macro_metadata_definitions.dart +++ b/tool/dart_model_generator/lib/macro_metadata_definitions.dart @@ -11,12 +11,14 @@ import 'generate_dart_model.dart'; final definitions = [ Definition.union( 'Argument', + createInBuffer: true, description: '', types: ['PositionalArgument', 'NamedArgument'], properties: [], ), Definition.union( 'Element', + createInBuffer: true, description: '', types: [ 'ExpressionElement', @@ -28,6 +30,7 @@ final definitions = [ ), Definition.union( 'Expression', + createInBuffer: true, description: '', types: [ 'InvalidExpression', @@ -68,12 +71,14 @@ final definitions = [ ), Definition.union( 'RecordField', + createInBuffer: true, description: '', types: ['RecordNamedField', 'RecordPositionalField'], properties: [], ), Definition.union( 'Reference', + createInBuffer: true, description: '', types: [ 'FieldReference', @@ -92,12 +97,14 @@ final definitions = [ ), Definition.union( 'StringLiteralPart', + createInBuffer: true, description: '', types: ['StringPart', 'InterpolationPart'], properties: [], ), Definition.union( 'TypeAnnotation', + createInBuffer: true, description: '', types: [ 'NamedTypeAnnotation', @@ -142,6 +149,7 @@ final definitions = [ ), Definition.clazz( 'AdjacentStringLiterals', + createInBuffer: true, description: '', properties: [ Property('expressions', type: 'List', description: ''), @@ -149,6 +157,7 @@ final definitions = [ ), Definition.clazz( 'AsExpression', + createInBuffer: true, description: '', properties: [ Property('expression', type: 'Expression', description: ''), @@ -157,6 +166,7 @@ final definitions = [ ), Definition.clazz( 'BinaryExpression', + createInBuffer: true, description: '', properties: [ Property('left', type: 'Expression', description: ''), @@ -166,16 +176,19 @@ final definitions = [ ), Definition.clazz( 'BooleanLiteral', + createInBuffer: true, description: '', properties: [Property('value', type: 'bool', description: '')], ), Definition.clazz( 'ClassReference', + createInBuffer: true, description: '', properties: [Property('name', type: 'String', description: '')], ), Definition.clazz( 'ConditionalExpression', + createInBuffer: true, description: '', properties: [ Property('condition', type: 'Expression', description: ''), @@ -185,6 +198,7 @@ final definitions = [ ), Definition.clazz( 'ConstructorInvocation', + createInBuffer: true, description: '', properties: [ Property('type', type: 'TypeAnnotation', description: ''), @@ -194,11 +208,13 @@ final definitions = [ ), Definition.clazz( 'ConstructorReference', + createInBuffer: true, description: '', properties: [Property('name', type: 'String', description: '')], ), Definition.clazz( 'ConstructorTearOff', + createInBuffer: true, description: '', properties: [ Property('type', type: 'TypeAnnotation', description: ''), @@ -207,6 +223,7 @@ final definitions = [ ), Definition.clazz( 'DoubleLiteral', + createInBuffer: true, description: '', properties: [ Property('text', type: 'String', description: ''), @@ -215,16 +232,19 @@ final definitions = [ ), Definition.clazz( 'DynamicTypeAnnotation', + createInBuffer: true, description: '', properties: [Property('reference', type: 'Reference', description: '')], ), Definition.clazz( 'EnumReference', + createInBuffer: true, description: '', properties: [Property('name', type: 'String', description: '')], ), Definition.clazz( 'EqualityExpression', + createInBuffer: true, description: '', properties: [ Property('left', type: 'Expression', description: ''), @@ -234,6 +254,7 @@ final definitions = [ ), Definition.clazz( 'ExpressionElement', + createInBuffer: true, description: '', properties: [ Property('expression', type: 'Expression', description: ''), @@ -242,32 +263,43 @@ final definitions = [ ), Definition.clazz( 'ExtensionReference', + createInBuffer: true, description: '', properties: [Property('name', type: 'String', description: '')], ), Definition.clazz( 'ExtensionTypeReference', + createInBuffer: true, description: '', properties: [Property('name', type: 'String', description: '')], ), Definition.clazz( 'FieldReference', + createInBuffer: true, description: '', properties: [Property('name', type: 'String', description: '')], ), - Definition.clazz('FormalParameter', description: '', properties: [ - ], -), - Definition.clazz('FormalParameterGroup', description: '', properties: [ - ], -), + Definition.clazz( + 'FormalParameter', + createInBuffer: true, + description: '', + properties: [], + ), + Definition.clazz( + 'FormalParameterGroup', + createInBuffer: true, + description: '', + properties: [], + ), Definition.clazz( 'FunctionReference', + createInBuffer: true, description: '', properties: [Property('name', type: 'String', description: '')], ), Definition.clazz( 'FunctionTearOff', + createInBuffer: true, description: '', properties: [ Property('reference', type: 'FunctionReference', description: ''), @@ -275,6 +307,7 @@ final definitions = [ ), Definition.clazz( 'FunctionTypeAnnotation', + createInBuffer: true, description: '', properties: [ Property( @@ -295,16 +328,21 @@ final definitions = [ ), ], ), - Definition.clazz('FunctionTypeParameter', description: '', properties: [ - ], -), + Definition.clazz( + 'FunctionTypeParameter', + createInBuffer: true, + description: '', + properties: [], + ), Definition.clazz( 'FunctionTypeParameterReference', + createInBuffer: true, description: '', properties: [Property('name', type: 'String', description: '')], ), Definition.clazz( 'FunctionTypeParameterType', + createInBuffer: true, description: '', properties: [ Property( @@ -316,6 +354,7 @@ final definitions = [ ), Definition.clazz( 'IfElement', + createInBuffer: true, description: '', properties: [ Property('condition', type: 'Expression', description: ''), @@ -325,6 +364,7 @@ final definitions = [ ), Definition.clazz( 'IfNull', + createInBuffer: true, description: '', properties: [ Property('left', type: 'Expression', description: ''), @@ -333,6 +373,7 @@ final definitions = [ ), Definition.clazz( 'ImplicitInvocation', + createInBuffer: true, description: '', properties: [ Property('receiver', type: 'Expression', description: ''), @@ -342,6 +383,7 @@ final definitions = [ ), Definition.clazz( 'Instantiation', + createInBuffer: true, description: '', properties: [ Property('receiver', type: 'Expression', description: ''), @@ -350,25 +392,34 @@ final definitions = [ ), Definition.clazz( 'IntegerLiteral', + createInBuffer: true, description: '', properties: [ - Property('text', type: 'String', description: '', nullable: true), + Property('text', type: 'String', description: ''), Property('value', type: 'int', description: '', nullable: true), ], ), Definition.clazz( 'InterpolationPart', + createInBuffer: true, description: '', properties: [Property('expression', type: 'Expression', description: '')], ), - Definition.clazz('InvalidExpression', description: '', properties: [ - ], -), - Definition.clazz('InvalidTypeAnnotation', description: '', properties: [ - ], -), + Definition.clazz( + 'InvalidExpression', + createInBuffer: true, + description: '', + properties: [], + ), + Definition.clazz( + 'InvalidTypeAnnotation', + createInBuffer: true, + description: '', + properties: [], + ), Definition.clazz( 'IsTest', + createInBuffer: true, description: '', properties: [ Property('expression', type: 'Expression', description: ''), @@ -378,6 +429,7 @@ final definitions = [ ), Definition.clazz( 'ListLiteral', + createInBuffer: true, description: '', properties: [ Property('typeArguments', type: 'List', description: ''), @@ -386,6 +438,7 @@ final definitions = [ ), Definition.clazz( 'LogicalExpression', + createInBuffer: true, description: '', properties: [ Property('left', type: 'Expression', description: ''), @@ -395,6 +448,7 @@ final definitions = [ ), Definition.clazz( 'MapEntryElement', + createInBuffer: true, description: '', properties: [ Property('key', type: 'Expression', description: ''), @@ -405,6 +459,7 @@ final definitions = [ ), Definition.clazz( 'MethodInvocation', + createInBuffer: true, description: '', properties: [ Property('receiver', type: 'Expression', description: ''), @@ -415,11 +470,13 @@ final definitions = [ ), Definition.clazz( 'MixinReference', + createInBuffer: true, description: '', properties: [Property('name', type: 'String', description: '')], ), Definition.clazz( 'NamedArgument', + createInBuffer: true, description: '', properties: [ Property('name', type: 'String', description: ''), @@ -428,6 +485,7 @@ final definitions = [ ), Definition.clazz( 'NamedTypeAnnotation', + createInBuffer: true, description: '', properties: [ Property('reference', type: 'Reference', description: ''), @@ -436,6 +494,7 @@ final definitions = [ ), Definition.clazz( 'NullableTypeAnnotation', + createInBuffer: true, description: '', properties: [ Property('typeAnnotation', type: 'TypeAnnotation', description: ''), @@ -443,6 +502,7 @@ final definitions = [ ), Definition.clazz( 'NullAwarePropertyGet', + createInBuffer: true, description: '', properties: [ Property('receiver', type: 'Expression', description: ''), @@ -451,24 +511,31 @@ final definitions = [ ), Definition.clazz( 'NullCheck', + createInBuffer: true, description: '', properties: [Property('expression', type: 'Expression', description: '')], ), - Definition.clazz('NullLiteral', description: '', properties: [ - ], -), + Definition.clazz( + 'NullLiteral', + createInBuffer: true, + description: '', + properties: [], + ), Definition.clazz( 'ParenthesizedExpression', + createInBuffer: true, description: '', properties: [Property('expression', type: 'Expression', description: '')], ), Definition.clazz( 'PositionalArgument', + createInBuffer: true, description: '', properties: [Property('expression', type: 'Expression', description: '')], ), Definition.clazz( 'PropertyGet', + createInBuffer: true, description: '', properties: [ Property('receiver', type: 'Expression', description: ''), @@ -477,6 +544,7 @@ final definitions = [ ), Definition.clazz( 'RecordLiteral', + createInBuffer: true, description: '', properties: [ Property('fields', type: 'List', description: ''), @@ -484,6 +552,7 @@ final definitions = [ ), Definition.clazz( 'RecordNamedField', + createInBuffer: true, description: '', properties: [ Property('name', type: 'String', description: ''), @@ -492,25 +561,34 @@ final definitions = [ ), Definition.clazz( 'RecordPositionalField', + createInBuffer: true, description: '', properties: [Property('expression', type: 'Expression', description: '')], ), Definition.clazz( 'RecordTypeAnnotation', + createInBuffer: true, description: '', properties: [ Property('positional', type: 'List', description: ''), Property('named', type: 'List', description: ''), ], ), - Definition.clazz('RecordTypeEntry', description: '', properties: [ - ], -), - Definition.clazz('References', description: '', properties: [ - ], -), + Definition.clazz( + 'RecordTypeEntry', + createInBuffer: true, + description: '', + properties: [], + ), + Definition.clazz( + 'References', + createInBuffer: true, + description: '', + properties: [], + ), Definition.clazz( 'SetOrMapLiteral', + createInBuffer: true, description: '', properties: [ Property('typeArguments', type: 'List', description: ''), @@ -519,6 +597,7 @@ final definitions = [ ), Definition.clazz( 'SpreadElement', + createInBuffer: true, description: '', properties: [ Property('expression', type: 'Expression', description: ''), @@ -527,6 +606,7 @@ final definitions = [ ), Definition.clazz( 'StaticGet', + createInBuffer: true, description: '', properties: [ Property('reference', type: 'FieldReference', description: ''), @@ -534,6 +614,7 @@ final definitions = [ ), Definition.clazz( 'StaticInvocation', + createInBuffer: true, description: '', properties: [ Property('function', type: 'FunctionReference', description: ''), @@ -543,6 +624,7 @@ final definitions = [ ), Definition.clazz( 'StringLiteral', + createInBuffer: true, description: '', properties: [ Property('parts', type: 'List', description: ''), @@ -550,45 +632,60 @@ final definitions = [ ), Definition.clazz( 'StringPart', + createInBuffer: true, description: '', properties: [Property('text', type: 'String', description: '')], ), Definition.clazz( 'SymbolLiteral', + createInBuffer: true, description: '', properties: [Property('parts', type: 'List', description: '')], ), Definition.clazz( 'TypedefReference', + createInBuffer: true, description: '', properties: [Property('name', type: 'String', description: '')], ), Definition.clazz( 'TypeLiteral', + createInBuffer: true, description: '', properties: [ Property('typeAnnotation', type: 'TypeAnnotation', description: ''), ], ), - Definition.clazz('TypeReference', description: '', properties: [ - ], -), + Definition.clazz( + 'TypeReference', + createInBuffer: true, + description: '', + properties: [], + ), Definition.clazz( 'UnaryExpression', + createInBuffer: true, description: '', properties: [ Property('operator', type: 'UnaryOperator', description: ''), Property('expression', type: 'Expression', description: ''), ], ), - Definition.clazz('UnresolvedExpression', description: '', properties: [ - ], -), - Definition.clazz('UnresolvedTypeAnnotation', description: '', properties: [ - ], -), + Definition.clazz( + 'UnresolvedExpression', + createInBuffer: true, + description: '', + properties: [], + ), + Definition.clazz( + 'UnresolvedTypeAnnotation', + createInBuffer: true, + description: '', + properties: [], + ), Definition.clazz( 'VoidTypeAnnotation', + createInBuffer: true, description: '', properties: [Property('reference', type: 'Reference', description: '')], ), diff --git a/tool/generate_definitions b/tool/generate_definitions index 1ff315f7..1e1980d7 100755 --- a/tool/generate_definitions +++ b/tool/generate_definitions @@ -24,6 +24,7 @@ for union in $( | sed -e 's# {##' \ | sort); do echo "Definition.union('$union'," + echo " createInBuffer: true," echo " description: ''," echo " types: [" for type in $(echo "$source" \ @@ -71,6 +72,7 @@ for type in $(echo "$source" \ | sed -e 's# {##' \ | sort); do echo "Definition.clazz('$type'," + echo " createInBuffer: true," echo " description: ''," echo " properties: [" for line in $(echo "$source" \ From 23860ee21af4b3789066ea206756b786d892db3a Mon Sep 17 00:00:00 2001 From: Karol Czeryna Date: Tue, 10 Dec 2024 12:30:10 +0100 Subject: [PATCH 3/5] ensure only fields of types annotated with BuiltValue are nested builders --- .../foo/lib/built_value/built_value_test.dart | 21 +++++++++++++++++-- pkgs/_test_macros/lib/built_value.dart | 17 +++++++++++++-- 2 files changed, 34 insertions(+), 4 deletions(-) diff --git a/goldens/foo/lib/built_value/built_value_test.dart b/goldens/foo/lib/built_value/built_value_test.dart index c8745062..6f14c30d 100644 --- a/goldens/foo/lib/built_value/built_value_test.dart +++ b/goldens/foo/lib/built_value/built_value_test.dart @@ -54,17 +54,33 @@ void main() { b ..aPrimitiveFields.anInt = 3 ..aPrimitiveFields.aString = 'four' - ..aString = 'five', + ..aString = 'five' + ..stringWrapper = StringWraper('six'), ); expect( value.toString(), 'NestedFields(aPrimitiveFields: PrimitiveFields(' - 'anInt: 3, aString: four, aNullableString: null), aString: five)', + 'anInt: 3, aString: four, aNullableString: null), ' + 'stringWrapper: StringWrapper(aString: six), aString: five)', ); }); }); } +class NonMacro { + const NonMacro(); +} + +@NonMacro() +class StringWraper { + const StringWraper(this.aString); + + final String aString; + + @override + String toString() => 'StringWrapper(aString: $aString)'; +} + @BuiltValue() class Empty {} @@ -78,5 +94,6 @@ class PrimitiveFields { @BuiltValue() class NestedFields { final PrimitiveFields aPrimitiveFields; + final StringWraper stringWrapper; final String aString; } diff --git a/pkgs/_test_macros/lib/built_value.dart b/pkgs/_test_macros/lib/built_value.dart index f928f427..81c8efeb 100644 --- a/pkgs/_test_macros/lib/built_value.dart +++ b/pkgs/_test_macros/lib/built_value.dart @@ -3,6 +3,7 @@ // BSD-style license that can be found in the LICENSE file. import 'dart:async'; +import 'dart:io'; import 'package:dart_model/dart_model.dart'; // ignore: implementation_imports @@ -183,8 +184,20 @@ class BuiltValueBuilderImplementation implements ClassDeclarationsMacro { TypeAnnotationType.namedTypeAnnotation) { continue; } - // TODO(davidmorgan): macro metadata model doesn't actually have the - // name yet, just assume any constructor annotation is `BuiltValue`. + + final namedTypeAnnotation = + constructorInvocation.type.asNamedTypeAnnotation; + if (namedTypeAnnotation.reference.type != + ReferenceType.classReference) { + continue; + } + + final constructorReference = + namedTypeAnnotation.reference.asClassReference; + if (constructorReference.name != 'BuiltValue') { + continue; + } + nestedBuilderTypes.add(qualifiedName.asString); } } From adb2a64465577c3ec2de13b28275ba3ea29f01e4 Mon Sep 17 00:00:00 2001 From: Karol Czeryna Date: Tue, 10 Dec 2024 12:30:19 +0100 Subject: [PATCH 4/5] remove redundant import --- pkgs/_test_macros/lib/built_value.dart | 1 - pkgs/dart_model/lib/src/json_buffer/json_buffer_builder.dart | 1 - 2 files changed, 2 deletions(-) diff --git a/pkgs/_test_macros/lib/built_value.dart b/pkgs/_test_macros/lib/built_value.dart index 81c8efeb..1784f698 100644 --- a/pkgs/_test_macros/lib/built_value.dart +++ b/pkgs/_test_macros/lib/built_value.dart @@ -3,7 +3,6 @@ // BSD-style license that can be found in the LICENSE file. import 'dart:async'; -import 'dart:io'; import 'package:dart_model/dart_model.dart'; // ignore: implementation_imports diff --git a/pkgs/dart_model/lib/src/json_buffer/json_buffer_builder.dart b/pkgs/dart_model/lib/src/json_buffer/json_buffer_builder.dart index 5bf0898e..01e2cc91 100644 --- a/pkgs/dart_model/lib/src/json_buffer/json_buffer_builder.dart +++ b/pkgs/dart_model/lib/src/json_buffer/json_buffer_builder.dart @@ -4,7 +4,6 @@ import 'dart:collection'; import 'dart:convert'; -import 'dart:io'; import 'dart:typed_data'; import 'package:convert/convert.dart'; From 74a13bad976df4674e31a92a5d8a17243401d5c4 Mon Sep 17 00:00:00 2001 From: Karol Czeryna Date: Tue, 10 Dec 2024 13:20:42 +0100 Subject: [PATCH 5/5] fix typo, sync build_value test goldens --- .../built_value_test.analyzer.augmentations | 14 +++++++------- goldens/foo/lib/built_value/built_value_test.dart | 8 ++++---- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/goldens/foo/lib/built_value/built_value_test.analyzer.augmentations b/goldens/foo/lib/built_value/built_value_test.analyzer.augmentations index 38674ffb..ee6f23e6 100644 --- a/goldens/foo/lib/built_value/built_value_test.analyzer.augmentations +++ b/goldens/foo/lib/built_value/built_value_test.analyzer.augmentations @@ -50,26 +50,26 @@ prefix1.PrimitiveFields rebuild(void Function(prefix1.PrimitiveFieldsBuilder) up augment class NestedFields { factory NestedFields([void Function(prefix1.NestedFieldsBuilder)? updates]) => (prefix1.NestedFieldsBuilder()..update(updates)).build(); -NestedFields._({required this.aPrimitiveFields,required this.aString,}) {} +NestedFields._({required this.aPrimitiveFields,required this.stringWrapper,required this.aString,}) {} prefix1.NestedFieldsBuilder toBuilder() => prefix1.NestedFieldsBuilder()..replace(this); prefix1.NestedFields rebuild(void Function(prefix1.NestedFieldsBuilder) updates) => (toBuilder()..update(updates)).build(); - prefix2.int get hashCode => prefix2.Object.hashAll([aPrimitiveFields,aString,]); + prefix2.int get hashCode => prefix2.Object.hashAll([aPrimitiveFields,stringWrapper,aString,]); prefix2.bool operator==(prefix2.Object other) => - other is prefix1.NestedFields&& aPrimitiveFields == other.aPrimitiveFields&& aString == other.aString; + other is prefix1.NestedFields&& aPrimitiveFields == other.aPrimitiveFields&& stringWrapper == other.stringWrapper&& aString == other.aString; - prefix2.String toString() => 'NestedFields(aPrimitiveFields: $aPrimitiveFields, aString: $aString)'; + prefix2.String toString() => 'NestedFields(aPrimitiveFields: $aPrimitiveFields, stringWrapper: $stringWrapper, aString: $aString)'; } augment class NestedFieldsBuilder { -prefix1.PrimitiveFieldsBuilder aPrimitiveFields = prefix1.PrimitiveFieldsBuilder();prefix2.String? aString; +prefix1.PrimitiveFieldsBuilder aPrimitiveFields = prefix1.PrimitiveFieldsBuilder();prefix1.StringWrapper? stringWrapper;prefix2.String? aString; -void replace(prefix1.NestedFields other) { this.aPrimitiveFields = other.aPrimitiveFields.toBuilder();this.aString = other.aString; } +void replace(prefix1.NestedFields other) { this.aPrimitiveFields = other.aPrimitiveFields.toBuilder();this.stringWrapper = other.stringWrapper;this.aString = other.aString; } void update(void Function(prefix1.NestedFieldsBuilder)? updates) => updates?.call(this); -prefix1.NestedFields build() => prefix1.NestedFields._(aPrimitiveFields: aPrimitiveFields.build(),aString: aString!,); +prefix1.NestedFields build() => prefix1.NestedFields._(aPrimitiveFields: aPrimitiveFields.build(),stringWrapper: stringWrapper!,aString: aString!,); } augment class PrimitiveFieldsBuilder { diff --git a/goldens/foo/lib/built_value/built_value_test.dart b/goldens/foo/lib/built_value/built_value_test.dart index 6f14c30d..27c1c33f 100644 --- a/goldens/foo/lib/built_value/built_value_test.dart +++ b/goldens/foo/lib/built_value/built_value_test.dart @@ -55,7 +55,7 @@ void main() { ..aPrimitiveFields.anInt = 3 ..aPrimitiveFields.aString = 'four' ..aString = 'five' - ..stringWrapper = StringWraper('six'), + ..stringWrapper = StringWrapper('six'), ); expect( value.toString(), @@ -72,8 +72,8 @@ class NonMacro { } @NonMacro() -class StringWraper { - const StringWraper(this.aString); +class StringWrapper { + const StringWrapper(this.aString); final String aString; @@ -94,6 +94,6 @@ class PrimitiveFields { @BuiltValue() class NestedFields { final PrimitiveFields aPrimitiveFields; - final StringWraper stringWrapper; + final StringWrapper stringWrapper; final String aString; }