@@ -290,7 +290,7 @@ export function isDataModelAttribute(item: unknown): item is DataModelAttribute
290290}
291291
292292export interface DataModelField extends AstNode {
293- readonly $container : DataModel | Enum | FunctionDecl | TypeDef ;
293+ readonly $container : DataModel | Enum | FunctionDecl ;
294294 readonly $type : 'DataModelField' ;
295295 attributes : Array < DataModelFieldAttribute >
296296 comments : Array < string >
@@ -305,7 +305,7 @@ export function isDataModelField(item: unknown): item is DataModelField {
305305}
306306
307307export interface DataModelFieldAttribute extends AstNode {
308- readonly $container : DataModelField | EnumField ;
308+ readonly $container : DataModelField | EnumField | TypeDefField ;
309309 readonly $type : 'DataModelFieldAttribute' ;
310310 args : Array < AttributeArg >
311311 decl : Reference < Attribute >
@@ -362,7 +362,7 @@ export function isEnum(item: unknown): item is Enum {
362362}
363363
364364export interface EnumField extends AstNode {
365- readonly $container : DataModel | Enum | FunctionDecl | TypeDef ;
365+ readonly $container : DataModel | Enum | FunctionDecl ;
366366 readonly $type : 'EnumField' ;
367367 attributes : Array < DataModelFieldAttribute >
368368 comments : Array < string >
@@ -405,7 +405,7 @@ export function isFunctionDecl(item: unknown): item is FunctionDecl {
405405}
406406
407407export interface FunctionParam extends AstNode {
408- readonly $container : DataModel | Enum | FunctionDecl | TypeDef ;
408+ readonly $container : DataModel | Enum | FunctionDecl ;
409409 readonly $type : 'FunctionParam' ;
410410 name : RegularID
411411 optional : boolean
@@ -624,7 +624,7 @@ export interface TypeDef extends AstNode {
624624 readonly $container : Model ;
625625 readonly $type : 'TypeDef' ;
626626 comments : Array < string >
627- fields : Array < DataModelField >
627+ fields : Array < TypeDefField >
628628 name : RegularID
629629}
630630
@@ -634,6 +634,36 @@ export function isTypeDef(item: unknown): item is TypeDef {
634634 return reflection . isInstance ( item , TypeDef ) ;
635635}
636636
637+ export interface TypeDefField extends AstNode {
638+ readonly $container : TypeDef ;
639+ readonly $type : 'TypeDefField' ;
640+ attributes : Array < DataModelFieldAttribute >
641+ comments : Array < string >
642+ name : RegularIDWithTypeNames
643+ type : TypeDefFieldType
644+ }
645+
646+ export const TypeDefField = 'TypeDefField' ;
647+
648+ export function isTypeDefField ( item : unknown ) : item is TypeDefField {
649+ return reflection . isInstance ( item , TypeDefField ) ;
650+ }
651+
652+ export interface TypeDefFieldType extends AstNode {
653+ readonly $container : TypeDefField ;
654+ readonly $type : 'TypeDefFieldType' ;
655+ array : boolean
656+ optional : boolean
657+ reference ?: Reference < TypeDef >
658+ type ?: BuiltinType
659+ }
660+
661+ export const TypeDefFieldType = 'TypeDefFieldType' ;
662+
663+ export function isTypeDefFieldType ( item : unknown ) : item is TypeDefFieldType {
664+ return reflection . isInstance ( item , TypeDefFieldType ) ;
665+ }
666+
637667export interface UnaryExpr extends AstNode {
638668 readonly $container : Argument | ArrayExpr | AttributeArg | BinaryExpr | ConfigArrayExpr | ConfigField | ConfigInvocationArg | FieldInitializer | FunctionDecl | MemberAccessExpr | PluginField | ReferenceArg | UnaryExpr | UnsupportedFieldType ;
639669 readonly $type : 'UnaryExpr' ;
@@ -706,14 +736,16 @@ export type ZModelAstType = {
706736 ThisExpr : ThisExpr
707737 TypeDeclaration : TypeDeclaration
708738 TypeDef : TypeDef
739+ TypeDefField : TypeDefField
740+ TypeDefFieldType : TypeDefFieldType
709741 UnaryExpr : UnaryExpr
710742 UnsupportedFieldType : UnsupportedFieldType
711743}
712744
713745export class ZModelAstReflection extends AbstractAstReflection {
714746
715747 getAllTypes ( ) : string [ ] {
716- return [ 'AbstractDeclaration' , 'Argument' , 'ArrayExpr' , 'Attribute' , 'AttributeArg' , 'AttributeParam' , 'AttributeParamType' , 'BinaryExpr' , 'BooleanLiteral' , 'ConfigArrayExpr' , 'ConfigExpr' , 'ConfigField' , 'ConfigInvocationArg' , 'ConfigInvocationExpr' , 'DataModel' , 'DataModelAttribute' , 'DataModelField' , 'DataModelFieldAttribute' , 'DataModelFieldType' , 'DataSource' , 'Enum' , 'EnumField' , 'Expression' , 'FieldInitializer' , 'FunctionDecl' , 'FunctionParam' , 'FunctionParamType' , 'GeneratorDecl' , 'InternalAttribute' , 'InvocationExpr' , 'LiteralExpr' , 'MemberAccessExpr' , 'Model' , 'ModelImport' , 'NullExpr' , 'NumberLiteral' , 'ObjectExpr' , 'Plugin' , 'PluginField' , 'ReferenceArg' , 'ReferenceExpr' , 'ReferenceTarget' , 'StringLiteral' , 'ThisExpr' , 'TypeDeclaration' , 'TypeDef' , 'UnaryExpr' , 'UnsupportedFieldType' ] ;
748+ return [ 'AbstractDeclaration' , 'Argument' , 'ArrayExpr' , 'Attribute' , 'AttributeArg' , 'AttributeParam' , 'AttributeParamType' , 'BinaryExpr' , 'BooleanLiteral' , 'ConfigArrayExpr' , 'ConfigExpr' , 'ConfigField' , 'ConfigInvocationArg' , 'ConfigInvocationExpr' , 'DataModel' , 'DataModelAttribute' , 'DataModelField' , 'DataModelFieldAttribute' , 'DataModelFieldType' , 'DataSource' , 'Enum' , 'EnumField' , 'Expression' , 'FieldInitializer' , 'FunctionDecl' , 'FunctionParam' , 'FunctionParamType' , 'GeneratorDecl' , 'InternalAttribute' , 'InvocationExpr' , 'LiteralExpr' , 'MemberAccessExpr' , 'Model' , 'ModelImport' , 'NullExpr' , 'NumberLiteral' , 'ObjectExpr' , 'Plugin' , 'PluginField' , 'ReferenceArg' , 'ReferenceExpr' , 'ReferenceTarget' , 'StringLiteral' , 'ThisExpr' , 'TypeDeclaration' , 'TypeDef' , 'TypeDefField' , 'TypeDefFieldType' , ' UnaryExpr', 'UnsupportedFieldType' ] ;
717749 }
718750
719751 protected override computeIsSubtype ( subtype : string , supertype : string ) : boolean {
@@ -788,6 +820,9 @@ export class ZModelAstReflection extends AbstractAstReflection {
788820 case 'ReferenceExpr:target' : {
789821 return ReferenceTarget ;
790822 }
823+ case 'TypeDefFieldType:reference' : {
824+ return TypeDef ;
825+ }
791826 default : {
792827 throw new Error ( `${ referenceId } is not a valid reference id.` ) ;
793828 }
@@ -1014,6 +1049,24 @@ export class ZModelAstReflection extends AbstractAstReflection {
10141049 ]
10151050 } ;
10161051 }
1052+ case 'TypeDefField' : {
1053+ return {
1054+ name : 'TypeDefField' ,
1055+ mandatory : [
1056+ { name : 'attributes' , type : 'array' } ,
1057+ { name : 'comments' , type : 'array' }
1058+ ]
1059+ } ;
1060+ }
1061+ case 'TypeDefFieldType' : {
1062+ return {
1063+ name : 'TypeDefFieldType' ,
1064+ mandatory : [
1065+ { name : 'array' , type : 'boolean' } ,
1066+ { name : 'optional' , type : 'boolean' }
1067+ ]
1068+ } ;
1069+ }
10171070 default : {
10181071 return {
10191072 name : type ,
0 commit comments