Skip to content

Commit

Permalink
fix: supports for complex usage of "@@Index" in zmodel (#995)
Browse files Browse the repository at this point in the history
  • Loading branch information
ymc9 authored Feb 12, 2024
1 parent d530367 commit 541cd97
Show file tree
Hide file tree
Showing 32 changed files with 245 additions and 151 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "zenstack-monorepo",
"version": "1.9.1",
"version": "1.9.0",
"description": "",
"scripts": {
"build": "pnpm -r build",
Expand Down
2 changes: 1 addition & 1 deletion packages/ide/jetbrains/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "jetbrains",
"version": "1.9.1",
"version": "1.9.0",
"displayName": "ZenStack JetBrains IDE Plugin",
"description": "ZenStack JetBrains IDE plugin",
"homepage": "https://zenstack.dev",
Expand Down
6 changes: 3 additions & 3 deletions packages/language/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@zenstackhq/language",
"version": "1.9.1",
"version": "1.9.0",
"displayName": "ZenStack modeling language compiler",
"description": "ZenStack modeling language compiler",
"homepage": "https://zenstack.dev",
Expand All @@ -19,11 +19,11 @@
"author": "ZenStack Team",
"license": "MIT",
"devDependencies": {
"langium-cli": "1.2.0",
"langium-cli": "1.3.1",
"plist2": "^1.1.3"
},
"dependencies": {
"langium": "1.2.0"
"langium": "1.3.1"
},
"contributes": {
"languages": [
Expand Down
53 changes: 33 additions & 20 deletions packages/language/src/generated/ast.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,24 @@
/******************************************************************************
* This file was generated by langium-cli 1.2.0.
* This file was generated by langium-cli 1.3.1.
* DO NOT EDIT MANUALLY!
******************************************************************************/

/* eslint-disable */
import { AstNode, AbstractAstReflection, Reference, ReferenceInfo, TypeMetaData } from 'langium';
import type { AstNode, Reference, ReferenceInfo, TypeMetaData } from 'langium';
import { AbstractAstReflection } from 'langium';

export const ZModelTerminals = {
WS: /\s+/,
INTERNAL_ATTRIBUTE_NAME: /@@@([_a-zA-Z][\w_]*\.)*[_a-zA-Z][\w_]*/,
MODEL_ATTRIBUTE_NAME: /@@([_a-zA-Z][\w_]*\.)*[_a-zA-Z][\w_]*/,
FIELD_ATTRIBUTE_NAME: /@([_a-zA-Z][\w_]*\.)*[_a-zA-Z][\w_]*/,
ID: /[_a-zA-Z][\w_]*/,
STRING: /"(\\.|[^"\\])*"|'(\\.|[^'\\])*'/,
NUMBER: /[+-]?[0-9]+(\.[0-9]+)?/,
TRIPLE_SLASH_COMMENT: /\/\/\/[^\n\r]*/,
ML_COMMENT: /\/\*[\s\S]*?\*\//,
SL_COMMENT: /\/\/[^\n\r]*/,
};

export type AbstractDeclaration = Attribute | DataModel | DataSource | Enum | FunctionDecl | GeneratorDecl | Plugin;

Expand Down Expand Up @@ -64,10 +78,10 @@ export function isReferenceTarget(item: unknown): item is ReferenceTarget {
return reflection.isInstance(item, ReferenceTarget);
}

export type RegularID = 'abstract' | 'attribute' | 'datasource' | 'enum' | 'import' | 'in' | 'model' | 'plugin' | 'sort' | 'view' | string;
export type RegularID = 'abstract' | 'attribute' | 'datasource' | 'enum' | 'import' | 'in' | 'model' | 'plugin' | 'view' | string;

export function isRegularID(item: unknown): item is RegularID {
return item === 'model' || item === 'enum' || item === 'attribute' || item === 'datasource' || item === 'plugin' || item === 'abstract' || item === 'in' || item === 'sort' || item === 'view' || item === 'import' || (typeof item === 'string' && (/[_a-zA-Z][\w_]*/.test(item)));
return item === 'model' || item === 'enum' || item === 'attribute' || item === 'datasource' || item === 'plugin' || item === 'abstract' || item === 'in' || item === 'view' || item === 'import' || (typeof item === 'string' && (/[_a-zA-Z][\w_]*/.test(item)));
}

export type TypeDeclaration = DataModel | Enum;
Expand All @@ -81,7 +95,6 @@ export function isTypeDeclaration(item: unknown): item is TypeDeclaration {
export interface Argument extends AstNode {
readonly $container: InvocationExpr;
readonly $type: 'Argument';
name?: RegularID
value: Expression
}

Expand All @@ -92,7 +105,7 @@ export function isArgument(item: unknown): item is Argument {
}

export interface ArrayExpr extends AstNode {
readonly $container: Argument | ArrayExpr | AttributeArg | BinaryExpr | ConfigArrayExpr | ConfigField | ConfigInvocationArg | FieldInitializer | FunctionDecl | MemberAccessExpr | PluginField | UnaryExpr | UnsupportedFieldType;
readonly $container: Argument | ArrayExpr | AttributeArg | BinaryExpr | ConfigArrayExpr | ConfigField | ConfigInvocationArg | FieldInitializer | FunctionDecl | MemberAccessExpr | PluginField | ReferenceArg | UnaryExpr | UnsupportedFieldType;
readonly $type: 'ArrayExpr';
items: Array<Expression>
}
Expand Down Expand Up @@ -163,7 +176,7 @@ export function isAttributeParamType(item: unknown): item is AttributeParamType
}

export interface BinaryExpr extends AstNode {
readonly $container: Argument | ArrayExpr | AttributeArg | BinaryExpr | ConfigArrayExpr | ConfigField | ConfigInvocationArg | FieldInitializer | FunctionDecl | MemberAccessExpr | PluginField | UnaryExpr | UnsupportedFieldType;
readonly $container: Argument | ArrayExpr | AttributeArg | BinaryExpr | ConfigArrayExpr | ConfigField | ConfigInvocationArg | FieldInitializer | FunctionDecl | MemberAccessExpr | PluginField | ReferenceArg | UnaryExpr | UnsupportedFieldType;
readonly $type: 'BinaryExpr';
left: Expression
operator: '!' | '!=' | '&&' | '<' | '<=' | '==' | '>' | '>=' | '?' | '^' | 'in' | '||'
Expand All @@ -177,7 +190,7 @@ export function isBinaryExpr(item: unknown): item is BinaryExpr {
}

export interface BooleanLiteral extends AstNode {
readonly $container: Argument | ArrayExpr | AttributeArg | BinaryExpr | ConfigArrayExpr | ConfigField | ConfigInvocationArg | FieldInitializer | FunctionDecl | MemberAccessExpr | PluginField | UnaryExpr | UnsupportedFieldType;
readonly $container: Argument | ArrayExpr | AttributeArg | BinaryExpr | ConfigArrayExpr | ConfigField | ConfigInvocationArg | FieldInitializer | FunctionDecl | MemberAccessExpr | PluginField | ReferenceArg | UnaryExpr | UnsupportedFieldType;
readonly $type: 'BooleanLiteral';
value: Boolean
}
Expand All @@ -189,7 +202,7 @@ export function isBooleanLiteral(item: unknown): item is BooleanLiteral {
}

export interface ConfigArrayExpr extends AstNode {
readonly $container: Argument | ArrayExpr | AttributeArg | BinaryExpr | ConfigArrayExpr | ConfigField | ConfigInvocationArg | FieldInitializer | FunctionDecl | MemberAccessExpr | PluginField | UnaryExpr | UnsupportedFieldType;
readonly $container: Argument | ArrayExpr | AttributeArg | BinaryExpr | ConfigArrayExpr | ConfigField | ConfigInvocationArg | FieldInitializer | FunctionDecl | MemberAccessExpr | PluginField | ReferenceArg | UnaryExpr | UnsupportedFieldType;
readonly $type: 'ConfigArrayExpr';
items: Array<ConfigInvocationExpr | LiteralExpr>
}
Expand Down Expand Up @@ -440,7 +453,7 @@ export function isInternalAttribute(item: unknown): item is InternalAttribute {
}

export interface InvocationExpr extends AstNode {
readonly $container: Argument | ArrayExpr | AttributeArg | BinaryExpr | ConfigArrayExpr | ConfigField | ConfigInvocationArg | FieldInitializer | FunctionDecl | MemberAccessExpr | PluginField | UnaryExpr | UnsupportedFieldType;
readonly $container: Argument | ArrayExpr | AttributeArg | BinaryExpr | ConfigArrayExpr | ConfigField | ConfigInvocationArg | FieldInitializer | FunctionDecl | MemberAccessExpr | PluginField | ReferenceArg | UnaryExpr | UnsupportedFieldType;
readonly $type: 'InvocationExpr';
args: Array<Argument>
function: Reference<FunctionDecl>
Expand All @@ -453,7 +466,7 @@ export function isInvocationExpr(item: unknown): item is InvocationExpr {
}

export interface MemberAccessExpr extends AstNode {
readonly $container: Argument | ArrayExpr | AttributeArg | BinaryExpr | ConfigArrayExpr | ConfigField | ConfigInvocationArg | FieldInitializer | FunctionDecl | MemberAccessExpr | PluginField | UnaryExpr | UnsupportedFieldType;
readonly $container: Argument | ArrayExpr | AttributeArg | BinaryExpr | ConfigArrayExpr | ConfigField | ConfigInvocationArg | FieldInitializer | FunctionDecl | MemberAccessExpr | PluginField | ReferenceArg | UnaryExpr | UnsupportedFieldType;
readonly $type: 'MemberAccessExpr';
member: Reference<DataModelField>
operand: Expression
Expand Down Expand Up @@ -490,7 +503,7 @@ export function isModelImport(item: unknown): item is ModelImport {
}

export interface NullExpr extends AstNode {
readonly $container: Argument | ArrayExpr | AttributeArg | BinaryExpr | ConfigArrayExpr | ConfigField | ConfigInvocationArg | FieldInitializer | FunctionDecl | MemberAccessExpr | PluginField | UnaryExpr | UnsupportedFieldType;
readonly $container: Argument | ArrayExpr | AttributeArg | BinaryExpr | ConfigArrayExpr | ConfigField | ConfigInvocationArg | FieldInitializer | FunctionDecl | MemberAccessExpr | PluginField | ReferenceArg | UnaryExpr | UnsupportedFieldType;
readonly $type: 'NullExpr';
value: 'null'
}
Expand All @@ -502,7 +515,7 @@ export function isNullExpr(item: unknown): item is NullExpr {
}

export interface NumberLiteral extends AstNode {
readonly $container: Argument | ArrayExpr | AttributeArg | BinaryExpr | ConfigArrayExpr | ConfigField | ConfigInvocationArg | FieldInitializer | FunctionDecl | MemberAccessExpr | PluginField | UnaryExpr | UnsupportedFieldType;
readonly $container: Argument | ArrayExpr | AttributeArg | BinaryExpr | ConfigArrayExpr | ConfigField | ConfigInvocationArg | FieldInitializer | FunctionDecl | MemberAccessExpr | PluginField | ReferenceArg | UnaryExpr | UnsupportedFieldType;
readonly $type: 'NumberLiteral';
value: string
}
Expand All @@ -514,7 +527,7 @@ export function isNumberLiteral(item: unknown): item is NumberLiteral {
}

export interface ObjectExpr extends AstNode {
readonly $container: Argument | ArrayExpr | AttributeArg | BinaryExpr | ConfigArrayExpr | ConfigField | ConfigInvocationArg | FieldInitializer | FunctionDecl | MemberAccessExpr | PluginField | UnaryExpr | UnsupportedFieldType;
readonly $container: Argument | ArrayExpr | AttributeArg | BinaryExpr | ConfigArrayExpr | ConfigField | ConfigInvocationArg | FieldInitializer | FunctionDecl | MemberAccessExpr | PluginField | ReferenceArg | UnaryExpr | UnsupportedFieldType;
readonly $type: 'ObjectExpr';
fields: Array<FieldInitializer>
}
Expand Down Expand Up @@ -554,8 +567,8 @@ export function isPluginField(item: unknown): item is PluginField {
export interface ReferenceArg extends AstNode {
readonly $container: ReferenceExpr;
readonly $type: 'ReferenceArg';
name: 'sort'
value: 'Asc' | 'Desc'
name: string
value: Expression
}

export const ReferenceArg = 'ReferenceArg';
Expand All @@ -565,7 +578,7 @@ export function isReferenceArg(item: unknown): item is ReferenceArg {
}

export interface ReferenceExpr extends AstNode {
readonly $container: Argument | ArrayExpr | AttributeArg | BinaryExpr | ConfigArrayExpr | ConfigField | ConfigInvocationArg | FieldInitializer | FunctionDecl | MemberAccessExpr | PluginField | UnaryExpr | UnsupportedFieldType;
readonly $container: Argument | ArrayExpr | AttributeArg | BinaryExpr | ConfigArrayExpr | ConfigField | ConfigInvocationArg | FieldInitializer | FunctionDecl | MemberAccessExpr | PluginField | ReferenceArg | UnaryExpr | UnsupportedFieldType;
readonly $type: 'ReferenceExpr';
args: Array<ReferenceArg>
target: Reference<ReferenceTarget>
Expand All @@ -578,7 +591,7 @@ export function isReferenceExpr(item: unknown): item is ReferenceExpr {
}

export interface StringLiteral extends AstNode {
readonly $container: Argument | ArrayExpr | AttributeArg | BinaryExpr | ConfigArrayExpr | ConfigField | ConfigInvocationArg | FieldInitializer | FunctionDecl | MemberAccessExpr | PluginField | UnaryExpr | UnsupportedFieldType;
readonly $container: Argument | ArrayExpr | AttributeArg | BinaryExpr | ConfigArrayExpr | ConfigField | ConfigInvocationArg | FieldInitializer | FunctionDecl | MemberAccessExpr | PluginField | ReferenceArg | UnaryExpr | UnsupportedFieldType;
readonly $type: 'StringLiteral';
value: string
}
Expand All @@ -590,7 +603,7 @@ export function isStringLiteral(item: unknown): item is StringLiteral {
}

export interface ThisExpr extends AstNode {
readonly $container: Argument | ArrayExpr | AttributeArg | BinaryExpr | ConfigArrayExpr | ConfigField | ConfigInvocationArg | FieldInitializer | FunctionDecl | MemberAccessExpr | PluginField | UnaryExpr | UnsupportedFieldType;
readonly $container: Argument | ArrayExpr | AttributeArg | BinaryExpr | ConfigArrayExpr | ConfigField | ConfigInvocationArg | FieldInitializer | FunctionDecl | MemberAccessExpr | PluginField | ReferenceArg | UnaryExpr | UnsupportedFieldType;
readonly $type: 'ThisExpr';
value: 'this'
}
Expand All @@ -602,7 +615,7 @@ export function isThisExpr(item: unknown): item is ThisExpr {
}

export interface UnaryExpr extends AstNode {
readonly $container: Argument | ArrayExpr | AttributeArg | BinaryExpr | ConfigArrayExpr | ConfigField | ConfigInvocationArg | FieldInitializer | FunctionDecl | MemberAccessExpr | PluginField | UnaryExpr | UnsupportedFieldType;
readonly $container: Argument | ArrayExpr | AttributeArg | BinaryExpr | ConfigArrayExpr | ConfigField | ConfigInvocationArg | FieldInitializer | FunctionDecl | MemberAccessExpr | PluginField | ReferenceArg | UnaryExpr | UnsupportedFieldType;
readonly $type: 'UnaryExpr';
operand: Expression
operator: '!'
Expand Down
Loading

0 comments on commit 541cd97

Please sign in to comment.