@@ -15,7 +15,7 @@ export function isAbstractDeclaration(item: unknown): item is AbstractDeclaratio
1515 return reflection . isInstance ( item , AbstractDeclaration ) ;
1616}
1717
18- export type Expression = ArrayExpr | BinaryExpr | InvocationExpr | LiteralExpr | ReferenceExpr | UnaryExpr ;
18+ export type Expression = ArrayExpr | BinaryExpr | InvocationExpr | LiteralExpr | MemberAccessExpr | ReferenceExpr | UnaryExpr ;
1919
2020export const Expression = 'Expression' ;
2121
@@ -25,7 +25,7 @@ export function isExpression(item: unknown): item is Expression {
2525
2626export type QualifiedName = string ;
2727
28- export type ReferenceTarget = DataModelField | EnumField | Function | FunctionParam ;
28+ export type ReferenceTarget = DataModelField | EnumField | FunctionParam ;
2929
3030export const ReferenceTarget = 'ReferenceTarget' ;
3131
@@ -42,7 +42,7 @@ export function isTypeDeclaration(item: unknown): item is TypeDeclaration {
4242}
4343
4444export interface ArrayExpr extends AstNode {
45- readonly $container : ArrayExpr | BinaryExpr | DataModelAttribute | DataModelFieldAttribute | DataSourceField | Function | InvocationExpr | UnaryExpr ;
45+ readonly $container : ArrayExpr | BinaryExpr | DataModelAttribute | DataModelFieldAttribute | DataSourceField | Function | InvocationExpr | MemberAccessExpr | UnaryExpr ;
4646 items : Array < Expression >
4747}
4848
@@ -64,7 +64,7 @@ export function isAttribute(item: unknown): item is Attribute {
6464}
6565
6666export interface BinaryExpr extends AstNode {
67- readonly $container : ArrayExpr | BinaryExpr | DataModelAttribute | DataModelFieldAttribute | DataSourceField | Function | InvocationExpr | UnaryExpr ;
67+ readonly $container : ArrayExpr | BinaryExpr | DataModelAttribute | DataModelFieldAttribute | DataSourceField | Function | InvocationExpr | MemberAccessExpr | UnaryExpr ;
6868 left : Expression
6969 operator : '!=' | '&&' | '*' | '+' | '-' | '/' | '<' | '<=' | '==' | '>' | '>=' | '||'
7070 right : Expression
@@ -131,7 +131,7 @@ export interface DataModelFieldType extends AstNode {
131131 array : boolean
132132 optional : boolean
133133 reference ?: Reference < TypeDeclaration >
134- type ?: 'Boolean' | 'DateTime' | 'Float' | ' Int' | 'JSON' | 'String'
134+ type ?: 'Boolean' | 'DateTime' | 'Int' | 'JSON' | 'String'
135135}
136136
137137export const DataModelFieldType = 'DataModelFieldType' ;
@@ -155,7 +155,7 @@ export function isDataSource(item: unknown): item is DataSource {
155155export interface DataSourceField extends AstNode {
156156 readonly $container : DataSource ;
157157 name : string
158- value : Expression
158+ value : InvocationExpr | LiteralExpr
159159}
160160
161161export const DataSourceField = 'DataSourceField' ;
@@ -216,7 +216,7 @@ export interface FunctionParamType extends AstNode {
216216 readonly $container : FunctionParam ;
217217 array : boolean
218218 reference ?: Reference < TypeDeclaration >
219- type ?: 'Boolean' | 'DateTime' | 'Float' | ' Int' | 'JSON' | 'String'
219+ type ?: 'Boolean' | 'DateTime' | 'Int' | 'JSON' | 'String'
220220}
221221
222222export const FunctionParamType = 'FunctionParamType' ;
@@ -226,9 +226,9 @@ export function isFunctionParamType(item: unknown): item is FunctionParamType {
226226}
227227
228228export interface InvocationExpr extends AstNode {
229- readonly $container : ArrayExpr | BinaryExpr | DataModelAttribute | DataModelFieldAttribute | DataSourceField | Function | InvocationExpr | UnaryExpr ;
229+ readonly $container : ArrayExpr | BinaryExpr | DataModelAttribute | DataModelFieldAttribute | DataSourceField | Function | InvocationExpr | MemberAccessExpr | UnaryExpr ;
230230 args : Array < Expression >
231- function : string
231+ function : Reference < Function >
232232}
233233
234234export const InvocationExpr = 'InvocationExpr' ;
@@ -238,7 +238,7 @@ export function isInvocationExpr(item: unknown): item is InvocationExpr {
238238}
239239
240240export interface LiteralExpr extends AstNode {
241- readonly $container : ArrayExpr | BinaryExpr | DataModelAttribute | DataModelFieldAttribute | DataSourceField | Function | InvocationExpr | UnaryExpr ;
241+ readonly $container : ArrayExpr | BinaryExpr | DataModelAttribute | DataModelFieldAttribute | DataSourceField | Function | InvocationExpr | MemberAccessExpr | UnaryExpr ;
242242 value : boolean | number | string
243243}
244244
@@ -248,6 +248,18 @@ export function isLiteralExpr(item: unknown): item is LiteralExpr {
248248 return reflection . isInstance ( item , LiteralExpr ) ;
249249}
250250
251+ export interface MemberAccessExpr extends AstNode {
252+ readonly $container : ArrayExpr | BinaryExpr | DataModelAttribute | DataModelFieldAttribute | DataSourceField | Function | InvocationExpr | MemberAccessExpr | UnaryExpr ;
253+ member : Reference < DataModelField >
254+ operand : Expression
255+ }
256+
257+ export const MemberAccessExpr = 'MemberAccessExpr' ;
258+
259+ export function isMemberAccessExpr ( item : unknown ) : item is MemberAccessExpr {
260+ return reflection . isInstance ( item , MemberAccessExpr ) ;
261+ }
262+
251263export interface Model extends AstNode {
252264 declarations : Array < AbstractDeclaration >
253265}
@@ -259,7 +271,7 @@ export function isModel(item: unknown): item is Model {
259271}
260272
261273export interface ReferenceExpr extends AstNode {
262- readonly $container : ArrayExpr | BinaryExpr | DataModelAttribute | DataModelFieldAttribute | DataSourceField | Function | InvocationExpr | UnaryExpr ;
274+ readonly $container : ArrayExpr | BinaryExpr | DataModelAttribute | DataModelFieldAttribute | DataSourceField | Function | InvocationExpr | MemberAccessExpr | UnaryExpr ;
263275 target : Reference < ReferenceTarget >
264276}
265277
@@ -270,7 +282,7 @@ export function isReferenceExpr(item: unknown): item is ReferenceExpr {
270282}
271283
272284export interface UnaryExpr extends AstNode {
273- readonly $container : ArrayExpr | BinaryExpr | DataModelAttribute | DataModelFieldAttribute | DataSourceField | Function | InvocationExpr | UnaryExpr ;
285+ readonly $container : ArrayExpr | BinaryExpr | DataModelAttribute | DataModelFieldAttribute | DataSourceField | Function | InvocationExpr | MemberAccessExpr | UnaryExpr ;
274286 arg : Expression
275287 operator : '!' | '+' | '-'
276288}
@@ -281,14 +293,14 @@ export function isUnaryExpr(item: unknown): item is UnaryExpr {
281293 return reflection . isInstance ( item , UnaryExpr ) ;
282294}
283295
284- export type ZModelAstType = 'AbstractDeclaration' | 'ArrayExpr' | 'Attribute' | 'BinaryExpr' | 'DataModel' | 'DataModelAttribute' | 'DataModelField' | 'DataModelFieldAttribute' | 'DataModelFieldType' | 'DataSource' | 'DataSourceField' | 'Enum' | 'EnumField' | 'Expression' | 'Function' | 'FunctionParam' | 'FunctionParamType' | 'InvocationExpr' | 'LiteralExpr' | 'Model' | 'ReferenceExpr' | 'ReferenceTarget' | 'TypeDeclaration' | 'UnaryExpr' ;
296+ export type ZModelAstType = 'AbstractDeclaration' | 'ArrayExpr' | 'Attribute' | 'BinaryExpr' | 'DataModel' | 'DataModelAttribute' | 'DataModelField' | 'DataModelFieldAttribute' | 'DataModelFieldType' | 'DataSource' | 'DataSourceField' | 'Enum' | 'EnumField' | 'Expression' | 'Function' | 'FunctionParam' | 'FunctionParamType' | 'InvocationExpr' | 'LiteralExpr' | 'MemberAccessExpr' | ' Model' | 'ReferenceExpr' | 'ReferenceTarget' | 'TypeDeclaration' | 'UnaryExpr' ;
285297
286- export type ZModelAstReference = 'DataModelAttribute:decl' | 'DataModelFieldAttribute:decl' | 'DataModelFieldType:reference' | 'FunctionParamType:reference' | 'ReferenceExpr:target' ;
298+ export type ZModelAstReference = 'DataModelAttribute:decl' | 'DataModelFieldAttribute:decl' | 'DataModelFieldType:reference' | 'FunctionParamType:reference' | 'InvocationExpr:function' | 'MemberAccessExpr:member' | ' ReferenceExpr:target';
287299
288300export class ZModelAstReflection implements AstReflection {
289301
290302 getAllTypes ( ) : string [ ] {
291- return [ 'AbstractDeclaration' , 'ArrayExpr' , 'Attribute' , 'BinaryExpr' , 'DataModel' , 'DataModelAttribute' , 'DataModelField' , 'DataModelFieldAttribute' , 'DataModelFieldType' , 'DataSource' , 'DataSourceField' , 'Enum' , 'EnumField' , 'Expression' , 'Function' , 'FunctionParam' , 'FunctionParamType' , 'InvocationExpr' , 'LiteralExpr' , 'Model' , 'ReferenceExpr' , 'ReferenceTarget' , 'TypeDeclaration' , 'UnaryExpr' ] ;
303+ return [ 'AbstractDeclaration' , 'ArrayExpr' , 'Attribute' , 'BinaryExpr' , 'DataModel' , 'DataModelAttribute' , 'DataModelField' , 'DataModelFieldAttribute' , 'DataModelFieldType' , 'DataSource' , 'DataSourceField' , 'Enum' , 'EnumField' , 'Expression' , 'Function' , 'FunctionParam' , 'FunctionParamType' , 'InvocationExpr' , 'LiteralExpr' , 'MemberAccessExpr' , ' Model', 'ReferenceExpr' , 'ReferenceTarget' , 'TypeDeclaration' , 'UnaryExpr' ] ;
292304 }
293305
294306 isInstance ( node : unknown , type : string ) : boolean {
@@ -304,12 +316,14 @@ export class ZModelAstReflection implements AstReflection {
304316 case BinaryExpr :
305317 case InvocationExpr :
306318 case LiteralExpr :
319+ case MemberAccessExpr :
307320 case ReferenceExpr :
308321 case UnaryExpr : {
309322 return this . isSubtype ( Expression , supertype ) ;
310323 }
311324 case Attribute :
312- case DataSource : {
325+ case DataSource :
326+ case Function : {
313327 return this . isSubtype ( AbstractDeclaration , supertype ) ;
314328 }
315329 case DataModel :
@@ -321,9 +335,6 @@ export class ZModelAstReflection implements AstReflection {
321335 case FunctionParam : {
322336 return this . isSubtype ( ReferenceTarget , supertype ) ;
323337 }
324- case Function : {
325- return this . isSubtype ( AbstractDeclaration , supertype ) || this . isSubtype ( ReferenceTarget , supertype ) ;
326- }
327338 default : {
328339 return false ;
329340 }
@@ -344,6 +355,12 @@ export class ZModelAstReflection implements AstReflection {
344355 case 'FunctionParamType:reference' : {
345356 return TypeDeclaration ;
346357 }
358+ case 'InvocationExpr:function' : {
359+ return Function ;
360+ }
361+ case 'MemberAccessExpr:member' : {
362+ return DataModelField ;
363+ }
347364 case 'ReferenceExpr:target' : {
348365 return ReferenceTarget ;
349366 }
0 commit comments