@zenstackhq/language 3.0.0-beta.19 → 3.0.0-beta.20
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +1189 -63
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +67 -2
- package/dist/index.d.ts +67 -2
- package/dist/index.js +1138 -13
- package/dist/index.js.map +1 -1
- package/package.json +7 -6
- package/res/stdlib.zmodel +4 -2
package/dist/index.cjs
CHANGED
|
@@ -31,6 +31,7 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
31
31
|
// src/index.ts
|
|
32
32
|
var src_exports = {};
|
|
33
33
|
__export(src_exports, {
|
|
34
|
+
ZModelCodeGenerator: () => ZModelCodeGenerator,
|
|
34
35
|
ZModelLanguageMetaData: () => ZModelLanguageMetaData,
|
|
35
36
|
ZModelLanguageModule: () => ZModelLanguageModule,
|
|
36
37
|
ZModelSharedModule: () => ZModelSharedModule,
|
|
@@ -41,14 +42,18 @@ __export(src_exports, {
|
|
|
41
42
|
module.exports = __toCommonJS(src_exports);
|
|
42
43
|
|
|
43
44
|
// src/document.ts
|
|
44
|
-
var
|
|
45
|
-
var
|
|
45
|
+
var import_langium14 = require("langium");
|
|
46
|
+
var import_node_fs4 = __toESM(require("fs"), 1);
|
|
46
47
|
var import_node_path4 = __toESM(require("path"), 1);
|
|
47
48
|
var import_node_url4 = require("url");
|
|
48
49
|
|
|
49
50
|
// src/generated/ast.ts
|
|
50
51
|
var langium = __toESM(require("langium"), 1);
|
|
51
52
|
var AbstractDeclaration = "AbstractDeclaration";
|
|
53
|
+
function isAbstractDeclaration(item) {
|
|
54
|
+
return reflection.isInstance(item, AbstractDeclaration);
|
|
55
|
+
}
|
|
56
|
+
__name(isAbstractDeclaration, "isAbstractDeclaration");
|
|
52
57
|
var ConfigExpr = "ConfigExpr";
|
|
53
58
|
var Expression = "Expression";
|
|
54
59
|
function isExpression(item) {
|
|
@@ -75,6 +80,10 @@ function isAttribute(item) {
|
|
|
75
80
|
}
|
|
76
81
|
__name(isAttribute, "isAttribute");
|
|
77
82
|
var AttributeArg = "AttributeArg";
|
|
83
|
+
function isAttributeArg(item) {
|
|
84
|
+
return reflection.isInstance(item, AttributeArg);
|
|
85
|
+
}
|
|
86
|
+
__name(isAttributeArg, "isAttributeArg");
|
|
78
87
|
var AttributeParam = "AttributeParam";
|
|
79
88
|
var AttributeParamType = "AttributeParamType";
|
|
80
89
|
var BinaryExpr = "BinaryExpr";
|
|
@@ -93,6 +102,10 @@ function isConfigArrayExpr(item) {
|
|
|
93
102
|
}
|
|
94
103
|
__name(isConfigArrayExpr, "isConfigArrayExpr");
|
|
95
104
|
var ConfigField = "ConfigField";
|
|
105
|
+
function isConfigField(item) {
|
|
106
|
+
return reflection.isInstance(item, ConfigField);
|
|
107
|
+
}
|
|
108
|
+
__name(isConfigField, "isConfigField");
|
|
96
109
|
var ConfigInvocationArg = "ConfigInvocationArg";
|
|
97
110
|
var ConfigInvocationExpr = "ConfigInvocationExpr";
|
|
98
111
|
var DataField = "DataField";
|
|
@@ -137,10 +150,22 @@ function isEnumField(item) {
|
|
|
137
150
|
__name(isEnumField, "isEnumField");
|
|
138
151
|
var FieldInitializer = "FieldInitializer";
|
|
139
152
|
var FunctionDecl = "FunctionDecl";
|
|
153
|
+
function isFunctionDecl(item) {
|
|
154
|
+
return reflection.isInstance(item, FunctionDecl);
|
|
155
|
+
}
|
|
156
|
+
__name(isFunctionDecl, "isFunctionDecl");
|
|
140
157
|
var FunctionParam = "FunctionParam";
|
|
141
158
|
var FunctionParamType = "FunctionParamType";
|
|
142
159
|
var GeneratorDecl = "GeneratorDecl";
|
|
160
|
+
function isGeneratorDecl(item) {
|
|
161
|
+
return reflection.isInstance(item, GeneratorDecl);
|
|
162
|
+
}
|
|
163
|
+
__name(isGeneratorDecl, "isGeneratorDecl");
|
|
143
164
|
var InternalAttribute = "InternalAttribute";
|
|
165
|
+
function isInternalAttribute(item) {
|
|
166
|
+
return reflection.isInstance(item, InternalAttribute);
|
|
167
|
+
}
|
|
168
|
+
__name(isInternalAttribute, "isInternalAttribute");
|
|
144
169
|
var InvocationExpr = "InvocationExpr";
|
|
145
170
|
function isInvocationExpr(item) {
|
|
146
171
|
return reflection.isInstance(item, InvocationExpr);
|
|
@@ -157,6 +182,10 @@ function isModel(item) {
|
|
|
157
182
|
}
|
|
158
183
|
__name(isModel, "isModel");
|
|
159
184
|
var ModelImport = "ModelImport";
|
|
185
|
+
function isModelImport(item) {
|
|
186
|
+
return reflection.isInstance(item, ModelImport);
|
|
187
|
+
}
|
|
188
|
+
__name(isModelImport, "isModelImport");
|
|
160
189
|
var NullExpr = "NullExpr";
|
|
161
190
|
function isNullExpr(item) {
|
|
162
191
|
return reflection.isInstance(item, NullExpr);
|
|
@@ -178,6 +207,10 @@ function isPlugin(item) {
|
|
|
178
207
|
}
|
|
179
208
|
__name(isPlugin, "isPlugin");
|
|
180
209
|
var PluginField = "PluginField";
|
|
210
|
+
function isPluginField(item) {
|
|
211
|
+
return reflection.isInstance(item, PluginField);
|
|
212
|
+
}
|
|
213
|
+
__name(isPluginField, "isPluginField");
|
|
181
214
|
var Procedure = "Procedure";
|
|
182
215
|
var ProcedureParam = "ProcedureParam";
|
|
183
216
|
var ReferenceArg = "ReferenceArg";
|
|
@@ -1044,6 +1077,26 @@ var ZModelAstReflection = class extends langium.AbstractAstReflection {
|
|
|
1044
1077
|
};
|
|
1045
1078
|
var reflection = new ZModelAstReflection();
|
|
1046
1079
|
|
|
1080
|
+
// src/ast.ts
|
|
1081
|
+
var BinaryExprOperatorPriority = {
|
|
1082
|
+
//LogicalExpr
|
|
1083
|
+
"||": 1,
|
|
1084
|
+
"&&": 1,
|
|
1085
|
+
//EqualityExpr
|
|
1086
|
+
"==": 2,
|
|
1087
|
+
"!=": 2,
|
|
1088
|
+
//ComparisonExpr
|
|
1089
|
+
">": 3,
|
|
1090
|
+
"<": 3,
|
|
1091
|
+
">=": 3,
|
|
1092
|
+
"<=": 3,
|
|
1093
|
+
in: 4,
|
|
1094
|
+
//CollectionPredicateExpr
|
|
1095
|
+
"^": 5,
|
|
1096
|
+
"?": 5,
|
|
1097
|
+
"!": 5
|
|
1098
|
+
};
|
|
1099
|
+
|
|
1047
1100
|
// src/constants.ts
|
|
1048
1101
|
var SUPPORTED_PROVIDERS = [
|
|
1049
1102
|
"sqlite",
|
|
@@ -1074,8 +1127,8 @@ var ExpressionContext = /* @__PURE__ */ function(ExpressionContext2) {
|
|
|
1074
1127
|
}({});
|
|
1075
1128
|
|
|
1076
1129
|
// src/module.ts
|
|
1077
|
-
var
|
|
1078
|
-
var
|
|
1130
|
+
var import_langium13 = require("langium");
|
|
1131
|
+
var import_lsp5 = require("langium/lsp");
|
|
1079
1132
|
var import_node = require("langium/node");
|
|
1080
1133
|
var import_node_path3 = __toESM(require("path"), 1);
|
|
1081
1134
|
var import_node_url3 = require("url");
|
|
@@ -7204,9 +7257,876 @@ var ZModelValidator = class {
|
|
|
7204
7257
|
}
|
|
7205
7258
|
};
|
|
7206
7259
|
|
|
7207
|
-
// src/zmodel-
|
|
7260
|
+
// src/zmodel-comment-provider.ts
|
|
7208
7261
|
var import_langium7 = require("langium");
|
|
7209
|
-
var
|
|
7262
|
+
var import_ts_pattern2 = require("ts-pattern");
|
|
7263
|
+
var ZModelCommentProvider = class extends import_langium7.DefaultCommentProvider {
|
|
7264
|
+
static {
|
|
7265
|
+
__name(this, "ZModelCommentProvider");
|
|
7266
|
+
}
|
|
7267
|
+
getComment(node) {
|
|
7268
|
+
let comment = super.getComment(node);
|
|
7269
|
+
if (!comment) {
|
|
7270
|
+
comment = (0, import_ts_pattern2.match)(node).when(isDataModel, (d) => `/**
|
|
7271
|
+
* Model *${d.name}*
|
|
7272
|
+
*/`).when(isTypeDef, (d) => `/**
|
|
7273
|
+
* Type *${d.name}*
|
|
7274
|
+
*/`).when(isEnum, (e) => `/**
|
|
7275
|
+
* Enum *${e.name}*
|
|
7276
|
+
*/`).when(isEnumField, (f) => `/**
|
|
7277
|
+
* Value of enum *${f.$container?.name}*
|
|
7278
|
+
*/`).when(isDataField, (f) => `/**
|
|
7279
|
+
* Field of *${f.$container?.name}*
|
|
7280
|
+
*/`).when(isFunctionDecl, (f) => `/**
|
|
7281
|
+
* Function *${f.name}*
|
|
7282
|
+
*/`).otherwise(() => "");
|
|
7283
|
+
}
|
|
7284
|
+
return comment;
|
|
7285
|
+
}
|
|
7286
|
+
};
|
|
7287
|
+
|
|
7288
|
+
// src/zmodel-completion-provider.ts
|
|
7289
|
+
var import_lsp = require("langium/lsp");
|
|
7290
|
+
var import_node_fs2 = __toESM(require("fs"), 1);
|
|
7291
|
+
var import_ts_pattern3 = require("ts-pattern");
|
|
7292
|
+
var import_vscode_languageserver = require("vscode-languageserver");
|
|
7293
|
+
|
|
7294
|
+
// src/zmodel-code-generator.ts
|
|
7295
|
+
function _ts_decorate3(decorators, target, key, desc) {
|
|
7296
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
7297
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
7298
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
7299
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7300
|
+
}
|
|
7301
|
+
__name(_ts_decorate3, "_ts_decorate");
|
|
7302
|
+
function _ts_metadata3(k, v) {
|
|
7303
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
7304
|
+
}
|
|
7305
|
+
__name(_ts_metadata3, "_ts_metadata");
|
|
7306
|
+
var generationHandlers = /* @__PURE__ */ new Map();
|
|
7307
|
+
function gen(name) {
|
|
7308
|
+
return function(_target, _propertyKey, descriptor) {
|
|
7309
|
+
if (!generationHandlers.get(name)) {
|
|
7310
|
+
generationHandlers.set(name, descriptor);
|
|
7311
|
+
}
|
|
7312
|
+
return descriptor;
|
|
7313
|
+
};
|
|
7314
|
+
}
|
|
7315
|
+
__name(gen, "gen");
|
|
7316
|
+
var ZModelCodeGenerator = class {
|
|
7317
|
+
static {
|
|
7318
|
+
__name(this, "ZModelCodeGenerator");
|
|
7319
|
+
}
|
|
7320
|
+
options;
|
|
7321
|
+
constructor(options) {
|
|
7322
|
+
this.options = {
|
|
7323
|
+
binaryExprNumberOfSpaces: options?.binaryExprNumberOfSpaces ?? 1,
|
|
7324
|
+
unaryExprNumberOfSpaces: options?.unaryExprNumberOfSpaces ?? 0,
|
|
7325
|
+
indent: options?.indent ?? 4,
|
|
7326
|
+
quote: options?.quote ?? "single"
|
|
7327
|
+
};
|
|
7328
|
+
}
|
|
7329
|
+
/**
|
|
7330
|
+
* Generates ZModel source code from AST.
|
|
7331
|
+
*/
|
|
7332
|
+
generate(ast) {
|
|
7333
|
+
const handler = generationHandlers.get(ast.$type);
|
|
7334
|
+
if (!handler) {
|
|
7335
|
+
throw new Error(`No generation handler found for ${ast.$type}`);
|
|
7336
|
+
}
|
|
7337
|
+
return handler.value.call(this, ast);
|
|
7338
|
+
}
|
|
7339
|
+
_generateModel(ast) {
|
|
7340
|
+
return ast.declarations.map((d) => this.generate(d)).join("\n\n");
|
|
7341
|
+
}
|
|
7342
|
+
_generateDataSource(ast) {
|
|
7343
|
+
return `datasource ${ast.name} {
|
|
7344
|
+
${ast.fields.map((x) => this.indent + this.generate(x)).join("\n")}
|
|
7345
|
+
}`;
|
|
7346
|
+
}
|
|
7347
|
+
_generateEnum(ast) {
|
|
7348
|
+
return `enum ${ast.name} {
|
|
7349
|
+
${ast.fields.map((x) => this.indent + this.generate(x)).join("\n")}
|
|
7350
|
+
}`;
|
|
7351
|
+
}
|
|
7352
|
+
_generateEnumField(ast) {
|
|
7353
|
+
return `${ast.name}${ast.attributes.length > 0 ? " " + ast.attributes.map((x) => this.generate(x)).join(" ") : ""}`;
|
|
7354
|
+
}
|
|
7355
|
+
_generateGenerator(ast) {
|
|
7356
|
+
return `generator ${ast.name} {
|
|
7357
|
+
${ast.fields.map((x) => this.indent + this.generate(x)).join("\n")}
|
|
7358
|
+
}`;
|
|
7359
|
+
}
|
|
7360
|
+
_generateConfigField(ast) {
|
|
7361
|
+
return `${ast.name} = ${this.generate(ast.value)}`;
|
|
7362
|
+
}
|
|
7363
|
+
_generateConfigArrayExpr(ast) {
|
|
7364
|
+
return `[${ast.items.map((x) => this.generate(x)).join(", ")}]`;
|
|
7365
|
+
}
|
|
7366
|
+
_generateConfigInvocationExpr(ast) {
|
|
7367
|
+
if (ast.args.length === 0) {
|
|
7368
|
+
return ast.name;
|
|
7369
|
+
} else {
|
|
7370
|
+
return `${ast.name}(${ast.args.map((x) => (x.name ? x.name + ": " : "") + this.generate(x.value)).join(", ")})`;
|
|
7371
|
+
}
|
|
7372
|
+
}
|
|
7373
|
+
_generatePlugin(ast) {
|
|
7374
|
+
return `plugin ${ast.name} {
|
|
7375
|
+
${ast.fields.map((x) => this.indent + this.generate(x)).join("\n")}
|
|
7376
|
+
}`;
|
|
7377
|
+
}
|
|
7378
|
+
_generatePluginField(ast) {
|
|
7379
|
+
return `${ast.name} = ${this.generate(ast.value)}`;
|
|
7380
|
+
}
|
|
7381
|
+
_generateDataModel(ast) {
|
|
7382
|
+
return `${ast.isView ? "view" : "model"} ${ast.name}${ast.mixins.length > 0 ? " mixes " + ast.mixins.map((x) => x.ref?.name).join(", ") : ""} {
|
|
7383
|
+
${ast.fields.map((x) => this.indent + this.generate(x)).join("\n")}${ast.attributes.length > 0 ? "\n\n" + ast.attributes.map((x) => this.indent + this.generate(x)).join("\n") : ""}
|
|
7384
|
+
}`;
|
|
7385
|
+
}
|
|
7386
|
+
_generateDataField(ast) {
|
|
7387
|
+
return `${ast.name} ${this.fieldType(ast.type)}${ast.attributes.length > 0 ? " " + ast.attributes.map((x) => this.generate(x)).join(" ") : ""}`;
|
|
7388
|
+
}
|
|
7389
|
+
fieldType(type) {
|
|
7390
|
+
const baseType = type.type ? type.type : type.$type == "DataFieldType" && type.unsupported ? "Unsupported(" + this.generate(type.unsupported.value) + ")" : type.reference?.$refText;
|
|
7391
|
+
return `${baseType}${type.array ? "[]" : ""}${type.optional ? "?" : ""}`;
|
|
7392
|
+
}
|
|
7393
|
+
_generateDataModelAttribute(ast) {
|
|
7394
|
+
return this.attribute(ast);
|
|
7395
|
+
}
|
|
7396
|
+
_generateDataFieldAttribute(ast) {
|
|
7397
|
+
return this.attribute(ast);
|
|
7398
|
+
}
|
|
7399
|
+
attribute(ast) {
|
|
7400
|
+
const args = ast.args.length ? `(${ast.args.map((x) => this.generate(x)).join(", ")})` : "";
|
|
7401
|
+
return `${resolved(ast.decl).name}${args}`;
|
|
7402
|
+
}
|
|
7403
|
+
_generateAttributeArg(ast) {
|
|
7404
|
+
if (ast.name) {
|
|
7405
|
+
return `${ast.name}: ${this.generate(ast.value)}`;
|
|
7406
|
+
} else {
|
|
7407
|
+
return this.generate(ast.value);
|
|
7408
|
+
}
|
|
7409
|
+
}
|
|
7410
|
+
_generateObjectExpr(ast) {
|
|
7411
|
+
return `{ ${ast.fields.map((field) => this.objectField(field)).join(", ")} }`;
|
|
7412
|
+
}
|
|
7413
|
+
objectField(field) {
|
|
7414
|
+
return `${field.name}: ${this.generate(field.value)}`;
|
|
7415
|
+
}
|
|
7416
|
+
_generateArrayExpr(ast) {
|
|
7417
|
+
return `[${ast.items.map((item) => this.generate(item)).join(", ")}]`;
|
|
7418
|
+
}
|
|
7419
|
+
_generateLiteralExpr(ast) {
|
|
7420
|
+
return this.options.quote === "single" ? `'${ast.value}'` : `"${ast.value}"`;
|
|
7421
|
+
}
|
|
7422
|
+
_generateNumberLiteral(ast) {
|
|
7423
|
+
return ast.value.toString();
|
|
7424
|
+
}
|
|
7425
|
+
_generateBooleanLiteral(ast) {
|
|
7426
|
+
return ast.value.toString();
|
|
7427
|
+
}
|
|
7428
|
+
_generateUnaryExpr(ast) {
|
|
7429
|
+
return `${ast.operator}${this.unaryExprSpace}${this.generate(ast.operand)}`;
|
|
7430
|
+
}
|
|
7431
|
+
_generateBinaryExpr(ast) {
|
|
7432
|
+
const operator = ast.operator;
|
|
7433
|
+
const isCollectionPredicate2 = this.isCollectionPredicateOperator(operator);
|
|
7434
|
+
const rightExpr = this.generate(ast.right);
|
|
7435
|
+
const { left: isLeftParenthesis, right: isRightParenthesis } = this.isParenthesesNeededForBinaryExpr(ast);
|
|
7436
|
+
return `${isLeftParenthesis ? "(" : ""}${this.generate(ast.left)}${isLeftParenthesis ? ")" : ""}${isCollectionPredicate2 ? "" : this.binaryExprSpace}${operator}${isCollectionPredicate2 ? "" : this.binaryExprSpace}${isRightParenthesis ? "(" : ""}${isCollectionPredicate2 ? `[${rightExpr}]` : rightExpr}${isRightParenthesis ? ")" : ""}`;
|
|
7437
|
+
}
|
|
7438
|
+
_generateReferenceExpr(ast) {
|
|
7439
|
+
const args = ast.args.length ? `(${ast.args.map((x) => this.generate(x)).join(", ")})` : "";
|
|
7440
|
+
return `${ast.target.ref?.name}${args}`;
|
|
7441
|
+
}
|
|
7442
|
+
_generateReferenceArg(ast) {
|
|
7443
|
+
return `${ast.name}:${this.generate(ast.value)}`;
|
|
7444
|
+
}
|
|
7445
|
+
_generateMemberExpr(ast) {
|
|
7446
|
+
return `${this.generate(ast.operand)}.${ast.member.ref?.name}`;
|
|
7447
|
+
}
|
|
7448
|
+
_generateInvocationExpr(ast) {
|
|
7449
|
+
return `${ast.function.ref?.name}(${ast.args.map((x) => this.argument(x)).join(", ")})`;
|
|
7450
|
+
}
|
|
7451
|
+
_generateNullExpr() {
|
|
7452
|
+
return "null";
|
|
7453
|
+
}
|
|
7454
|
+
_generateThisExpr() {
|
|
7455
|
+
return "this";
|
|
7456
|
+
}
|
|
7457
|
+
_generateAttribute(ast) {
|
|
7458
|
+
return `attribute ${ast.name}(${ast.params.map((x) => this.generate(x)).join(", ")})`;
|
|
7459
|
+
}
|
|
7460
|
+
_generateAttributeParam(ast) {
|
|
7461
|
+
return `${ast.default ? "_ " : ""}${ast.name}: ${this.generate(ast.type)}`;
|
|
7462
|
+
}
|
|
7463
|
+
_generateAttributeParamType(ast) {
|
|
7464
|
+
return `${ast.type ?? ast.reference?.$refText}${ast.array ? "[]" : ""}${ast.optional ? "?" : ""}`;
|
|
7465
|
+
}
|
|
7466
|
+
_generateFunctionDecl(ast) {
|
|
7467
|
+
return `function ${ast.name}(${ast.params.map((x) => this.generate(x)).join(", ")}) ${ast.returnType ? ": " + this.generate(ast.returnType) : ""} {}`;
|
|
7468
|
+
}
|
|
7469
|
+
_generateFunctionParam(ast) {
|
|
7470
|
+
return `${ast.name}: ${this.generate(ast.type)}`;
|
|
7471
|
+
}
|
|
7472
|
+
_generateFunctionParamType(ast) {
|
|
7473
|
+
return `${ast.type ?? ast.reference?.$refText}${ast.array ? "[]" : ""}`;
|
|
7474
|
+
}
|
|
7475
|
+
_generateTypeDef(ast) {
|
|
7476
|
+
return `type ${ast.name} {
|
|
7477
|
+
${ast.fields.map((x) => this.indent + this.generate(x)).join("\n")}${ast.attributes.length > 0 ? "\n\n" + ast.attributes.map((x) => this.indent + this.generate(x)).join("\n") : ""}
|
|
7478
|
+
}`;
|
|
7479
|
+
}
|
|
7480
|
+
argument(ast) {
|
|
7481
|
+
return this.generate(ast.value);
|
|
7482
|
+
}
|
|
7483
|
+
get binaryExprSpace() {
|
|
7484
|
+
return " ".repeat(this.options.binaryExprNumberOfSpaces);
|
|
7485
|
+
}
|
|
7486
|
+
get unaryExprSpace() {
|
|
7487
|
+
return " ".repeat(this.options.unaryExprNumberOfSpaces);
|
|
7488
|
+
}
|
|
7489
|
+
get indent() {
|
|
7490
|
+
return " ".repeat(this.options.indent);
|
|
7491
|
+
}
|
|
7492
|
+
isParenthesesNeededForBinaryExpr(ast) {
|
|
7493
|
+
const result = {
|
|
7494
|
+
left: false,
|
|
7495
|
+
right: false
|
|
7496
|
+
};
|
|
7497
|
+
const operator = ast.operator;
|
|
7498
|
+
const isCollectionPredicate2 = this.isCollectionPredicateOperator(operator);
|
|
7499
|
+
const currentPriority = BinaryExprOperatorPriority[operator];
|
|
7500
|
+
if (ast.left.$type === BinaryExpr && BinaryExprOperatorPriority[ast.left["operator"]] < currentPriority) {
|
|
7501
|
+
result.left = true;
|
|
7502
|
+
}
|
|
7503
|
+
if (!isCollectionPredicate2 && ast.right.$type === BinaryExpr && BinaryExprOperatorPriority[ast.right["operator"]] <= currentPriority) {
|
|
7504
|
+
result.right = true;
|
|
7505
|
+
}
|
|
7506
|
+
return result;
|
|
7507
|
+
}
|
|
7508
|
+
isCollectionPredicateOperator(op) {
|
|
7509
|
+
return [
|
|
7510
|
+
"?",
|
|
7511
|
+
"!",
|
|
7512
|
+
"^"
|
|
7513
|
+
].includes(op);
|
|
7514
|
+
}
|
|
7515
|
+
};
|
|
7516
|
+
_ts_decorate3([
|
|
7517
|
+
gen(Model),
|
|
7518
|
+
_ts_metadata3("design:type", Function),
|
|
7519
|
+
_ts_metadata3("design:paramtypes", [
|
|
7520
|
+
typeof Model === "undefined" ? Object : Model
|
|
7521
|
+
]),
|
|
7522
|
+
_ts_metadata3("design:returntype", void 0)
|
|
7523
|
+
], ZModelCodeGenerator.prototype, "_generateModel", null);
|
|
7524
|
+
_ts_decorate3([
|
|
7525
|
+
gen(DataSource),
|
|
7526
|
+
_ts_metadata3("design:type", Function),
|
|
7527
|
+
_ts_metadata3("design:paramtypes", [
|
|
7528
|
+
typeof DataSource === "undefined" ? Object : DataSource
|
|
7529
|
+
]),
|
|
7530
|
+
_ts_metadata3("design:returntype", void 0)
|
|
7531
|
+
], ZModelCodeGenerator.prototype, "_generateDataSource", null);
|
|
7532
|
+
_ts_decorate3([
|
|
7533
|
+
gen(Enum),
|
|
7534
|
+
_ts_metadata3("design:type", Function),
|
|
7535
|
+
_ts_metadata3("design:paramtypes", [
|
|
7536
|
+
typeof Enum === "undefined" ? Object : Enum
|
|
7537
|
+
]),
|
|
7538
|
+
_ts_metadata3("design:returntype", void 0)
|
|
7539
|
+
], ZModelCodeGenerator.prototype, "_generateEnum", null);
|
|
7540
|
+
_ts_decorate3([
|
|
7541
|
+
gen(EnumField),
|
|
7542
|
+
_ts_metadata3("design:type", Function),
|
|
7543
|
+
_ts_metadata3("design:paramtypes", [
|
|
7544
|
+
typeof EnumField === "undefined" ? Object : EnumField
|
|
7545
|
+
]),
|
|
7546
|
+
_ts_metadata3("design:returntype", void 0)
|
|
7547
|
+
], ZModelCodeGenerator.prototype, "_generateEnumField", null);
|
|
7548
|
+
_ts_decorate3([
|
|
7549
|
+
gen(GeneratorDecl),
|
|
7550
|
+
_ts_metadata3("design:type", Function),
|
|
7551
|
+
_ts_metadata3("design:paramtypes", [
|
|
7552
|
+
typeof GeneratorDecl === "undefined" ? Object : GeneratorDecl
|
|
7553
|
+
]),
|
|
7554
|
+
_ts_metadata3("design:returntype", void 0)
|
|
7555
|
+
], ZModelCodeGenerator.prototype, "_generateGenerator", null);
|
|
7556
|
+
_ts_decorate3([
|
|
7557
|
+
gen(ConfigField),
|
|
7558
|
+
_ts_metadata3("design:type", Function),
|
|
7559
|
+
_ts_metadata3("design:paramtypes", [
|
|
7560
|
+
typeof ConfigField === "undefined" ? Object : ConfigField
|
|
7561
|
+
]),
|
|
7562
|
+
_ts_metadata3("design:returntype", void 0)
|
|
7563
|
+
], ZModelCodeGenerator.prototype, "_generateConfigField", null);
|
|
7564
|
+
_ts_decorate3([
|
|
7565
|
+
gen(ConfigArrayExpr),
|
|
7566
|
+
_ts_metadata3("design:type", Function),
|
|
7567
|
+
_ts_metadata3("design:paramtypes", [
|
|
7568
|
+
typeof ConfigArrayExpr === "undefined" ? Object : ConfigArrayExpr
|
|
7569
|
+
]),
|
|
7570
|
+
_ts_metadata3("design:returntype", void 0)
|
|
7571
|
+
], ZModelCodeGenerator.prototype, "_generateConfigArrayExpr", null);
|
|
7572
|
+
_ts_decorate3([
|
|
7573
|
+
gen(ConfigInvocationExpr),
|
|
7574
|
+
_ts_metadata3("design:type", Function),
|
|
7575
|
+
_ts_metadata3("design:paramtypes", [
|
|
7576
|
+
typeof ConfigInvocationExpr === "undefined" ? Object : ConfigInvocationExpr
|
|
7577
|
+
]),
|
|
7578
|
+
_ts_metadata3("design:returntype", void 0)
|
|
7579
|
+
], ZModelCodeGenerator.prototype, "_generateConfigInvocationExpr", null);
|
|
7580
|
+
_ts_decorate3([
|
|
7581
|
+
gen(Plugin),
|
|
7582
|
+
_ts_metadata3("design:type", Function),
|
|
7583
|
+
_ts_metadata3("design:paramtypes", [
|
|
7584
|
+
typeof Plugin === "undefined" ? Object : Plugin
|
|
7585
|
+
]),
|
|
7586
|
+
_ts_metadata3("design:returntype", void 0)
|
|
7587
|
+
], ZModelCodeGenerator.prototype, "_generatePlugin", null);
|
|
7588
|
+
_ts_decorate3([
|
|
7589
|
+
gen(PluginField),
|
|
7590
|
+
_ts_metadata3("design:type", Function),
|
|
7591
|
+
_ts_metadata3("design:paramtypes", [
|
|
7592
|
+
typeof PluginField === "undefined" ? Object : PluginField
|
|
7593
|
+
]),
|
|
7594
|
+
_ts_metadata3("design:returntype", void 0)
|
|
7595
|
+
], ZModelCodeGenerator.prototype, "_generatePluginField", null);
|
|
7596
|
+
_ts_decorate3([
|
|
7597
|
+
gen(DataModel),
|
|
7598
|
+
_ts_metadata3("design:type", Function),
|
|
7599
|
+
_ts_metadata3("design:paramtypes", [
|
|
7600
|
+
typeof DataModel === "undefined" ? Object : DataModel
|
|
7601
|
+
]),
|
|
7602
|
+
_ts_metadata3("design:returntype", void 0)
|
|
7603
|
+
], ZModelCodeGenerator.prototype, "_generateDataModel", null);
|
|
7604
|
+
_ts_decorate3([
|
|
7605
|
+
gen(DataField),
|
|
7606
|
+
_ts_metadata3("design:type", Function),
|
|
7607
|
+
_ts_metadata3("design:paramtypes", [
|
|
7608
|
+
typeof DataField === "undefined" ? Object : DataField
|
|
7609
|
+
]),
|
|
7610
|
+
_ts_metadata3("design:returntype", void 0)
|
|
7611
|
+
], ZModelCodeGenerator.prototype, "_generateDataField", null);
|
|
7612
|
+
_ts_decorate3([
|
|
7613
|
+
gen(DataModelAttribute),
|
|
7614
|
+
_ts_metadata3("design:type", Function),
|
|
7615
|
+
_ts_metadata3("design:paramtypes", [
|
|
7616
|
+
typeof DataModelAttribute === "undefined" ? Object : DataModelAttribute
|
|
7617
|
+
]),
|
|
7618
|
+
_ts_metadata3("design:returntype", void 0)
|
|
7619
|
+
], ZModelCodeGenerator.prototype, "_generateDataModelAttribute", null);
|
|
7620
|
+
_ts_decorate3([
|
|
7621
|
+
gen(DataFieldAttribute),
|
|
7622
|
+
_ts_metadata3("design:type", Function),
|
|
7623
|
+
_ts_metadata3("design:paramtypes", [
|
|
7624
|
+
typeof DataFieldAttribute === "undefined" ? Object : DataFieldAttribute
|
|
7625
|
+
]),
|
|
7626
|
+
_ts_metadata3("design:returntype", void 0)
|
|
7627
|
+
], ZModelCodeGenerator.prototype, "_generateDataFieldAttribute", null);
|
|
7628
|
+
_ts_decorate3([
|
|
7629
|
+
gen(AttributeArg),
|
|
7630
|
+
_ts_metadata3("design:type", Function),
|
|
7631
|
+
_ts_metadata3("design:paramtypes", [
|
|
7632
|
+
typeof AttributeArg === "undefined" ? Object : AttributeArg
|
|
7633
|
+
]),
|
|
7634
|
+
_ts_metadata3("design:returntype", void 0)
|
|
7635
|
+
], ZModelCodeGenerator.prototype, "_generateAttributeArg", null);
|
|
7636
|
+
_ts_decorate3([
|
|
7637
|
+
gen(ObjectExpr),
|
|
7638
|
+
_ts_metadata3("design:type", Function),
|
|
7639
|
+
_ts_metadata3("design:paramtypes", [
|
|
7640
|
+
typeof ObjectExpr === "undefined" ? Object : ObjectExpr
|
|
7641
|
+
]),
|
|
7642
|
+
_ts_metadata3("design:returntype", void 0)
|
|
7643
|
+
], ZModelCodeGenerator.prototype, "_generateObjectExpr", null);
|
|
7644
|
+
_ts_decorate3([
|
|
7645
|
+
gen(ArrayExpr),
|
|
7646
|
+
_ts_metadata3("design:type", Function),
|
|
7647
|
+
_ts_metadata3("design:paramtypes", [
|
|
7648
|
+
typeof ArrayExpr === "undefined" ? Object : ArrayExpr
|
|
7649
|
+
]),
|
|
7650
|
+
_ts_metadata3("design:returntype", void 0)
|
|
7651
|
+
], ZModelCodeGenerator.prototype, "_generateArrayExpr", null);
|
|
7652
|
+
_ts_decorate3([
|
|
7653
|
+
gen(StringLiteral),
|
|
7654
|
+
_ts_metadata3("design:type", Function),
|
|
7655
|
+
_ts_metadata3("design:paramtypes", [
|
|
7656
|
+
typeof LiteralExpr === "undefined" ? Object : LiteralExpr
|
|
7657
|
+
]),
|
|
7658
|
+
_ts_metadata3("design:returntype", void 0)
|
|
7659
|
+
], ZModelCodeGenerator.prototype, "_generateLiteralExpr", null);
|
|
7660
|
+
_ts_decorate3([
|
|
7661
|
+
gen(NumberLiteral),
|
|
7662
|
+
_ts_metadata3("design:type", Function),
|
|
7663
|
+
_ts_metadata3("design:paramtypes", [
|
|
7664
|
+
typeof NumberLiteral === "undefined" ? Object : NumberLiteral
|
|
7665
|
+
]),
|
|
7666
|
+
_ts_metadata3("design:returntype", void 0)
|
|
7667
|
+
], ZModelCodeGenerator.prototype, "_generateNumberLiteral", null);
|
|
7668
|
+
_ts_decorate3([
|
|
7669
|
+
gen(BooleanLiteral),
|
|
7670
|
+
_ts_metadata3("design:type", Function),
|
|
7671
|
+
_ts_metadata3("design:paramtypes", [
|
|
7672
|
+
typeof BooleanLiteral === "undefined" ? Object : BooleanLiteral
|
|
7673
|
+
]),
|
|
7674
|
+
_ts_metadata3("design:returntype", void 0)
|
|
7675
|
+
], ZModelCodeGenerator.prototype, "_generateBooleanLiteral", null);
|
|
7676
|
+
_ts_decorate3([
|
|
7677
|
+
gen(UnaryExpr),
|
|
7678
|
+
_ts_metadata3("design:type", Function),
|
|
7679
|
+
_ts_metadata3("design:paramtypes", [
|
|
7680
|
+
typeof UnaryExpr === "undefined" ? Object : UnaryExpr
|
|
7681
|
+
]),
|
|
7682
|
+
_ts_metadata3("design:returntype", void 0)
|
|
7683
|
+
], ZModelCodeGenerator.prototype, "_generateUnaryExpr", null);
|
|
7684
|
+
_ts_decorate3([
|
|
7685
|
+
gen(BinaryExpr),
|
|
7686
|
+
_ts_metadata3("design:type", Function),
|
|
7687
|
+
_ts_metadata3("design:paramtypes", [
|
|
7688
|
+
typeof BinaryExpr === "undefined" ? Object : BinaryExpr
|
|
7689
|
+
]),
|
|
7690
|
+
_ts_metadata3("design:returntype", void 0)
|
|
7691
|
+
], ZModelCodeGenerator.prototype, "_generateBinaryExpr", null);
|
|
7692
|
+
_ts_decorate3([
|
|
7693
|
+
gen(ReferenceExpr),
|
|
7694
|
+
_ts_metadata3("design:type", Function),
|
|
7695
|
+
_ts_metadata3("design:paramtypes", [
|
|
7696
|
+
typeof ReferenceExpr === "undefined" ? Object : ReferenceExpr
|
|
7697
|
+
]),
|
|
7698
|
+
_ts_metadata3("design:returntype", void 0)
|
|
7699
|
+
], ZModelCodeGenerator.prototype, "_generateReferenceExpr", null);
|
|
7700
|
+
_ts_decorate3([
|
|
7701
|
+
gen(ReferenceArg),
|
|
7702
|
+
_ts_metadata3("design:type", Function),
|
|
7703
|
+
_ts_metadata3("design:paramtypes", [
|
|
7704
|
+
typeof ReferenceArg === "undefined" ? Object : ReferenceArg
|
|
7705
|
+
]),
|
|
7706
|
+
_ts_metadata3("design:returntype", void 0)
|
|
7707
|
+
], ZModelCodeGenerator.prototype, "_generateReferenceArg", null);
|
|
7708
|
+
_ts_decorate3([
|
|
7709
|
+
gen(MemberAccessExpr),
|
|
7710
|
+
_ts_metadata3("design:type", Function),
|
|
7711
|
+
_ts_metadata3("design:paramtypes", [
|
|
7712
|
+
typeof MemberAccessExpr === "undefined" ? Object : MemberAccessExpr
|
|
7713
|
+
]),
|
|
7714
|
+
_ts_metadata3("design:returntype", void 0)
|
|
7715
|
+
], ZModelCodeGenerator.prototype, "_generateMemberExpr", null);
|
|
7716
|
+
_ts_decorate3([
|
|
7717
|
+
gen(InvocationExpr),
|
|
7718
|
+
_ts_metadata3("design:type", Function),
|
|
7719
|
+
_ts_metadata3("design:paramtypes", [
|
|
7720
|
+
typeof InvocationExpr === "undefined" ? Object : InvocationExpr
|
|
7721
|
+
]),
|
|
7722
|
+
_ts_metadata3("design:returntype", void 0)
|
|
7723
|
+
], ZModelCodeGenerator.prototype, "_generateInvocationExpr", null);
|
|
7724
|
+
_ts_decorate3([
|
|
7725
|
+
gen(NullExpr),
|
|
7726
|
+
_ts_metadata3("design:type", Function),
|
|
7727
|
+
_ts_metadata3("design:paramtypes", []),
|
|
7728
|
+
_ts_metadata3("design:returntype", void 0)
|
|
7729
|
+
], ZModelCodeGenerator.prototype, "_generateNullExpr", null);
|
|
7730
|
+
_ts_decorate3([
|
|
7731
|
+
gen(ThisExpr),
|
|
7732
|
+
_ts_metadata3("design:type", Function),
|
|
7733
|
+
_ts_metadata3("design:paramtypes", []),
|
|
7734
|
+
_ts_metadata3("design:returntype", void 0)
|
|
7735
|
+
], ZModelCodeGenerator.prototype, "_generateThisExpr", null);
|
|
7736
|
+
_ts_decorate3([
|
|
7737
|
+
gen(Attribute),
|
|
7738
|
+
_ts_metadata3("design:type", Function),
|
|
7739
|
+
_ts_metadata3("design:paramtypes", [
|
|
7740
|
+
typeof Attribute === "undefined" ? Object : Attribute
|
|
7741
|
+
]),
|
|
7742
|
+
_ts_metadata3("design:returntype", void 0)
|
|
7743
|
+
], ZModelCodeGenerator.prototype, "_generateAttribute", null);
|
|
7744
|
+
_ts_decorate3([
|
|
7745
|
+
gen(AttributeParam),
|
|
7746
|
+
_ts_metadata3("design:type", Function),
|
|
7747
|
+
_ts_metadata3("design:paramtypes", [
|
|
7748
|
+
typeof AttributeParam === "undefined" ? Object : AttributeParam
|
|
7749
|
+
]),
|
|
7750
|
+
_ts_metadata3("design:returntype", void 0)
|
|
7751
|
+
], ZModelCodeGenerator.prototype, "_generateAttributeParam", null);
|
|
7752
|
+
_ts_decorate3([
|
|
7753
|
+
gen(AttributeParamType),
|
|
7754
|
+
_ts_metadata3("design:type", Function),
|
|
7755
|
+
_ts_metadata3("design:paramtypes", [
|
|
7756
|
+
typeof AttributeParamType === "undefined" ? Object : AttributeParamType
|
|
7757
|
+
]),
|
|
7758
|
+
_ts_metadata3("design:returntype", void 0)
|
|
7759
|
+
], ZModelCodeGenerator.prototype, "_generateAttributeParamType", null);
|
|
7760
|
+
_ts_decorate3([
|
|
7761
|
+
gen(FunctionDecl),
|
|
7762
|
+
_ts_metadata3("design:type", Function),
|
|
7763
|
+
_ts_metadata3("design:paramtypes", [
|
|
7764
|
+
typeof FunctionDecl === "undefined" ? Object : FunctionDecl
|
|
7765
|
+
]),
|
|
7766
|
+
_ts_metadata3("design:returntype", void 0)
|
|
7767
|
+
], ZModelCodeGenerator.prototype, "_generateFunctionDecl", null);
|
|
7768
|
+
_ts_decorate3([
|
|
7769
|
+
gen(FunctionParam),
|
|
7770
|
+
_ts_metadata3("design:type", Function),
|
|
7771
|
+
_ts_metadata3("design:paramtypes", [
|
|
7772
|
+
typeof FunctionParam === "undefined" ? Object : FunctionParam
|
|
7773
|
+
]),
|
|
7774
|
+
_ts_metadata3("design:returntype", void 0)
|
|
7775
|
+
], ZModelCodeGenerator.prototype, "_generateFunctionParam", null);
|
|
7776
|
+
_ts_decorate3([
|
|
7777
|
+
gen(FunctionParamType),
|
|
7778
|
+
_ts_metadata3("design:type", Function),
|
|
7779
|
+
_ts_metadata3("design:paramtypes", [
|
|
7780
|
+
typeof FunctionParamType === "undefined" ? Object : FunctionParamType
|
|
7781
|
+
]),
|
|
7782
|
+
_ts_metadata3("design:returntype", void 0)
|
|
7783
|
+
], ZModelCodeGenerator.prototype, "_generateFunctionParamType", null);
|
|
7784
|
+
_ts_decorate3([
|
|
7785
|
+
gen(TypeDef),
|
|
7786
|
+
_ts_metadata3("design:type", Function),
|
|
7787
|
+
_ts_metadata3("design:paramtypes", [
|
|
7788
|
+
typeof TypeDef === "undefined" ? Object : TypeDef
|
|
7789
|
+
]),
|
|
7790
|
+
_ts_metadata3("design:returntype", void 0)
|
|
7791
|
+
], ZModelCodeGenerator.prototype, "_generateTypeDef", null);
|
|
7792
|
+
|
|
7793
|
+
// src/zmodel-completion-provider.ts
|
|
7794
|
+
var ZModelCompletionProvider = class extends import_lsp.DefaultCompletionProvider {
|
|
7795
|
+
static {
|
|
7796
|
+
__name(this, "ZModelCompletionProvider");
|
|
7797
|
+
}
|
|
7798
|
+
services;
|
|
7799
|
+
constructor(services) {
|
|
7800
|
+
super(services), this.services = services;
|
|
7801
|
+
}
|
|
7802
|
+
completionOptions = {
|
|
7803
|
+
triggerCharacters: [
|
|
7804
|
+
"@",
|
|
7805
|
+
"(",
|
|
7806
|
+
",",
|
|
7807
|
+
"."
|
|
7808
|
+
]
|
|
7809
|
+
};
|
|
7810
|
+
async getCompletion(document, params) {
|
|
7811
|
+
try {
|
|
7812
|
+
return await super.getCompletion(document, params);
|
|
7813
|
+
} catch (e) {
|
|
7814
|
+
console.error("Completion error:", e.message);
|
|
7815
|
+
return void 0;
|
|
7816
|
+
}
|
|
7817
|
+
}
|
|
7818
|
+
completionFor(context, next, acceptor) {
|
|
7819
|
+
if (isDataModelAttribute(context.node) || isDataFieldAttribute(context.node)) {
|
|
7820
|
+
const completions = this.getCompletionFromHint(context.node);
|
|
7821
|
+
if (completions) {
|
|
7822
|
+
completions.forEach((c) => acceptor(context, c));
|
|
7823
|
+
return;
|
|
7824
|
+
}
|
|
7825
|
+
}
|
|
7826
|
+
return super.completionFor(context, next, acceptor);
|
|
7827
|
+
}
|
|
7828
|
+
getCompletionFromHint(contextNode) {
|
|
7829
|
+
const unfilledParams = this.getUnfilledAttributeParams(contextNode);
|
|
7830
|
+
const nextParam = unfilledParams[0];
|
|
7831
|
+
if (!nextParam) {
|
|
7832
|
+
return void 0;
|
|
7833
|
+
}
|
|
7834
|
+
const hintAttr = getAttribute(nextParam, "@@@completionHint");
|
|
7835
|
+
if (hintAttr) {
|
|
7836
|
+
const hint = hintAttr.args[0];
|
|
7837
|
+
if (hint?.value) {
|
|
7838
|
+
if (isArrayExpr(hint.value)) {
|
|
7839
|
+
return hint.value.items.map((item) => {
|
|
7840
|
+
return {
|
|
7841
|
+
label: `${item.value}`,
|
|
7842
|
+
kind: import_vscode_languageserver.CompletionItemKind.Value,
|
|
7843
|
+
detail: "Parameter",
|
|
7844
|
+
sortText: "0"
|
|
7845
|
+
};
|
|
7846
|
+
});
|
|
7847
|
+
}
|
|
7848
|
+
}
|
|
7849
|
+
}
|
|
7850
|
+
return void 0;
|
|
7851
|
+
}
|
|
7852
|
+
// TODO: this doesn't work when the file contains parse errors
|
|
7853
|
+
getUnfilledAttributeParams(contextNode) {
|
|
7854
|
+
try {
|
|
7855
|
+
const params = contextNode.decl.ref?.params;
|
|
7856
|
+
if (params) {
|
|
7857
|
+
const args = contextNode.args;
|
|
7858
|
+
let unfilledParams = [
|
|
7859
|
+
...params
|
|
7860
|
+
];
|
|
7861
|
+
args.forEach((arg) => {
|
|
7862
|
+
if (arg.name) {
|
|
7863
|
+
unfilledParams = unfilledParams.filter((p) => p.name !== arg.name);
|
|
7864
|
+
} else {
|
|
7865
|
+
unfilledParams.shift();
|
|
7866
|
+
}
|
|
7867
|
+
});
|
|
7868
|
+
return unfilledParams;
|
|
7869
|
+
}
|
|
7870
|
+
} catch {
|
|
7871
|
+
}
|
|
7872
|
+
return [];
|
|
7873
|
+
}
|
|
7874
|
+
completionForCrossReference(context, crossRef, acceptor) {
|
|
7875
|
+
if (crossRef.property === "member" && !isMemberAccessExpr(context.node)) {
|
|
7876
|
+
return;
|
|
7877
|
+
}
|
|
7878
|
+
const customAcceptor = /* @__PURE__ */ __name((context2, item) => {
|
|
7879
|
+
if (item.insertText?.startsWith("@@@") || item.label?.startsWith("@@@")) {
|
|
7880
|
+
return;
|
|
7881
|
+
}
|
|
7882
|
+
if ("nodeDescription" in item) {
|
|
7883
|
+
const node = this.getAstNode(item.nodeDescription);
|
|
7884
|
+
if (!node) {
|
|
7885
|
+
return;
|
|
7886
|
+
}
|
|
7887
|
+
if ((isEnum(node) || isEnumField(node)) && isFromStdlib(node)) {
|
|
7888
|
+
return;
|
|
7889
|
+
}
|
|
7890
|
+
if ((isDataModelAttribute(context2.node) || isDataFieldAttribute(context2.node)) && !this.filterAttributeApplicationCompletion(context2.node, node)) {
|
|
7891
|
+
return;
|
|
7892
|
+
}
|
|
7893
|
+
}
|
|
7894
|
+
acceptor(context2, item);
|
|
7895
|
+
}, "customAcceptor");
|
|
7896
|
+
return super.completionForCrossReference(context, crossRef, customAcceptor);
|
|
7897
|
+
}
|
|
7898
|
+
completionForKeyword(context, keyword, acceptor) {
|
|
7899
|
+
const customAcceptor = /* @__PURE__ */ __name((context2, item) => {
|
|
7900
|
+
if (!this.filterKeywordForContext(context2, keyword.value)) {
|
|
7901
|
+
return;
|
|
7902
|
+
}
|
|
7903
|
+
acceptor(context2, item);
|
|
7904
|
+
}, "customAcceptor");
|
|
7905
|
+
return super.completionForKeyword(context, keyword, customAcceptor);
|
|
7906
|
+
}
|
|
7907
|
+
filterKeywordForContext(context, keyword) {
|
|
7908
|
+
if (isInvocationExpr(context.node)) {
|
|
7909
|
+
return [
|
|
7910
|
+
"true",
|
|
7911
|
+
"false",
|
|
7912
|
+
"null",
|
|
7913
|
+
"this"
|
|
7914
|
+
].includes(keyword);
|
|
7915
|
+
} else if (isDataModelAttribute(context.node) || isDataFieldAttribute(context.node)) {
|
|
7916
|
+
const exprContext = this.getAttributeContextType(context.node);
|
|
7917
|
+
if (exprContext === "DefaultValue") {
|
|
7918
|
+
return [
|
|
7919
|
+
"true",
|
|
7920
|
+
"false",
|
|
7921
|
+
"null"
|
|
7922
|
+
].includes(keyword);
|
|
7923
|
+
} else {
|
|
7924
|
+
return [
|
|
7925
|
+
"true",
|
|
7926
|
+
"false",
|
|
7927
|
+
"null",
|
|
7928
|
+
"this"
|
|
7929
|
+
].includes(keyword);
|
|
7930
|
+
}
|
|
7931
|
+
} else {
|
|
7932
|
+
return true;
|
|
7933
|
+
}
|
|
7934
|
+
}
|
|
7935
|
+
filterAttributeApplicationCompletion(contextNode, node) {
|
|
7936
|
+
const attrContextType = this.getAttributeContextType(contextNode);
|
|
7937
|
+
if (isFunctionDecl(node) && attrContextType) {
|
|
7938
|
+
const funcExprContextAttr = getAttribute(node, "@@@expressionContext");
|
|
7939
|
+
if (funcExprContextAttr && funcExprContextAttr.args[0]) {
|
|
7940
|
+
const arg = funcExprContextAttr.args[0];
|
|
7941
|
+
if (isArrayExpr(arg.value)) {
|
|
7942
|
+
return arg.value.items.some((item) => isEnumFieldReference(item) && item.target.$refText === attrContextType);
|
|
7943
|
+
}
|
|
7944
|
+
}
|
|
7945
|
+
return false;
|
|
7946
|
+
}
|
|
7947
|
+
if (isDataField(node)) {
|
|
7948
|
+
return attrContextType !== "DefaultValue";
|
|
7949
|
+
}
|
|
7950
|
+
return true;
|
|
7951
|
+
}
|
|
7952
|
+
getAttributeContextType(node) {
|
|
7953
|
+
return (0, import_ts_pattern3.match)(node.decl.$refText).with("@default", () => "DefaultValue").with(import_ts_pattern3.P.union("@@allow", "@allow", "@@deny", "@deny"), () => "AccessPolicy").with("@@validate", () => "ValidationRule").otherwise(() => void 0);
|
|
7954
|
+
}
|
|
7955
|
+
createReferenceCompletionItem(nodeDescription) {
|
|
7956
|
+
const node = this.getAstNode(nodeDescription);
|
|
7957
|
+
const documentation = this.getNodeDocumentation(node);
|
|
7958
|
+
return (0, import_ts_pattern3.match)(node).when(isDataModel, () => ({
|
|
7959
|
+
nodeDescription,
|
|
7960
|
+
kind: import_vscode_languageserver.CompletionItemKind.Class,
|
|
7961
|
+
detail: "Model",
|
|
7962
|
+
sortText: "1",
|
|
7963
|
+
documentation
|
|
7964
|
+
})).when(isTypeDef, () => ({
|
|
7965
|
+
nodeDescription,
|
|
7966
|
+
kind: import_vscode_languageserver.CompletionItemKind.Class,
|
|
7967
|
+
detail: "Type",
|
|
7968
|
+
sortText: "1",
|
|
7969
|
+
documentation
|
|
7970
|
+
})).when(isDataField, () => ({
|
|
7971
|
+
nodeDescription,
|
|
7972
|
+
kind: import_vscode_languageserver.CompletionItemKind.Field,
|
|
7973
|
+
detail: "Field",
|
|
7974
|
+
sortText: "0",
|
|
7975
|
+
documentation
|
|
7976
|
+
})).when(isEnum, () => ({
|
|
7977
|
+
nodeDescription,
|
|
7978
|
+
kind: import_vscode_languageserver.CompletionItemKind.Class,
|
|
7979
|
+
detail: "Enum",
|
|
7980
|
+
sortText: "1",
|
|
7981
|
+
documentation
|
|
7982
|
+
})).when(isEnumField, (d) => {
|
|
7983
|
+
const container = d.$container;
|
|
7984
|
+
return {
|
|
7985
|
+
nodeDescription,
|
|
7986
|
+
kind: import_vscode_languageserver.CompletionItemKind.Enum,
|
|
7987
|
+
detail: `Value of enum "${container.name}"`,
|
|
7988
|
+
sortText: "1",
|
|
7989
|
+
documentation
|
|
7990
|
+
};
|
|
7991
|
+
}).when(isFunctionDecl, () => ({
|
|
7992
|
+
nodeDescription,
|
|
7993
|
+
insertText: this.getFunctionInsertText(nodeDescription),
|
|
7994
|
+
kind: import_vscode_languageserver.CompletionItemKind.Function,
|
|
7995
|
+
detail: "Function",
|
|
7996
|
+
sortText: "1",
|
|
7997
|
+
documentation
|
|
7998
|
+
})).when(isAttribute, () => ({
|
|
7999
|
+
nodeDescription,
|
|
8000
|
+
insertText: this.getAttributeInsertText(nodeDescription),
|
|
8001
|
+
kind: import_vscode_languageserver.CompletionItemKind.Property,
|
|
8002
|
+
detail: "Attribute",
|
|
8003
|
+
sortText: "1",
|
|
8004
|
+
documentation
|
|
8005
|
+
})).otherwise(() => ({
|
|
8006
|
+
nodeDescription,
|
|
8007
|
+
kind: import_vscode_languageserver.CompletionItemKind.Reference,
|
|
8008
|
+
detail: nodeDescription.type,
|
|
8009
|
+
sortText: "2",
|
|
8010
|
+
documentation
|
|
8011
|
+
}));
|
|
8012
|
+
}
|
|
8013
|
+
getFunctionInsertText(nodeDescription) {
|
|
8014
|
+
const node = this.getAstNode(nodeDescription);
|
|
8015
|
+
if (isFunctionDecl(node)) {
|
|
8016
|
+
if (node.params.some((p) => !p.optional)) {
|
|
8017
|
+
return nodeDescription.name;
|
|
8018
|
+
}
|
|
8019
|
+
}
|
|
8020
|
+
return `${nodeDescription.name}()`;
|
|
8021
|
+
}
|
|
8022
|
+
getAttributeInsertText(nodeDescription) {
|
|
8023
|
+
const node = this.getAstNode(nodeDescription);
|
|
8024
|
+
if (isAttribute(node)) {
|
|
8025
|
+
if (node.name === "@relation") {
|
|
8026
|
+
return `${nodeDescription.name}(fields: [], references: [])`;
|
|
8027
|
+
}
|
|
8028
|
+
}
|
|
8029
|
+
return nodeDescription.name;
|
|
8030
|
+
}
|
|
8031
|
+
getAstNode(nodeDescription) {
|
|
8032
|
+
let node = nodeDescription.node;
|
|
8033
|
+
if (!node) {
|
|
8034
|
+
const doc = this.getOrCreateDocumentSync(nodeDescription);
|
|
8035
|
+
if (!doc) {
|
|
8036
|
+
return void 0;
|
|
8037
|
+
}
|
|
8038
|
+
node = this.services.workspace.AstNodeLocator.getAstNode(doc.parseResult.value, nodeDescription.path);
|
|
8039
|
+
if (!node) {
|
|
8040
|
+
return void 0;
|
|
8041
|
+
}
|
|
8042
|
+
}
|
|
8043
|
+
return node;
|
|
8044
|
+
}
|
|
8045
|
+
getOrCreateDocumentSync(nodeDescription) {
|
|
8046
|
+
let doc = this.services.shared.workspace.LangiumDocuments.getDocument(nodeDescription.documentUri);
|
|
8047
|
+
if (!doc) {
|
|
8048
|
+
try {
|
|
8049
|
+
const content = import_node_fs2.default.readFileSync(nodeDescription.documentUri.fsPath, "utf-8");
|
|
8050
|
+
doc = this.services.shared.workspace.LangiumDocuments.createDocument(nodeDescription.documentUri, content);
|
|
8051
|
+
} catch {
|
|
8052
|
+
console.warn("Failed to read or create document:", nodeDescription.documentUri);
|
|
8053
|
+
return void 0;
|
|
8054
|
+
}
|
|
8055
|
+
}
|
|
8056
|
+
return doc;
|
|
8057
|
+
}
|
|
8058
|
+
getNodeDocumentation(node) {
|
|
8059
|
+
if (!node) {
|
|
8060
|
+
return void 0;
|
|
8061
|
+
}
|
|
8062
|
+
const md = this.commentsToMarkdown(node);
|
|
8063
|
+
return {
|
|
8064
|
+
kind: "markdown",
|
|
8065
|
+
value: md
|
|
8066
|
+
};
|
|
8067
|
+
}
|
|
8068
|
+
commentsToMarkdown(node) {
|
|
8069
|
+
const md = this.services.documentation.DocumentationProvider.getDocumentation(node) ?? "";
|
|
8070
|
+
const zModelGenerator = new ZModelCodeGenerator();
|
|
8071
|
+
const docs = [];
|
|
8072
|
+
try {
|
|
8073
|
+
(0, import_ts_pattern3.match)(node).when(isAttribute, (attr) => {
|
|
8074
|
+
docs.push("```prisma", zModelGenerator.generate(attr), "```");
|
|
8075
|
+
}).when(isFunctionDecl, (func2) => {
|
|
8076
|
+
docs.push("```ts", zModelGenerator.generate(func2), "```");
|
|
8077
|
+
}).when(isDataModel, (model) => {
|
|
8078
|
+
docs.push("```prisma", `model ${model.name} { ... }`, "```");
|
|
8079
|
+
}).when(isEnum, (enumDecl) => {
|
|
8080
|
+
docs.push("```prisma", zModelGenerator.generate(enumDecl), "```");
|
|
8081
|
+
}).when(isDataField, (field) => {
|
|
8082
|
+
docs.push(`${field.name}: ${field.type.type ?? field.type.reference?.$refText}`);
|
|
8083
|
+
}).otherwise((ast) => {
|
|
8084
|
+
const name = ast.name;
|
|
8085
|
+
if (name) {
|
|
8086
|
+
docs.push(name);
|
|
8087
|
+
}
|
|
8088
|
+
});
|
|
8089
|
+
} catch {
|
|
8090
|
+
}
|
|
8091
|
+
if (md) {
|
|
8092
|
+
docs.push("___", md);
|
|
8093
|
+
}
|
|
8094
|
+
return docs.join("\n");
|
|
8095
|
+
}
|
|
8096
|
+
};
|
|
8097
|
+
|
|
8098
|
+
// src/zmodel-definition.ts
|
|
8099
|
+
var import_lsp2 = require("langium/lsp");
|
|
8100
|
+
var import_vscode_languageserver2 = require("vscode-languageserver");
|
|
8101
|
+
var ZModelDefinitionProvider = class extends import_lsp2.DefaultDefinitionProvider {
|
|
8102
|
+
static {
|
|
8103
|
+
__name(this, "ZModelDefinitionProvider");
|
|
8104
|
+
}
|
|
8105
|
+
documents;
|
|
8106
|
+
constructor(services) {
|
|
8107
|
+
super(services);
|
|
8108
|
+
this.documents = services.shared.workspace.LangiumDocuments;
|
|
8109
|
+
}
|
|
8110
|
+
collectLocationLinks(sourceCstNode, _params) {
|
|
8111
|
+
if (isModelImport(sourceCstNode.astNode)) {
|
|
8112
|
+
const importedModel = resolveImport(this.documents, sourceCstNode.astNode);
|
|
8113
|
+
if (importedModel?.$document) {
|
|
8114
|
+
const targetObject = importedModel;
|
|
8115
|
+
const selectionRange = this.nameProvider.getNameNode(targetObject)?.range ?? import_vscode_languageserver2.Range.create(0, 0, 0, 0);
|
|
8116
|
+
const previewRange = targetObject.$cstNode?.range ?? import_vscode_languageserver2.Range.create(0, 0, 0, 0);
|
|
8117
|
+
return [
|
|
8118
|
+
import_vscode_languageserver2.LocationLink.create(importedModel.$document.uri.toString(), previewRange, selectionRange, sourceCstNode.range)
|
|
8119
|
+
];
|
|
8120
|
+
}
|
|
8121
|
+
return void 0;
|
|
8122
|
+
}
|
|
8123
|
+
return super.collectLocationLinks(sourceCstNode, _params);
|
|
8124
|
+
}
|
|
8125
|
+
};
|
|
8126
|
+
|
|
8127
|
+
// src/zmodel-document-builder.ts
|
|
8128
|
+
var import_langium8 = require("langium");
|
|
8129
|
+
var ZModelDocumentBuilder = class extends import_langium8.DefaultDocumentBuilder {
|
|
7210
8130
|
static {
|
|
7211
8131
|
__name(this, "ZModelDocumentBuilder");
|
|
7212
8132
|
}
|
|
@@ -7233,10 +8153,115 @@ var ZModelDocumentBuilder = class extends import_langium7.DefaultDocumentBuilder
|
|
|
7233
8153
|
}
|
|
7234
8154
|
};
|
|
7235
8155
|
|
|
8156
|
+
// src/zmodel-documentation-provider.ts
|
|
8157
|
+
var import_langium9 = require("langium");
|
|
8158
|
+
var ZModelDocumentationProvider = class extends import_langium9.JSDocDocumentationProvider {
|
|
8159
|
+
static {
|
|
8160
|
+
__name(this, "ZModelDocumentationProvider");
|
|
8161
|
+
}
|
|
8162
|
+
getDocumentation(node) {
|
|
8163
|
+
if ("comments" in node && Array.isArray(node.comments) && node.comments.length > 0) {
|
|
8164
|
+
return node.comments.map((c) => c.replace(/^[/]*\s*/, "")).join("\n");
|
|
8165
|
+
}
|
|
8166
|
+
return super.getDocumentation(node);
|
|
8167
|
+
}
|
|
8168
|
+
};
|
|
8169
|
+
|
|
8170
|
+
// src/zmodel-formatter.ts
|
|
8171
|
+
var import_lsp3 = require("langium/lsp");
|
|
8172
|
+
var ZModelFormatter = class extends import_lsp3.AbstractFormatter {
|
|
8173
|
+
static {
|
|
8174
|
+
__name(this, "ZModelFormatter");
|
|
8175
|
+
}
|
|
8176
|
+
formatOptions;
|
|
8177
|
+
configurationProvider;
|
|
8178
|
+
constructor(services) {
|
|
8179
|
+
super();
|
|
8180
|
+
this.configurationProvider = services.shared.workspace.ConfigurationProvider;
|
|
8181
|
+
}
|
|
8182
|
+
format(node) {
|
|
8183
|
+
const formatter = this.getNodeFormatter(node);
|
|
8184
|
+
if (isDataField(node)) {
|
|
8185
|
+
if (isDataModel(node.$container) || isTypeDef(node.$container)) {
|
|
8186
|
+
const dataModel = node.$container;
|
|
8187
|
+
const compareFn = /* @__PURE__ */ __name((a, b) => b - a, "compareFn");
|
|
8188
|
+
const maxNameLength = dataModel.fields.map((x) => x.name.length).sort(compareFn)[0] ?? 0;
|
|
8189
|
+
const maxTypeLength = dataModel.fields.map(this.getFieldTypeLength).sort(compareFn)[0] ?? 0;
|
|
8190
|
+
formatter.property("type").prepend(import_lsp3.Formatting.spaces(maxNameLength - node.name.length + 1));
|
|
8191
|
+
if (node.attributes.length > 0) {
|
|
8192
|
+
formatter.node(node.attributes[0]).prepend(import_lsp3.Formatting.spaces(maxTypeLength - this.getFieldTypeLength(node) + 1));
|
|
8193
|
+
formatter.nodes(...node.attributes.slice(1)).prepend(import_lsp3.Formatting.oneSpace());
|
|
8194
|
+
}
|
|
8195
|
+
} else {
|
|
8196
|
+
formatter.property("type").prepend(import_lsp3.Formatting.oneSpace());
|
|
8197
|
+
if (node.attributes.length > 0) {
|
|
8198
|
+
formatter.properties("attributes").prepend(import_lsp3.Formatting.oneSpace());
|
|
8199
|
+
}
|
|
8200
|
+
}
|
|
8201
|
+
} else if (isDataFieldAttribute(node)) {
|
|
8202
|
+
formatter.keyword("(").surround(import_lsp3.Formatting.noSpace());
|
|
8203
|
+
formatter.keyword(")").prepend(import_lsp3.Formatting.noSpace());
|
|
8204
|
+
formatter.keyword(",").append(import_lsp3.Formatting.oneSpace());
|
|
8205
|
+
if (node.args.length > 1) {
|
|
8206
|
+
formatter.nodes(...node.args.slice(1)).prepend(import_lsp3.Formatting.oneSpace());
|
|
8207
|
+
}
|
|
8208
|
+
} else if (isAttributeArg(node)) {
|
|
8209
|
+
formatter.keyword(":").prepend(import_lsp3.Formatting.noSpace());
|
|
8210
|
+
formatter.keyword(":").append(import_lsp3.Formatting.oneSpace());
|
|
8211
|
+
} else if (isAbstractDeclaration(node)) {
|
|
8212
|
+
const bracesOpen = formatter.keyword("{");
|
|
8213
|
+
const bracesClose = formatter.keyword("}");
|
|
8214
|
+
formatter.interior(bracesOpen, bracesClose).prepend(import_lsp3.Formatting.indent({
|
|
8215
|
+
allowMore: true
|
|
8216
|
+
}));
|
|
8217
|
+
bracesOpen.prepend(import_lsp3.Formatting.oneSpace());
|
|
8218
|
+
bracesClose.prepend(import_lsp3.Formatting.newLine());
|
|
8219
|
+
} else if (isModel(node)) {
|
|
8220
|
+
const model = node;
|
|
8221
|
+
const nodes = formatter.nodes(...model.declarations);
|
|
8222
|
+
nodes.prepend(import_lsp3.Formatting.noIndent());
|
|
8223
|
+
}
|
|
8224
|
+
}
|
|
8225
|
+
formatDocument(document, params) {
|
|
8226
|
+
this.formatOptions = params.options;
|
|
8227
|
+
this.configurationProvider.getConfiguration(ZModelLanguageMetaData.languageId, "format").then((config) => {
|
|
8228
|
+
if (config) {
|
|
8229
|
+
}
|
|
8230
|
+
});
|
|
8231
|
+
return super.formatDocument(document, params);
|
|
8232
|
+
}
|
|
8233
|
+
getFormatOptions() {
|
|
8234
|
+
return this.formatOptions;
|
|
8235
|
+
}
|
|
8236
|
+
getIndent() {
|
|
8237
|
+
return 1;
|
|
8238
|
+
}
|
|
8239
|
+
getFieldTypeLength(field) {
|
|
8240
|
+
let length;
|
|
8241
|
+
if (field.type.type) {
|
|
8242
|
+
length = field.type.type.length;
|
|
8243
|
+
} else if (field.type.reference) {
|
|
8244
|
+
length = field.type.reference.$refText.length;
|
|
8245
|
+
} else if (isDataField(field) && field.type.unsupported) {
|
|
8246
|
+
const name = `Unsupported("${field.type.unsupported.value.value}")`;
|
|
8247
|
+
length = name.length;
|
|
8248
|
+
} else {
|
|
8249
|
+
length = 1;
|
|
8250
|
+
}
|
|
8251
|
+
if (field.type.optional) {
|
|
8252
|
+
length += 1;
|
|
8253
|
+
}
|
|
8254
|
+
if (field.type.array) {
|
|
8255
|
+
length += 2;
|
|
8256
|
+
}
|
|
8257
|
+
return length;
|
|
8258
|
+
}
|
|
8259
|
+
};
|
|
8260
|
+
|
|
7236
8261
|
// src/zmodel-linker.ts
|
|
7237
|
-
var
|
|
7238
|
-
var
|
|
7239
|
-
var ZModelLinker = class extends
|
|
8262
|
+
var import_langium10 = require("langium");
|
|
8263
|
+
var import_ts_pattern4 = require("ts-pattern");
|
|
8264
|
+
var ZModelLinker = class extends import_langium10.DefaultLinker {
|
|
7240
8265
|
static {
|
|
7241
8266
|
__name(this, "ZModelLinker");
|
|
7242
8267
|
}
|
|
@@ -7246,15 +8271,15 @@ var ZModelLinker = class extends import_langium8.DefaultLinker {
|
|
|
7246
8271
|
this.descriptions = services.workspace.AstNodeDescriptionProvider;
|
|
7247
8272
|
}
|
|
7248
8273
|
//#region Reference linking
|
|
7249
|
-
async link(document, cancelToken =
|
|
8274
|
+
async link(document, cancelToken = import_langium10.Cancellation.CancellationToken.None) {
|
|
7250
8275
|
if (document.parseResult.lexerErrors?.length > 0 || document.parseResult.parserErrors?.length > 0) {
|
|
7251
8276
|
return;
|
|
7252
8277
|
}
|
|
7253
|
-
for (const node of
|
|
7254
|
-
await (0,
|
|
8278
|
+
for (const node of import_langium10.AstUtils.streamContents(document.parseResult.value)) {
|
|
8279
|
+
await (0, import_langium10.interruptAndCheck)(cancelToken);
|
|
7255
8280
|
this.resolve(node, document);
|
|
7256
8281
|
}
|
|
7257
|
-
document.state =
|
|
8282
|
+
document.state = import_langium10.DocumentState.Linked;
|
|
7258
8283
|
}
|
|
7259
8284
|
linkReference(refInfo, document, extraScopes) {
|
|
7260
8285
|
const defaultRef = refInfo.reference;
|
|
@@ -7406,7 +8431,7 @@ var ZModelLinker = class extends import_langium8.DefaultLinker {
|
|
|
7406
8431
|
if (node.function.ref) {
|
|
7407
8432
|
const funcDecl = node.function.ref;
|
|
7408
8433
|
if (isAuthInvocation(node)) {
|
|
7409
|
-
const allDecls = getAllLoadedAndReachableDataModelsAndTypeDefs(this.langiumDocuments(),
|
|
8434
|
+
const allDecls = getAllLoadedAndReachableDataModelsAndTypeDefs(this.langiumDocuments(), import_langium10.AstUtils.getContainerOfType(node, isDataModel));
|
|
7410
8435
|
const authDecl = getAuthDecl(allDecls);
|
|
7411
8436
|
if (authDecl) {
|
|
7412
8437
|
node.$resolvedType = {
|
|
@@ -7424,7 +8449,7 @@ var ZModelLinker = class extends import_langium8.DefaultLinker {
|
|
|
7424
8449
|
}
|
|
7425
8450
|
}
|
|
7426
8451
|
resolveLiteral(node) {
|
|
7427
|
-
const type = (0,
|
|
8452
|
+
const type = (0, import_ts_pattern4.match)(node).when(isStringLiteral, () => "String").when(isBooleanLiteral, () => "Boolean").when(isNumberLiteral, () => "Int").exhaustive();
|
|
7428
8453
|
if (type) {
|
|
7429
8454
|
this.resolveToBuiltinTypeOrDecl(node, type);
|
|
7430
8455
|
}
|
|
@@ -7544,10 +8569,10 @@ var ZModelLinker = class extends import_langium8.DefaultLinker {
|
|
|
7544
8569
|
this.resolveDefault(node, document, scopes);
|
|
7545
8570
|
}
|
|
7546
8571
|
resolveDefault(node, document, extraScopes) {
|
|
7547
|
-
|
|
8572
|
+
import_langium10.AstUtils.streamReferences(node).forEach((ref) => {
|
|
7548
8573
|
this.linkReference(ref, document, extraScopes);
|
|
7549
8574
|
});
|
|
7550
|
-
for (const child of
|
|
8575
|
+
for (const child of import_langium10.AstUtils.streamContents(node)) {
|
|
7551
8576
|
this.resolve(child, document, extraScopes);
|
|
7552
8577
|
}
|
|
7553
8578
|
}
|
|
@@ -7591,9 +8616,9 @@ var ZModelLinker = class extends import_langium8.DefaultLinker {
|
|
|
7591
8616
|
};
|
|
7592
8617
|
|
|
7593
8618
|
// src/zmodel-scope.ts
|
|
7594
|
-
var
|
|
7595
|
-
var
|
|
7596
|
-
var ZModelScopeComputation = class extends
|
|
8619
|
+
var import_langium11 = require("langium");
|
|
8620
|
+
var import_ts_pattern5 = require("ts-pattern");
|
|
8621
|
+
var ZModelScopeComputation = class extends import_langium11.DefaultScopeComputation {
|
|
7597
8622
|
static {
|
|
7598
8623
|
__name(this, "ZModelScopeComputation");
|
|
7599
8624
|
}
|
|
@@ -7603,9 +8628,9 @@ var ZModelScopeComputation = class extends import_langium9.DefaultScopeComputati
|
|
|
7603
8628
|
}
|
|
7604
8629
|
async computeExports(document, cancelToken) {
|
|
7605
8630
|
const result = await super.computeExports(document, cancelToken);
|
|
7606
|
-
for (const node of
|
|
8631
|
+
for (const node of import_langium11.AstUtils.streamAllContents(document.parseResult.value)) {
|
|
7607
8632
|
if (cancelToken) {
|
|
7608
|
-
await (0,
|
|
8633
|
+
await (0, import_langium11.interruptAndCheck)(cancelToken);
|
|
7609
8634
|
}
|
|
7610
8635
|
if (isEnumField(node)) {
|
|
7611
8636
|
const desc = this.services.workspace.AstNodeDescriptionProvider.createDescription(node, node.name, document);
|
|
@@ -7626,7 +8651,7 @@ var ZModelScopeComputation = class extends import_langium9.DefaultScopeComputati
|
|
|
7626
8651
|
}
|
|
7627
8652
|
}
|
|
7628
8653
|
};
|
|
7629
|
-
var ZModelScopeProvider = class extends
|
|
8654
|
+
var ZModelScopeProvider = class extends import_langium11.DefaultScopeProvider {
|
|
7630
8655
|
static {
|
|
7631
8656
|
__name(this, "ZModelScopeProvider");
|
|
7632
8657
|
}
|
|
@@ -7635,19 +8660,19 @@ var ZModelScopeProvider = class extends import_langium9.DefaultScopeProvider {
|
|
|
7635
8660
|
super(services), this.services = services;
|
|
7636
8661
|
}
|
|
7637
8662
|
getGlobalScope(referenceType, context) {
|
|
7638
|
-
const model =
|
|
8663
|
+
const model = import_langium11.AstUtils.getContainerOfType(context.container, isModel);
|
|
7639
8664
|
if (!model) {
|
|
7640
|
-
return
|
|
8665
|
+
return import_langium11.EMPTY_SCOPE;
|
|
7641
8666
|
}
|
|
7642
8667
|
const importedUris = model.imports.map(resolveImportUri).filter((url) => !!url);
|
|
7643
8668
|
const importedElements = this.indexManager.allElements(referenceType).filter((des) => (
|
|
7644
8669
|
// allow current document
|
|
7645
|
-
|
|
8670
|
+
import_langium11.UriUtils.equals(des.documentUri, model.$document?.uri) || // allow stdlib
|
|
7646
8671
|
des.documentUri.path.endsWith(STD_LIB_MODULE_NAME) || // allow plugin models
|
|
7647
8672
|
des.documentUri.path.endsWith(PLUGIN_MODULE_NAME) || // allow imported documents
|
|
7648
|
-
importedUris.some((importedUri) =>
|
|
8673
|
+
importedUris.some((importedUri) => import_langium11.UriUtils.equals(des.documentUri, importedUri))
|
|
7649
8674
|
));
|
|
7650
|
-
return new
|
|
8675
|
+
return new import_langium11.StreamScope(importedElements);
|
|
7651
8676
|
}
|
|
7652
8677
|
getScope(context) {
|
|
7653
8678
|
if (isMemberAccessExpr(context.container) && context.container.operand && context.property === "member") {
|
|
@@ -7667,20 +8692,20 @@ var ZModelScopeProvider = class extends import_langium9.DefaultScopeProvider {
|
|
|
7667
8692
|
const node = context.container;
|
|
7668
8693
|
const allowTypeDefScope = (
|
|
7669
8694
|
// isAuthOrAuthMemberAccess(node.operand) ||
|
|
7670
|
-
!!
|
|
8695
|
+
!!import_langium11.AstUtils.getContainerOfType(node, isTypeDef)
|
|
7671
8696
|
);
|
|
7672
|
-
return (0,
|
|
8697
|
+
return (0, import_ts_pattern5.match)(node.operand).when(isReferenceExpr, (operand) => {
|
|
7673
8698
|
const ref = operand.target.ref;
|
|
7674
8699
|
if (isDataField(ref)) {
|
|
7675
8700
|
return this.createScopeForContainer(ref.type.reference?.ref, globalScope, allowTypeDefScope);
|
|
7676
8701
|
}
|
|
7677
|
-
return
|
|
8702
|
+
return import_langium11.EMPTY_SCOPE;
|
|
7678
8703
|
}).when(isMemberAccessExpr, (operand) => {
|
|
7679
8704
|
const ref = operand.member.ref;
|
|
7680
8705
|
if (isDataField(ref) && !ref.type.array) {
|
|
7681
8706
|
return this.createScopeForContainer(ref.type.reference?.ref, globalScope, allowTypeDefScope);
|
|
7682
8707
|
}
|
|
7683
|
-
return
|
|
8708
|
+
return import_langium11.EMPTY_SCOPE;
|
|
7684
8709
|
}).when(isThisExpr, () => {
|
|
7685
8710
|
return this.createScopeForContainingModel(node, globalScope);
|
|
7686
8711
|
}).when(isInvocationExpr, (operand) => {
|
|
@@ -7690,43 +8715,43 @@ var ZModelScopeProvider = class extends import_langium9.DefaultScopeProvider {
|
|
|
7690
8715
|
if (isBeforeInvocation(operand)) {
|
|
7691
8716
|
return this.createScopeForContainingModel(node, globalScope);
|
|
7692
8717
|
}
|
|
7693
|
-
return
|
|
7694
|
-
}).otherwise(() =>
|
|
8718
|
+
return import_langium11.EMPTY_SCOPE;
|
|
8719
|
+
}).otherwise(() => import_langium11.EMPTY_SCOPE);
|
|
7695
8720
|
}
|
|
7696
8721
|
getCollectionPredicateScope(context, collectionPredicate) {
|
|
7697
8722
|
const referenceType = this.reflection.getReferenceType(context);
|
|
7698
8723
|
const globalScope = this.getGlobalScope(referenceType, context);
|
|
7699
8724
|
const collection = collectionPredicate.left;
|
|
7700
8725
|
const allowTypeDefScope = false;
|
|
7701
|
-
return (0,
|
|
8726
|
+
return (0, import_ts_pattern5.match)(collection).when(isReferenceExpr, (expr) => {
|
|
7702
8727
|
const ref = expr.target.ref;
|
|
7703
8728
|
if (isDataField(ref)) {
|
|
7704
8729
|
return this.createScopeForContainer(ref.type.reference?.ref, globalScope, allowTypeDefScope);
|
|
7705
8730
|
}
|
|
7706
|
-
return
|
|
8731
|
+
return import_langium11.EMPTY_SCOPE;
|
|
7707
8732
|
}).when(isMemberAccessExpr, (expr) => {
|
|
7708
8733
|
const ref = expr.member.ref;
|
|
7709
8734
|
if (isDataField(ref)) {
|
|
7710
8735
|
return this.createScopeForContainer(ref.type.reference?.ref, globalScope, allowTypeDefScope);
|
|
7711
8736
|
}
|
|
7712
|
-
return
|
|
8737
|
+
return import_langium11.EMPTY_SCOPE;
|
|
7713
8738
|
}).when(isInvocationExpr, (expr) => {
|
|
7714
8739
|
const returnTypeDecl = expr.function.ref?.returnType.reference?.ref;
|
|
7715
8740
|
if (isDataModel(returnTypeDecl)) {
|
|
7716
8741
|
return this.createScopeForContainer(returnTypeDecl, globalScope, allowTypeDefScope);
|
|
7717
8742
|
} else {
|
|
7718
|
-
return
|
|
8743
|
+
return import_langium11.EMPTY_SCOPE;
|
|
7719
8744
|
}
|
|
7720
8745
|
}).when(isAuthInvocation, (expr) => {
|
|
7721
8746
|
return this.createScopeForAuth(expr, globalScope);
|
|
7722
|
-
}).otherwise(() =>
|
|
8747
|
+
}).otherwise(() => import_langium11.EMPTY_SCOPE);
|
|
7723
8748
|
}
|
|
7724
8749
|
createScopeForContainingModel(node, globalScope) {
|
|
7725
|
-
const model =
|
|
8750
|
+
const model = import_langium11.AstUtils.getContainerOfType(node, isDataModel);
|
|
7726
8751
|
if (model) {
|
|
7727
8752
|
return this.createScopeForContainer(model, globalScope);
|
|
7728
8753
|
} else {
|
|
7729
|
-
return
|
|
8754
|
+
return import_langium11.EMPTY_SCOPE;
|
|
7730
8755
|
}
|
|
7731
8756
|
}
|
|
7732
8757
|
createScopeForContainer(node, globalScope, includeTypeDefScope = false) {
|
|
@@ -7735,16 +8760,16 @@ var ZModelScopeProvider = class extends import_langium9.DefaultScopeProvider {
|
|
|
7735
8760
|
} else if (includeTypeDefScope && isTypeDef(node)) {
|
|
7736
8761
|
return this.createScopeForNodes(node.fields, globalScope);
|
|
7737
8762
|
} else {
|
|
7738
|
-
return
|
|
8763
|
+
return import_langium11.EMPTY_SCOPE;
|
|
7739
8764
|
}
|
|
7740
8765
|
}
|
|
7741
8766
|
createScopeForAuth(node, globalScope) {
|
|
7742
|
-
const decls = getAllLoadedAndReachableDataModelsAndTypeDefs(this.services.shared.workspace.LangiumDocuments,
|
|
8767
|
+
const decls = getAllLoadedAndReachableDataModelsAndTypeDefs(this.services.shared.workspace.LangiumDocuments, import_langium11.AstUtils.getContainerOfType(node, isDataModel));
|
|
7743
8768
|
const authDecl = getAuthDecl(decls);
|
|
7744
8769
|
if (authDecl) {
|
|
7745
8770
|
return this.createScopeForContainer(authDecl, globalScope, true);
|
|
7746
8771
|
} else {
|
|
7747
|
-
return
|
|
8772
|
+
return import_langium11.EMPTY_SCOPE;
|
|
7748
8773
|
}
|
|
7749
8774
|
}
|
|
7750
8775
|
};
|
|
@@ -7760,13 +8785,97 @@ function getCollectionPredicateContext(node) {
|
|
|
7760
8785
|
}
|
|
7761
8786
|
__name(getCollectionPredicateContext, "getCollectionPredicateContext");
|
|
7762
8787
|
|
|
8788
|
+
// src/zmodel-semantic.ts
|
|
8789
|
+
var import_lsp4 = require("langium/lsp");
|
|
8790
|
+
var import_vscode_languageserver3 = require("vscode-languageserver");
|
|
8791
|
+
var ZModelSemanticTokenProvider = class extends import_lsp4.AbstractSemanticTokenProvider {
|
|
8792
|
+
static {
|
|
8793
|
+
__name(this, "ZModelSemanticTokenProvider");
|
|
8794
|
+
}
|
|
8795
|
+
highlightElement(node, acceptor) {
|
|
8796
|
+
if (isDataModel(node)) {
|
|
8797
|
+
acceptor({
|
|
8798
|
+
node,
|
|
8799
|
+
property: "name",
|
|
8800
|
+
type: import_vscode_languageserver3.SemanticTokenTypes.type
|
|
8801
|
+
});
|
|
8802
|
+
acceptor({
|
|
8803
|
+
node,
|
|
8804
|
+
property: "mixins",
|
|
8805
|
+
type: import_vscode_languageserver3.SemanticTokenTypes.type
|
|
8806
|
+
});
|
|
8807
|
+
acceptor({
|
|
8808
|
+
node,
|
|
8809
|
+
property: "baseModel",
|
|
8810
|
+
type: import_vscode_languageserver3.SemanticTokenTypes.type
|
|
8811
|
+
});
|
|
8812
|
+
} else if (isDataSource(node) || isGeneratorDecl(node) || isPlugin(node) || isEnum(node) || isTypeDef(node)) {
|
|
8813
|
+
acceptor({
|
|
8814
|
+
node,
|
|
8815
|
+
property: "name",
|
|
8816
|
+
type: import_vscode_languageserver3.SemanticTokenTypes.type
|
|
8817
|
+
});
|
|
8818
|
+
} else if (isDataField(node) || isConfigField(node) || isAttributeArg(node) || isPluginField(node) || isEnumField(node)) {
|
|
8819
|
+
acceptor({
|
|
8820
|
+
node,
|
|
8821
|
+
property: "name",
|
|
8822
|
+
type: import_vscode_languageserver3.SemanticTokenTypes.variable
|
|
8823
|
+
});
|
|
8824
|
+
} else if (isDataFieldType(node)) {
|
|
8825
|
+
if (node.type) {
|
|
8826
|
+
acceptor({
|
|
8827
|
+
node,
|
|
8828
|
+
property: "type",
|
|
8829
|
+
type: import_vscode_languageserver3.SemanticTokenTypes.type
|
|
8830
|
+
});
|
|
8831
|
+
} else {
|
|
8832
|
+
acceptor({
|
|
8833
|
+
node,
|
|
8834
|
+
property: "reference",
|
|
8835
|
+
type: import_vscode_languageserver3.SemanticTokenTypes.macro
|
|
8836
|
+
});
|
|
8837
|
+
}
|
|
8838
|
+
} else if (isDataModelAttribute(node) || isDataFieldAttribute(node) || isInternalAttribute(node)) {
|
|
8839
|
+
acceptor({
|
|
8840
|
+
node,
|
|
8841
|
+
property: "decl",
|
|
8842
|
+
type: import_vscode_languageserver3.SemanticTokenTypes.function
|
|
8843
|
+
});
|
|
8844
|
+
} else if (isInvocationExpr(node)) {
|
|
8845
|
+
acceptor({
|
|
8846
|
+
node,
|
|
8847
|
+
property: "function",
|
|
8848
|
+
type: import_vscode_languageserver3.SemanticTokenTypes.function
|
|
8849
|
+
});
|
|
8850
|
+
} else if (isFunctionDecl(node) || isAttribute(node)) {
|
|
8851
|
+
acceptor({
|
|
8852
|
+
node,
|
|
8853
|
+
property: "name",
|
|
8854
|
+
type: import_vscode_languageserver3.SemanticTokenTypes.function
|
|
8855
|
+
});
|
|
8856
|
+
} else if (isReferenceExpr(node)) {
|
|
8857
|
+
acceptor({
|
|
8858
|
+
node,
|
|
8859
|
+
property: "target",
|
|
8860
|
+
type: import_vscode_languageserver3.SemanticTokenTypes.variable
|
|
8861
|
+
});
|
|
8862
|
+
} else if (isMemberAccessExpr(node)) {
|
|
8863
|
+
acceptor({
|
|
8864
|
+
node,
|
|
8865
|
+
property: "member",
|
|
8866
|
+
type: import_vscode_languageserver3.SemanticTokenTypes.property
|
|
8867
|
+
});
|
|
8868
|
+
}
|
|
8869
|
+
}
|
|
8870
|
+
};
|
|
8871
|
+
|
|
7763
8872
|
// src/zmodel-workspace-manager.ts
|
|
7764
|
-
var
|
|
7765
|
-
var
|
|
8873
|
+
var import_langium12 = require("langium");
|
|
8874
|
+
var import_node_fs3 = __toESM(require("fs"), 1);
|
|
7766
8875
|
var import_node_path2 = __toESM(require("path"), 1);
|
|
7767
8876
|
var import_node_url2 = require("url");
|
|
7768
8877
|
var import_meta2 = {};
|
|
7769
|
-
var ZModelWorkspaceManager = class extends
|
|
8878
|
+
var ZModelWorkspaceManager = class extends import_langium12.DefaultWorkspaceManager {
|
|
7770
8879
|
static {
|
|
7771
8880
|
__name(this, "ZModelWorkspaceManager");
|
|
7772
8881
|
}
|
|
@@ -7789,7 +8898,7 @@ var ZModelWorkspaceManager = class extends import_langium10.DefaultWorkspaceMana
|
|
|
7789
8898
|
});
|
|
7790
8899
|
const languagePackageDir = import_node_path2.default.dirname(languagePackagePath);
|
|
7791
8900
|
const candidateStdlibPath = import_node_path2.default.join(languagePackageDir, "res", STD_LIB_MODULE_NAME);
|
|
7792
|
-
if (
|
|
8901
|
+
if (import_node_fs3.default.existsSync(candidateStdlibPath)) {
|
|
7793
8902
|
installedStdlibPath = candidateStdlibPath;
|
|
7794
8903
|
console.log(`Found installed zenstack package stdlib at: ${installedStdlibPath}`);
|
|
7795
8904
|
break;
|
|
@@ -7805,7 +8914,7 @@ var ZModelWorkspaceManager = class extends import_langium10.DefaultWorkspaceMana
|
|
|
7805
8914
|
stdLibPath = import_node_path2.default.join(_dirname, "../res", STD_LIB_MODULE_NAME);
|
|
7806
8915
|
console.log(`Using bundled stdlib in extension:`, stdLibPath);
|
|
7807
8916
|
}
|
|
7808
|
-
const stdlib = await this.documentFactory.fromUri(
|
|
8917
|
+
const stdlib = await this.documentFactory.fromUri(import_langium12.URI.file(stdLibPath));
|
|
7809
8918
|
collector(stdlib);
|
|
7810
8919
|
}
|
|
7811
8920
|
};
|
|
@@ -7819,6 +8928,16 @@ var ZModelLanguageModule = {
|
|
|
7819
8928
|
},
|
|
7820
8929
|
validation: {
|
|
7821
8930
|
ZModelValidator: /* @__PURE__ */ __name((services) => new ZModelValidator(services), "ZModelValidator")
|
|
8931
|
+
},
|
|
8932
|
+
lsp: {
|
|
8933
|
+
Formatter: /* @__PURE__ */ __name((services) => new ZModelFormatter(services), "Formatter"),
|
|
8934
|
+
DefinitionProvider: /* @__PURE__ */ __name((services) => new ZModelDefinitionProvider(services), "DefinitionProvider"),
|
|
8935
|
+
CompletionProvider: /* @__PURE__ */ __name((services) => new ZModelCompletionProvider(services), "CompletionProvider"),
|
|
8936
|
+
SemanticTokenProvider: /* @__PURE__ */ __name((services) => new ZModelSemanticTokenProvider(services), "SemanticTokenProvider")
|
|
8937
|
+
},
|
|
8938
|
+
documentation: {
|
|
8939
|
+
CommentProvider: /* @__PURE__ */ __name((services) => new ZModelCommentProvider(services), "CommentProvider"),
|
|
8940
|
+
DocumentationProvider: /* @__PURE__ */ __name((services) => new ZModelDocumentationProvider(services), "DocumentationProvider")
|
|
7822
8941
|
}
|
|
7823
8942
|
};
|
|
7824
8943
|
var ZModelSharedModule = {
|
|
@@ -7828,8 +8947,8 @@ var ZModelSharedModule = {
|
|
|
7828
8947
|
}
|
|
7829
8948
|
};
|
|
7830
8949
|
function createZModelLanguageServices(context, logToConsole = false) {
|
|
7831
|
-
const shared = (0,
|
|
7832
|
-
const ZModelLanguage = (0,
|
|
8950
|
+
const shared = (0, import_langium13.inject)((0, import_lsp5.createDefaultSharedModule)(context), ZModelGeneratedSharedModule, ZModelSharedModule);
|
|
8951
|
+
const ZModelLanguage = (0, import_langium13.inject)((0, import_lsp5.createDefaultModule)({
|
|
7833
8952
|
shared
|
|
7834
8953
|
}), ZModelGeneratedModule, ZModelLanguageModule);
|
|
7835
8954
|
shared.ServiceRegistry.register(ZModelLanguage);
|
|
@@ -7837,7 +8956,7 @@ function createZModelLanguageServices(context, logToConsole = false) {
|
|
|
7837
8956
|
if (!context.connection) {
|
|
7838
8957
|
shared.workspace.ConfigurationProvider.initialized({});
|
|
7839
8958
|
}
|
|
7840
|
-
shared.workspace.DocumentBuilder.onBuildPhase(
|
|
8959
|
+
shared.workspace.DocumentBuilder.onBuildPhase(import_langium13.DocumentState.Parsed, async (documents) => {
|
|
7841
8960
|
for (const doc of documents) {
|
|
7842
8961
|
if (doc.parseResult.lexerErrors.length > 0 || doc.parseResult.parserErrors.length > 0) {
|
|
7843
8962
|
continue;
|
|
@@ -7848,10 +8967,16 @@ function createZModelLanguageServices(context, logToConsole = false) {
|
|
|
7848
8967
|
const schemaPath = (0, import_node_url3.fileURLToPath)(doc.uri.toString());
|
|
7849
8968
|
const pluginSchemas = getPluginDocuments(doc.parseResult.value, schemaPath);
|
|
7850
8969
|
for (const plugin of pluginSchemas) {
|
|
7851
|
-
const
|
|
7852
|
-
shared.workspace.
|
|
7853
|
-
if (
|
|
7854
|
-
|
|
8970
|
+
const pluginDocUri = import_langium13.URI.file(import_node_path3.default.resolve(plugin));
|
|
8971
|
+
let pluginDoc = shared.workspace.LangiumDocuments.getDocument(pluginDocUri);
|
|
8972
|
+
if (!pluginDoc) {
|
|
8973
|
+
pluginDoc = await shared.workspace.LangiumDocuments.getOrCreateDocument(pluginDocUri);
|
|
8974
|
+
if (pluginDoc) {
|
|
8975
|
+
shared.workspace.IndexManager.updateContent(pluginDoc);
|
|
8976
|
+
if (logToConsole) {
|
|
8977
|
+
console.log(`Loaded plugin model: ${plugin}`);
|
|
8978
|
+
}
|
|
8979
|
+
}
|
|
7855
8980
|
}
|
|
7856
8981
|
}
|
|
7857
8982
|
}
|
|
@@ -7881,7 +9006,7 @@ async function loadDocument(fileName, additionalModelFiles = []) {
|
|
|
7881
9006
|
warnings: []
|
|
7882
9007
|
};
|
|
7883
9008
|
}
|
|
7884
|
-
if (!
|
|
9009
|
+
if (!import_node_fs4.default.existsSync(fileName)) {
|
|
7885
9010
|
return {
|
|
7886
9011
|
success: false,
|
|
7887
9012
|
errors: [
|
|
@@ -7891,15 +9016,15 @@ async function loadDocument(fileName, additionalModelFiles = []) {
|
|
|
7891
9016
|
};
|
|
7892
9017
|
}
|
|
7893
9018
|
const _dirname = typeof __dirname !== "undefined" ? __dirname : import_node_path4.default.dirname((0, import_node_url4.fileURLToPath)(import_meta3.url));
|
|
7894
|
-
const stdLib = await services.shared.workspace.LangiumDocuments.getOrCreateDocument(
|
|
9019
|
+
const stdLib = await services.shared.workspace.LangiumDocuments.getOrCreateDocument(import_langium14.URI.file(import_node_path4.default.resolve(import_node_path4.default.join(_dirname, "../res", STD_LIB_MODULE_NAME))));
|
|
7895
9020
|
const langiumDocuments = services.shared.workspace.LangiumDocuments;
|
|
7896
|
-
const document = await langiumDocuments.getOrCreateDocument(
|
|
9021
|
+
const document = await langiumDocuments.getOrCreateDocument(import_langium14.URI.file(import_node_path4.default.resolve(fileName)));
|
|
7897
9022
|
const importedURIs = await loadImports(document, langiumDocuments);
|
|
7898
9023
|
const importedDocuments = [];
|
|
7899
9024
|
for (const uri of importedURIs) {
|
|
7900
9025
|
importedDocuments.push(await langiumDocuments.getOrCreateDocument(uri));
|
|
7901
9026
|
}
|
|
7902
|
-
const additionalDocs = await Promise.all(additionalModelFiles.map((file) => services.shared.workspace.LangiumDocuments.getOrCreateDocument(
|
|
9027
|
+
const additionalDocs = await Promise.all(additionalModelFiles.map((file) => services.shared.workspace.LangiumDocuments.getOrCreateDocument(import_langium14.URI.file(import_node_path4.default.resolve(file)))));
|
|
7903
9028
|
await services.shared.workspace.DocumentBuilder.build([
|
|
7904
9029
|
stdLib,
|
|
7905
9030
|
...additionalDocs,
|
|
@@ -7969,7 +9094,7 @@ async function loadImports(document, documents, uris = /* @__PURE__ */ new Set()
|
|
|
7969
9094
|
}
|
|
7970
9095
|
}
|
|
7971
9096
|
}
|
|
7972
|
-
return Array.from(uris).filter((x) => uriString != x).map((e) =>
|
|
9097
|
+
return Array.from(uris).filter((x) => uriString != x).map((e) => import_langium14.URI.parse(e));
|
|
7973
9098
|
}
|
|
7974
9099
|
__name(loadImports, "loadImports");
|
|
7975
9100
|
function mergeImportsDeclarations(documents, model) {
|
|
@@ -7986,13 +9111,13 @@ function linkContentToContainer(node) {
|
|
|
7986
9111
|
if (!name.startsWith("$")) {
|
|
7987
9112
|
if (Array.isArray(value)) {
|
|
7988
9113
|
value.forEach((item, index) => {
|
|
7989
|
-
if ((0,
|
|
9114
|
+
if ((0, import_langium14.isAstNode)(item)) {
|
|
7990
9115
|
item.$container = node;
|
|
7991
9116
|
item.$containerProperty = name;
|
|
7992
9117
|
item.$containerIndex = index;
|
|
7993
9118
|
}
|
|
7994
9119
|
});
|
|
7995
|
-
} else if ((0,
|
|
9120
|
+
} else if ((0, import_langium14.isAstNode)(value)) {
|
|
7996
9121
|
value.$container = node;
|
|
7997
9122
|
value.$containerProperty = name;
|
|
7998
9123
|
}
|
|
@@ -8020,6 +9145,7 @@ function validationAfterImportMerge(model) {
|
|
|
8020
9145
|
__name(validationAfterImportMerge, "validationAfterImportMerge");
|
|
8021
9146
|
// Annotate the CommonJS export names for ESM import in node:
|
|
8022
9147
|
0 && (module.exports = {
|
|
9148
|
+
ZModelCodeGenerator,
|
|
8023
9149
|
ZModelLanguageMetaData,
|
|
8024
9150
|
ZModelLanguageModule,
|
|
8025
9151
|
ZModelSharedModule,
|