Skip to content

merge dev to main #365

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 10 commits into from
Apr 30, 2023
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
11 changes: 2 additions & 9 deletions .github/workflows/build-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ env:

on:
pull_request:
branches: ['dev', 'main', 'canary']
branches: ['dev', 'main']

jobs:
build-test:
Expand All @@ -18,7 +18,6 @@ jobs:
strategy:
matrix:
node-version: [16.x]
# See supported Node.js release schedule at https://nodejs.org/en/about/releases/

steps:
- uses: actions/checkout@v3
Expand All @@ -32,13 +31,7 @@ jobs:
node-version: ${{ matrix.node-version }}
cache: 'pnpm'
- run: pnpm install --frozen-lockfile
- run: |
if [[ $GITHUB_REF == 'refs/heads/canary' ]]; then
DEFAULT_NPM_TAG=canary pnpm run build
else
DEFAULT_NPM_TAG=latest pnpm run build
fi

- run: DEFAULT_NPM_TAG=latest pnpm run build
- run: pnpm lint

# install again for internal dependencies
Expand Down
2 changes: 1 addition & 1 deletion .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
"request": "attach",
"skipFiles": ["<node_internals>/**"],
"sourceMaps": true,
"outFiles": ["${workspaceFolder}/bundle/**/*.js"]
"outFiles": ["${workspaceFolder}/packages/schema/bundle/**/*.js"]
},
{
"name": "Todo sample: debug server-side",
Expand Down
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.0.0-alpha.102",
"version": "1.0.0-alpha.110",
"description": "",
"scripts": {
"build": "pnpm -r build",
Expand Down
2 changes: 1 addition & 1 deletion packages/language/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@zenstackhq/language",
"version": "1.0.0-alpha.102",
"version": "1.0.0-alpha.110",
"displayName": "ZenStack modeling language compiler",
"description": "ZenStack modeling language compiler",
"homepage": "https://zenstack.dev",
Expand Down
11 changes: 11 additions & 0 deletions packages/language/src/ast.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,17 @@ declare module './generated/ast' {
*/
$resolvedParam?: AttributeParam;
}

interface DataModel {
/**
* Resolved fields, include inherited fields
*/
$resolvedFields: Array<DataModelField>;
}

interface DataModelField {
$isInherited?: boolean;
}
}

declare module 'langium' {
Expand Down
64 changes: 50 additions & 14 deletions packages/language/src/generated/ast.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ export function isExpression(item: unknown): item is Expression {
return reflection.isInstance(item, Expression);
}

export type ExpressionType = 'Any' | 'Boolean' | 'DateTime' | 'Float' | 'Int' | 'Null' | 'Object' | 'String';
export type ExpressionType = 'Any' | 'Boolean' | 'DateTime' | 'Float' | 'Int' | 'Null' | 'Object' | 'String' | 'Unsupported';

export type QualifiedName = string;

Expand Down Expand Up @@ -68,7 +68,7 @@ export function isArgument(item: unknown): item is Argument {
}

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

export interface BinaryExpr extends AstNode {
readonly $container: Argument | ArrayExpr | AttributeArg | BinaryExpr | DataSourceField | FieldInitializer | FunctionDecl | GeneratorField | MemberAccessExpr | PluginField | UnaryExpr;
readonly $container: Argument | ArrayExpr | AttributeArg | BinaryExpr | DataSourceField | FieldInitializer | FunctionDecl | GeneratorField | MemberAccessExpr | PluginField | UnaryExpr | UnsupportedFieldType;
readonly $type: 'BinaryExpr';
left: Expression
operator: '!' | '!=' | '&&' | '<' | '<=' | '==' | '>' | '>=' | '?' | '^' | 'in' | '||'
Expand All @@ -168,7 +168,9 @@ export interface DataModel extends AstNode {
attributes: Array<DataModelAttribute>
comments: Array<string>
fields: Array<DataModelField>
isAbstract: boolean
name: RegularID
superTypes: Array<Reference<DataModel>>
}

export const DataModel = 'DataModel';
Expand Down Expand Up @@ -225,6 +227,7 @@ export interface DataModelFieldType extends AstNode {
optional: boolean
reference?: Reference<TypeDeclaration>
type?: BuiltinType
unsupported?: UnsupportedFieldType
}

export const DataModelFieldType = 'DataModelFieldType';
Expand Down Expand Up @@ -371,7 +374,7 @@ export function isGeneratorField(item: unknown): item is GeneratorField {
}

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

export interface LiteralExpr extends AstNode {
readonly $container: Argument | ArrayExpr | AttributeArg | BinaryExpr | DataSourceField | FieldInitializer | FunctionDecl | GeneratorField | MemberAccessExpr | PluginField | UnaryExpr;
readonly $container: Argument | ArrayExpr | AttributeArg | BinaryExpr | DataSourceField | FieldInitializer | FunctionDecl | GeneratorField | MemberAccessExpr | PluginField | UnaryExpr | UnsupportedFieldType;
readonly $type: 'LiteralExpr';
value: boolean | number | string
}
Expand All @@ -396,7 +399,7 @@ export function isLiteralExpr(item: unknown): item is LiteralExpr {
}

export interface MemberAccessExpr extends AstNode {
readonly $container: Argument | ArrayExpr | AttributeArg | BinaryExpr | DataSourceField | FieldInitializer | FunctionDecl | GeneratorField | MemberAccessExpr | PluginField | UnaryExpr;
readonly $container: Argument | ArrayExpr | AttributeArg | BinaryExpr | DataSourceField | FieldInitializer | FunctionDecl | GeneratorField | MemberAccessExpr | PluginField | UnaryExpr | UnsupportedFieldType;
readonly $type: 'MemberAccessExpr';
member: Reference<DataModelField>
operand: Expression
Expand All @@ -411,6 +414,7 @@ export function isMemberAccessExpr(item: unknown): item is MemberAccessExpr {
export interface Model extends AstNode {
readonly $type: 'Model';
declarations: Array<AbstractDeclaration>
imports: Array<ModelImport>
}

export const Model = 'Model';
Expand All @@ -419,8 +423,20 @@ export function isModel(item: unknown): item is Model {
return reflection.isInstance(item, Model);
}

export interface ModelImport extends AstNode {
readonly $container: Model;
readonly $type: 'ModelImport';
path: string
}

export const ModelImport = 'ModelImport';

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

export interface NullExpr extends AstNode {
readonly $container: Argument | ArrayExpr | AttributeArg | BinaryExpr | DataSourceField | FieldInitializer | FunctionDecl | GeneratorField | MemberAccessExpr | PluginField | UnaryExpr;
readonly $container: Argument | ArrayExpr | AttributeArg | BinaryExpr | DataSourceField | FieldInitializer | FunctionDecl | GeneratorField | MemberAccessExpr | PluginField | UnaryExpr | UnsupportedFieldType;
readonly $type: 'NullExpr';
value: string
}
Expand All @@ -432,7 +448,7 @@ export function isNullExpr(item: unknown): item is NullExpr {
}

export interface ObjectExpr extends AstNode {
readonly $container: Argument | ArrayExpr | AttributeArg | BinaryExpr | DataSourceField | FieldInitializer | FunctionDecl | GeneratorField | MemberAccessExpr | PluginField | UnaryExpr;
readonly $container: Argument | ArrayExpr | AttributeArg | BinaryExpr | DataSourceField | FieldInitializer | FunctionDecl | GeneratorField | MemberAccessExpr | PluginField | UnaryExpr | UnsupportedFieldType;
readonly $type: 'ObjectExpr';
fields: Array<FieldInitializer>
}
Expand Down Expand Up @@ -483,7 +499,7 @@ export function isReferenceArg(item: unknown): item is ReferenceArg {
}

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

export interface ThisExpr extends AstNode {
readonly $container: Argument | ArrayExpr | AttributeArg | BinaryExpr | DataSourceField | FieldInitializer | FunctionDecl | GeneratorField | MemberAccessExpr | PluginField | UnaryExpr;
readonly $container: Argument | ArrayExpr | AttributeArg | BinaryExpr | DataSourceField | FieldInitializer | FunctionDecl | GeneratorField | MemberAccessExpr | PluginField | UnaryExpr | UnsupportedFieldType;
readonly $type: 'ThisExpr';
value: string
}
Expand All @@ -508,7 +524,7 @@ export function isThisExpr(item: unknown): item is ThisExpr {
}

export interface UnaryExpr extends AstNode {
readonly $container: Argument | ArrayExpr | AttributeArg | BinaryExpr | DataSourceField | FieldInitializer | FunctionDecl | GeneratorField | MemberAccessExpr | PluginField | UnaryExpr;
readonly $container: Argument | ArrayExpr | AttributeArg | BinaryExpr | DataSourceField | FieldInitializer | FunctionDecl | GeneratorField | MemberAccessExpr | PluginField | UnaryExpr | UnsupportedFieldType;
readonly $type: 'UnaryExpr';
operand: Expression
operator: '!'
Expand All @@ -520,6 +536,18 @@ export function isUnaryExpr(item: unknown): item is UnaryExpr {
return reflection.isInstance(item, UnaryExpr);
}

export interface UnsupportedFieldType extends AstNode {
readonly $container: DataModelFieldType;
readonly $type: 'UnsupportedFieldType';
value: LiteralExpr
}

export const UnsupportedFieldType = 'UnsupportedFieldType';

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

export interface ZModelAstType {
AbstractDeclaration: AbstractDeclaration
Argument: Argument
Expand Down Expand Up @@ -550,6 +578,7 @@ export interface ZModelAstType {
LiteralExpr: LiteralExpr
MemberAccessExpr: MemberAccessExpr
Model: Model
ModelImport: ModelImport
NullExpr: NullExpr
ObjectExpr: ObjectExpr
Plugin: Plugin
Expand All @@ -560,12 +589,13 @@ export interface ZModelAstType {
ThisExpr: ThisExpr
TypeDeclaration: TypeDeclaration
UnaryExpr: UnaryExpr
UnsupportedFieldType: UnsupportedFieldType
}

export class ZModelAstReflection extends AbstractAstReflection {

getAllTypes(): string[] {
return ['AbstractDeclaration', 'Argument', 'ArrayExpr', 'Attribute', 'AttributeArg', 'AttributeAttribute', 'AttributeParam', 'AttributeParamType', 'BinaryExpr', 'DataModel', 'DataModelAttribute', 'DataModelField', 'DataModelFieldAttribute', 'DataModelFieldType', 'DataSource', 'DataSourceField', 'Enum', 'EnumField', 'Expression', 'FieldInitializer', 'FunctionDecl', 'FunctionParam', 'FunctionParamType', 'GeneratorDecl', 'GeneratorField', 'InvocationExpr', 'LiteralExpr', 'MemberAccessExpr', 'Model', 'NullExpr', 'ObjectExpr', 'Plugin', 'PluginField', 'ReferenceArg', 'ReferenceExpr', 'ReferenceTarget', 'ThisExpr', 'TypeDeclaration', 'UnaryExpr'];
return ['AbstractDeclaration', 'Argument', 'ArrayExpr', 'Attribute', 'AttributeArg', 'AttributeAttribute', 'AttributeParam', 'AttributeParamType', 'BinaryExpr', 'DataModel', 'DataModelAttribute', 'DataModelField', 'DataModelFieldAttribute', 'DataModelFieldType', 'DataSource', 'DataSourceField', 'Enum', 'EnumField', 'Expression', 'FieldInitializer', 'FunctionDecl', 'FunctionParam', 'FunctionParamType', 'GeneratorDecl', 'GeneratorField', 'InvocationExpr', 'LiteralExpr', 'MemberAccessExpr', 'Model', 'ModelImport', 'NullExpr', 'ObjectExpr', 'Plugin', 'PluginField', 'ReferenceArg', 'ReferenceExpr', 'ReferenceTarget', 'ThisExpr', 'TypeDeclaration', 'UnaryExpr', 'UnsupportedFieldType'];
}

protected override computeIsSubtype(subtype: string, supertype: string): boolean {
Expand Down Expand Up @@ -617,6 +647,9 @@ export class ZModelAstReflection extends AbstractAstReflection {
case 'FunctionParamType:reference': {
return TypeDeclaration;
}
case 'DataModel:superTypes': {
return DataModel;
}
case 'InvocationExpr:function': {
return FunctionDecl;
}
Expand Down Expand Up @@ -682,7 +715,9 @@ export class ZModelAstReflection extends AbstractAstReflection {
mandatory: [
{ name: 'attributes', type: 'array' },
{ name: 'comments', type: 'array' },
{ name: 'fields', type: 'array' }
{ name: 'fields', type: 'array' },
{ name: 'isAbstract', type: 'boolean' },
{ name: 'superTypes', type: 'array' }
]
};
}
Expand Down Expand Up @@ -799,7 +834,8 @@ export class ZModelAstReflection extends AbstractAstReflection {
return {
name: 'Model',
mandatory: [
{ name: 'declarations', type: 'array' }
{ name: 'declarations', type: 'array' },
{ name: 'imports', type: 'array' }
]
};
}
Expand Down
Loading