Skip to content

Commit 4e57b96

Browse files
authored
feat: Add multi-schema file support (#368)
1 parent 170bc73 commit 4e57b96

File tree

21 files changed

+2525
-2470
lines changed

21 files changed

+2525
-2470
lines changed

.vscode/launch.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@
4141
"request": "attach",
4242
"skipFiles": ["<node_internals>/**"],
4343
"sourceMaps": true,
44-
"outFiles": ["${workspaceFolder}/bundle/**/*.js"]
44+
"outFiles": ["${workspaceFolder}/packages/schema/bundle/**/*.js"]
4545
},
4646
{
4747
"name": "Todo sample: debug server-side",

packages/language/src/generated/ast.ts

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -412,6 +412,7 @@ export function isMemberAccessExpr(item: unknown): item is MemberAccessExpr {
412412
export interface Model extends AstNode {
413413
readonly $type: 'Model';
414414
declarations: Array<AbstractDeclaration>
415+
imports: Array<ModelImport>
415416
}
416417

417418
export const Model = 'Model';
@@ -420,6 +421,18 @@ export function isModel(item: unknown): item is Model {
420421
return reflection.isInstance(item, Model);
421422
}
422423

424+
export interface ModelImport extends AstNode {
425+
readonly $container: Model;
426+
readonly $type: 'ModelImport';
427+
path: string
428+
}
429+
430+
export const ModelImport = 'ModelImport';
431+
432+
export function isModelImport(item: unknown): item is ModelImport {
433+
return reflection.isInstance(item, ModelImport);
434+
}
435+
423436
export interface NullExpr extends AstNode {
424437
readonly $container: Argument | ArrayExpr | AttributeArg | BinaryExpr | DataSourceField | FieldInitializer | FunctionDecl | GeneratorField | MemberAccessExpr | PluginField | UnaryExpr | UnsupportedFieldType;
425438
readonly $type: 'NullExpr';
@@ -563,6 +576,7 @@ export interface ZModelAstType {
563576
LiteralExpr: LiteralExpr
564577
MemberAccessExpr: MemberAccessExpr
565578
Model: Model
579+
ModelImport: ModelImport
566580
NullExpr: NullExpr
567581
ObjectExpr: ObjectExpr
568582
Plugin: Plugin
@@ -579,7 +593,7 @@ export interface ZModelAstType {
579593
export class ZModelAstReflection extends AbstractAstReflection {
580594

581595
getAllTypes(): string[] {
582-
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', 'UnsupportedFieldType'];
596+
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'];
583597
}
584598

585599
protected override computeIsSubtype(subtype: string, supertype: string): boolean {
@@ -813,7 +827,8 @@ export class ZModelAstReflection extends AbstractAstReflection {
813827
return {
814828
name: 'Model',
815829
mandatory: [
816-
{ name: 'declarations', type: 'array' }
830+
{ name: 'declarations', type: 'array' },
831+
{ name: 'imports', type: 'array' }
817832
]
818833
};
819834
}

0 commit comments

Comments
 (0)