Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 0 additions & 7 deletions packages/language/src/ast.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,13 +46,6 @@ declare module './ast' {
$resolvedParam?: AttributeParam;
}

interface BinaryExpr {
/**
* Optional iterator binding for collection predicates
*/
binding?: string;
}

export interface DataModel {
/**
* All fields including those marked with `@ignore`
Expand Down
40 changes: 30 additions & 10 deletions packages/language/src/generated/ast.ts
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ export function isMemberAccessTarget(item: unknown): item is MemberAccessTarget
return reflection.isInstance(item, MemberAccessTarget);
}

export type ReferenceTarget = BinaryExpr | DataField | EnumField | FunctionParam;
export type ReferenceTarget = CollectionPredicateBinding | DataField | EnumField | FunctionParam;

export const ReferenceTarget = 'ReferenceTarget';

Expand Down Expand Up @@ -256,7 +256,7 @@ export function isAttributeParamType(item: unknown): item is AttributeParamType
export interface BinaryExpr extends langium.AstNode {
readonly $container: Argument | ArrayExpr | AttributeArg | BinaryExpr | FieldInitializer | FunctionDecl | MemberAccessExpr | ReferenceArg | UnaryExpr;
readonly $type: 'BinaryExpr';
binding?: RegularID;
binding?: CollectionPredicateBinding;
left: Expression;
operator: '!' | '!=' | '&&' | '<' | '<=' | '==' | '>' | '>=' | '?' | '^' | 'in' | '||';
right: Expression;
Expand All @@ -280,6 +280,18 @@ export function isBooleanLiteral(item: unknown): item is BooleanLiteral {
return reflection.isInstance(item, BooleanLiteral);
}

export interface CollectionPredicateBinding extends langium.AstNode {
readonly $container: BinaryExpr;
readonly $type: 'CollectionPredicateBinding';
name: RegularID;
}

export const CollectionPredicateBinding = 'CollectionPredicateBinding';

export function isCollectionPredicateBinding(item: unknown): item is CollectionPredicateBinding {
return reflection.isInstance(item, CollectionPredicateBinding);
}

export interface ConfigArrayExpr extends langium.AstNode {
readonly $container: ConfigField;
readonly $type: 'ConfigArrayExpr';
Expand Down Expand Up @@ -774,6 +786,7 @@ export type ZModelAstType = {
AttributeParamType: AttributeParamType
BinaryExpr: BinaryExpr
BooleanLiteral: BooleanLiteral
CollectionPredicateBinding: CollectionPredicateBinding
ConfigArrayExpr: ConfigArrayExpr
ConfigExpr: ConfigExpr
ConfigField: ConfigField
Expand Down Expand Up @@ -821,12 +834,13 @@ export type ZModelAstType = {
export class ZModelAstReflection extends langium.AbstractAstReflection {

getAllTypes(): string[] {
return [AbstractDeclaration, Argument, ArrayExpr, Attribute, AttributeArg, AttributeParam, AttributeParamType, BinaryExpr, BooleanLiteral, ConfigArrayExpr, ConfigExpr, ConfigField, ConfigInvocationArg, ConfigInvocationExpr, DataField, DataFieldAttribute, DataFieldType, DataModel, DataModelAttribute, DataSource, Enum, EnumField, Expression, FieldInitializer, FunctionDecl, FunctionParam, FunctionParamType, GeneratorDecl, InternalAttribute, InvocationExpr, LiteralExpr, MemberAccessExpr, MemberAccessTarget, Model, ModelImport, NullExpr, NumberLiteral, ObjectExpr, Plugin, PluginField, Procedure, ProcedureParam, ReferenceArg, ReferenceExpr, ReferenceTarget, StringLiteral, ThisExpr, TypeDeclaration, TypeDef, UnaryExpr, UnsupportedFieldType];
return [AbstractDeclaration, Argument, ArrayExpr, Attribute, AttributeArg, AttributeParam, AttributeParamType, BinaryExpr, BooleanLiteral, CollectionPredicateBinding, ConfigArrayExpr, ConfigExpr, ConfigField, ConfigInvocationArg, ConfigInvocationExpr, DataField, DataFieldAttribute, DataFieldType, DataModel, DataModelAttribute, DataSource, Enum, EnumField, Expression, FieldInitializer, FunctionDecl, FunctionParam, FunctionParamType, GeneratorDecl, InternalAttribute, InvocationExpr, LiteralExpr, MemberAccessExpr, MemberAccessTarget, Model, ModelImport, NullExpr, NumberLiteral, ObjectExpr, Plugin, PluginField, Procedure, ProcedureParam, ReferenceArg, ReferenceExpr, ReferenceTarget, StringLiteral, ThisExpr, TypeDeclaration, TypeDef, UnaryExpr, UnsupportedFieldType];
}

protected override computeIsSubtype(subtype: string, supertype: string): boolean {
switch (subtype) {
case ArrayExpr:
case BinaryExpr:
case MemberAccessExpr:
case NullExpr:
case ObjectExpr:
Expand All @@ -843,14 +857,16 @@ export class ZModelAstReflection extends langium.AbstractAstReflection {
case Procedure: {
return this.isSubtype(AbstractDeclaration, supertype);
}
case BinaryExpr: {
return this.isSubtype(Expression, supertype) || this.isSubtype(ReferenceTarget, supertype);
}
case BooleanLiteral:
case NumberLiteral:
case StringLiteral: {
return this.isSubtype(LiteralExpr, supertype);
}
case CollectionPredicateBinding:
case EnumField:
case FunctionParam: {
return this.isSubtype(ReferenceTarget, supertype);
}
case ConfigArrayExpr: {
return this.isSubtype(ConfigExpr, supertype);
}
Expand All @@ -862,10 +878,6 @@ export class ZModelAstReflection extends langium.AbstractAstReflection {
case TypeDef: {
return this.isSubtype(AbstractDeclaration, supertype) || this.isSubtype(TypeDeclaration, supertype);
}
case EnumField:
case FunctionParam: {
return this.isSubtype(ReferenceTarget, supertype);
}
case InvocationExpr:
case LiteralExpr: {
return this.isSubtype(ConfigExpr, supertype) || this.isSubtype(Expression, supertype);
Expand Down Expand Up @@ -991,6 +1003,14 @@ export class ZModelAstReflection extends langium.AbstractAstReflection {
]
};
}
case CollectionPredicateBinding: {
return {
name: CollectionPredicateBinding,
properties: [
{ name: 'name' }
]
};
}
case ConfigArrayExpr: {
return {
name: ConfigArrayExpr,
Expand Down
Loading
Loading