@zenstackhq/language 3.0.0-beta.6 → 3.0.0-beta.7
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 +96 -83
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +0 -1
- package/dist/index.d.ts +0 -1
- package/dist/index.js +47 -34
- package/dist/index.js.map +1 -1
- package/dist/utils.cjs +13 -10
- package/dist/utils.cjs.map +1 -1
- package/dist/utils.js +13 -10
- package/dist/utils.js.map +1 -1
- package/package.json +5 -5
package/dist/index.cjs
CHANGED
|
@@ -40,7 +40,7 @@ __export(src_exports, {
|
|
|
40
40
|
loadDocument: () => loadDocument
|
|
41
41
|
});
|
|
42
42
|
module.exports = __toCommonJS(src_exports);
|
|
43
|
-
var
|
|
43
|
+
var import_langium12 = require("langium");
|
|
44
44
|
var import_node = require("langium/node");
|
|
45
45
|
var import_node_fs3 = __toESM(require("fs"), 1);
|
|
46
46
|
var import_node_path2 = __toESM(require("path"), 1);
|
|
@@ -1074,7 +1074,7 @@ var ExpressionContext = /* @__PURE__ */ function(ExpressionContext2) {
|
|
|
1074
1074
|
}({});
|
|
1075
1075
|
|
|
1076
1076
|
// src/module.ts
|
|
1077
|
-
var
|
|
1077
|
+
var import_langium11 = require("langium");
|
|
1078
1078
|
var import_lsp = require("langium/lsp");
|
|
1079
1079
|
|
|
1080
1080
|
// src/generated/grammar.ts
|
|
@@ -5141,7 +5141,6 @@ var import_langium3 = require("langium");
|
|
|
5141
5141
|
var import_pluralize = __toESM(require("pluralize"), 1);
|
|
5142
5142
|
|
|
5143
5143
|
// src/utils.ts
|
|
5144
|
-
var import_common_helpers = require("@zenstackhq/common-helpers");
|
|
5145
5144
|
var import_langium2 = require("langium");
|
|
5146
5145
|
var import_node_fs = __toESM(require("fs"), 1);
|
|
5147
5146
|
var import_path = __toESM(require("path"), 1);
|
|
@@ -5246,7 +5245,7 @@ function getRecursiveBases(decl, includeDelegate = true, seen = /* @__PURE__ */
|
|
|
5246
5245
|
}
|
|
5247
5246
|
seen.add(decl);
|
|
5248
5247
|
decl.mixins.forEach((mixin) => {
|
|
5249
|
-
const baseDecl = mixin
|
|
5248
|
+
const baseDecl = decl.$container.declarations.find((d) => isTypeDef(d) && d.name === mixin.$refText);
|
|
5250
5249
|
if (baseDecl) {
|
|
5251
5250
|
if (!includeDelegate && isDelegateModel(baseDecl)) {
|
|
5252
5251
|
return;
|
|
@@ -5521,12 +5520,14 @@ function getAllFields(decl, includeIgnored = false, seen = /* @__PURE__ */ new S
|
|
|
5521
5520
|
seen.add(decl);
|
|
5522
5521
|
const fields = [];
|
|
5523
5522
|
for (const mixin of decl.mixins) {
|
|
5524
|
-
|
|
5525
|
-
|
|
5523
|
+
if (mixin.ref) {
|
|
5524
|
+
fields.push(...getAllFields(mixin.ref, includeIgnored, seen));
|
|
5525
|
+
}
|
|
5526
5526
|
}
|
|
5527
5527
|
if (isDataModel(decl) && decl.baseModel) {
|
|
5528
|
-
|
|
5529
|
-
|
|
5528
|
+
if (decl.baseModel.ref) {
|
|
5529
|
+
fields.push(...getAllFields(decl.baseModel.ref, includeIgnored, seen));
|
|
5530
|
+
}
|
|
5530
5531
|
}
|
|
5531
5532
|
fields.push(...decl.fields.filter((f) => includeIgnored || !hasAttribute(f, "@ignore")));
|
|
5532
5533
|
return fields;
|
|
@@ -5539,12 +5540,14 @@ function getAllAttributes(decl, seen = /* @__PURE__ */ new Set()) {
|
|
|
5539
5540
|
seen.add(decl);
|
|
5540
5541
|
const attributes = [];
|
|
5541
5542
|
for (const mixin of decl.mixins) {
|
|
5542
|
-
|
|
5543
|
-
|
|
5543
|
+
if (mixin.ref) {
|
|
5544
|
+
attributes.push(...getAllAttributes(mixin.ref, seen));
|
|
5545
|
+
}
|
|
5544
5546
|
}
|
|
5545
5547
|
if (isDataModel(decl) && decl.baseModel) {
|
|
5546
|
-
|
|
5547
|
-
|
|
5548
|
+
if (decl.baseModel.ref) {
|
|
5549
|
+
attributes.push(...getAllAttributes(decl.baseModel.ref, seen));
|
|
5550
|
+
}
|
|
5548
5551
|
}
|
|
5549
5552
|
attributes.push(...decl.attributes);
|
|
5550
5553
|
return attributes;
|
|
@@ -5993,7 +5996,7 @@ var AttributeValidator = class {
|
|
|
5993
5996
|
};
|
|
5994
5997
|
|
|
5995
5998
|
// src/validators/datamodel-validator.ts
|
|
5996
|
-
var
|
|
5999
|
+
var import_common_helpers = require("@zenstackhq/common-helpers");
|
|
5997
6000
|
var import_langium4 = require("langium");
|
|
5998
6001
|
|
|
5999
6002
|
// src/validators/common.ts
|
|
@@ -6364,7 +6367,7 @@ var DataModelValidator = class {
|
|
|
6364
6367
|
if (!model.baseModel) {
|
|
6365
6368
|
return;
|
|
6366
6369
|
}
|
|
6367
|
-
(0,
|
|
6370
|
+
(0, import_common_helpers.invariant)(model.baseModel.ref, "baseModel must be resolved");
|
|
6368
6371
|
if (!isDelegateModel(model.baseModel.ref)) {
|
|
6369
6372
|
accept("error", `Model ${model.baseModel.$refText} cannot be extended because it's not a delegate model`, {
|
|
6370
6373
|
node: model,
|
|
@@ -6386,7 +6389,7 @@ var DataModelValidator = class {
|
|
|
6386
6389
|
}
|
|
6387
6390
|
seen.push(current);
|
|
6388
6391
|
if (current.baseModel) {
|
|
6389
|
-
(0,
|
|
6392
|
+
(0, import_common_helpers.invariant)(current.baseModel.ref, "baseModel must be resolved");
|
|
6390
6393
|
todo.push(current.baseModel.ref);
|
|
6391
6394
|
}
|
|
6392
6395
|
}
|
|
@@ -7008,51 +7011,60 @@ var ZModelValidator = class {
|
|
|
7008
7011
|
constructor(services) {
|
|
7009
7012
|
this.services = services;
|
|
7010
7013
|
}
|
|
7011
|
-
shouldCheck(node) {
|
|
7012
|
-
let doc;
|
|
7013
|
-
let currNode = node;
|
|
7014
|
-
while (currNode) {
|
|
7015
|
-
if (currNode.$document) {
|
|
7016
|
-
doc = currNode.$document;
|
|
7017
|
-
break;
|
|
7018
|
-
}
|
|
7019
|
-
currNode = currNode.$container;
|
|
7020
|
-
}
|
|
7021
|
-
return doc?.parseResult.lexerErrors.length === 0 && doc?.parseResult.parserErrors.length === 0;
|
|
7022
|
-
}
|
|
7023
7014
|
checkModel(node, accept) {
|
|
7024
|
-
|
|
7015
|
+
new SchemaValidator(this.services.shared.workspace.LangiumDocuments).validate(node, accept);
|
|
7025
7016
|
}
|
|
7026
7017
|
checkDataSource(node, accept) {
|
|
7027
|
-
|
|
7018
|
+
new DataSourceValidator().validate(node, accept);
|
|
7028
7019
|
}
|
|
7029
7020
|
checkDataModel(node, accept) {
|
|
7030
|
-
|
|
7021
|
+
new DataModelValidator().validate(node, accept);
|
|
7031
7022
|
}
|
|
7032
7023
|
checkTypeDef(node, accept) {
|
|
7033
|
-
|
|
7024
|
+
new TypeDefValidator().validate(node, accept);
|
|
7034
7025
|
}
|
|
7035
7026
|
checkEnum(node, accept) {
|
|
7036
|
-
|
|
7027
|
+
new EnumValidator().validate(node, accept);
|
|
7037
7028
|
}
|
|
7038
7029
|
checkAttribute(node, accept) {
|
|
7039
|
-
|
|
7030
|
+
new AttributeValidator().validate(node, accept);
|
|
7040
7031
|
}
|
|
7041
7032
|
checkExpression(node, accept) {
|
|
7042
|
-
|
|
7033
|
+
new ExpressionValidator().validate(node, accept);
|
|
7043
7034
|
}
|
|
7044
7035
|
checkFunctionInvocation(node, accept) {
|
|
7045
|
-
|
|
7036
|
+
new FunctionInvocationValidator().validate(node, accept);
|
|
7046
7037
|
}
|
|
7047
7038
|
checkFunctionDecl(node, accept) {
|
|
7048
|
-
|
|
7039
|
+
new FunctionDeclValidator().validate(node, accept);
|
|
7049
7040
|
}
|
|
7050
7041
|
};
|
|
7051
7042
|
|
|
7052
|
-
// src/zmodel-
|
|
7043
|
+
// src/zmodel-document-builder.ts
|
|
7053
7044
|
var import_langium7 = require("langium");
|
|
7045
|
+
var ZModelDocumentBuilder = class extends import_langium7.DefaultDocumentBuilder {
|
|
7046
|
+
static {
|
|
7047
|
+
__name(this, "ZModelDocumentBuilder");
|
|
7048
|
+
}
|
|
7049
|
+
buildDocuments(documents, options, cancelToken) {
|
|
7050
|
+
return super.buildDocuments(documents, {
|
|
7051
|
+
...options,
|
|
7052
|
+
validation: (
|
|
7053
|
+
// force overriding validation options
|
|
7054
|
+
options.validation === false || options.validation === void 0 ? options.validation : {
|
|
7055
|
+
stopAfterLexingErrors: true,
|
|
7056
|
+
stopAfterParsingErrors: true,
|
|
7057
|
+
stopAfterLinkingErrors: true
|
|
7058
|
+
}
|
|
7059
|
+
)
|
|
7060
|
+
}, cancelToken);
|
|
7061
|
+
}
|
|
7062
|
+
};
|
|
7063
|
+
|
|
7064
|
+
// src/zmodel-linker.ts
|
|
7065
|
+
var import_langium8 = require("langium");
|
|
7054
7066
|
var import_ts_pattern2 = require("ts-pattern");
|
|
7055
|
-
var ZModelLinker = class extends
|
|
7067
|
+
var ZModelLinker = class extends import_langium8.DefaultLinker {
|
|
7056
7068
|
static {
|
|
7057
7069
|
__name(this, "ZModelLinker");
|
|
7058
7070
|
}
|
|
@@ -7062,15 +7074,15 @@ var ZModelLinker = class extends import_langium7.DefaultLinker {
|
|
|
7062
7074
|
this.descriptions = services.workspace.AstNodeDescriptionProvider;
|
|
7063
7075
|
}
|
|
7064
7076
|
//#region Reference linking
|
|
7065
|
-
async link(document, cancelToken =
|
|
7077
|
+
async link(document, cancelToken = import_langium8.Cancellation.CancellationToken.None) {
|
|
7066
7078
|
if (document.parseResult.lexerErrors?.length > 0 || document.parseResult.parserErrors?.length > 0) {
|
|
7067
7079
|
return;
|
|
7068
7080
|
}
|
|
7069
|
-
for (const node of
|
|
7070
|
-
await (0,
|
|
7081
|
+
for (const node of import_langium8.AstUtils.streamContents(document.parseResult.value)) {
|
|
7082
|
+
await (0, import_langium8.interruptAndCheck)(cancelToken);
|
|
7071
7083
|
this.resolve(node, document);
|
|
7072
7084
|
}
|
|
7073
|
-
document.state =
|
|
7085
|
+
document.state = import_langium8.DocumentState.Linked;
|
|
7074
7086
|
}
|
|
7075
7087
|
linkReference(container, property, document, extraScopes) {
|
|
7076
7088
|
if (this.resolveFromScopeProviders(container, property, document, extraScopes)) {
|
|
@@ -7220,7 +7232,7 @@ var ZModelLinker = class extends import_langium7.DefaultLinker {
|
|
|
7220
7232
|
if (node.function.ref) {
|
|
7221
7233
|
const funcDecl = node.function.ref;
|
|
7222
7234
|
if (isAuthInvocation(node)) {
|
|
7223
|
-
const allDecls = getAllLoadedAndReachableDataModelsAndTypeDefs(this.langiumDocuments(),
|
|
7235
|
+
const allDecls = getAllLoadedAndReachableDataModelsAndTypeDefs(this.langiumDocuments(), import_langium8.AstUtils.getContainerOfType(node, isDataModel));
|
|
7224
7236
|
const authDecl = getAuthDecl(allDecls);
|
|
7225
7237
|
if (authDecl) {
|
|
7226
7238
|
node.$resolvedType = {
|
|
@@ -7360,12 +7372,12 @@ var ZModelLinker = class extends import_langium7.DefaultLinker {
|
|
|
7360
7372
|
resolveDefault(node, document, extraScopes) {
|
|
7361
7373
|
for (const [property, value] of Object.entries(node)) {
|
|
7362
7374
|
if (!property.startsWith("$")) {
|
|
7363
|
-
if ((0,
|
|
7375
|
+
if ((0, import_langium8.isReference)(value)) {
|
|
7364
7376
|
this.linkReference(node, property, document, extraScopes);
|
|
7365
7377
|
}
|
|
7366
7378
|
}
|
|
7367
7379
|
}
|
|
7368
|
-
for (const child of
|
|
7380
|
+
for (const child of import_langium8.AstUtils.streamContents(node)) {
|
|
7369
7381
|
this.resolve(child, document, extraScopes);
|
|
7370
7382
|
}
|
|
7371
7383
|
}
|
|
@@ -7409,9 +7421,9 @@ var ZModelLinker = class extends import_langium7.DefaultLinker {
|
|
|
7409
7421
|
};
|
|
7410
7422
|
|
|
7411
7423
|
// src/zmodel-scope.ts
|
|
7412
|
-
var
|
|
7424
|
+
var import_langium9 = require("langium");
|
|
7413
7425
|
var import_ts_pattern3 = require("ts-pattern");
|
|
7414
|
-
var ZModelScopeComputation = class extends
|
|
7426
|
+
var ZModelScopeComputation = class extends import_langium9.DefaultScopeComputation {
|
|
7415
7427
|
static {
|
|
7416
7428
|
__name(this, "ZModelScopeComputation");
|
|
7417
7429
|
}
|
|
@@ -7421,9 +7433,9 @@ var ZModelScopeComputation = class extends import_langium8.DefaultScopeComputati
|
|
|
7421
7433
|
}
|
|
7422
7434
|
async computeExports(document, cancelToken) {
|
|
7423
7435
|
const result = await super.computeExports(document, cancelToken);
|
|
7424
|
-
for (const node of
|
|
7436
|
+
for (const node of import_langium9.AstUtils.streamAllContents(document.parseResult.value)) {
|
|
7425
7437
|
if (cancelToken) {
|
|
7426
|
-
await (0,
|
|
7438
|
+
await (0, import_langium9.interruptAndCheck)(cancelToken);
|
|
7427
7439
|
}
|
|
7428
7440
|
if (isEnumField(node)) {
|
|
7429
7441
|
const desc = this.services.workspace.AstNodeDescriptionProvider.createDescription(node, node.name, document);
|
|
@@ -7444,7 +7456,7 @@ var ZModelScopeComputation = class extends import_langium8.DefaultScopeComputati
|
|
|
7444
7456
|
}
|
|
7445
7457
|
}
|
|
7446
7458
|
};
|
|
7447
|
-
var ZModelScopeProvider = class extends
|
|
7459
|
+
var ZModelScopeProvider = class extends import_langium9.DefaultScopeProvider {
|
|
7448
7460
|
static {
|
|
7449
7461
|
__name(this, "ZModelScopeProvider");
|
|
7450
7462
|
}
|
|
@@ -7453,19 +7465,19 @@ var ZModelScopeProvider = class extends import_langium8.DefaultScopeProvider {
|
|
|
7453
7465
|
super(services), this.services = services;
|
|
7454
7466
|
}
|
|
7455
7467
|
getGlobalScope(referenceType, context) {
|
|
7456
|
-
const model =
|
|
7468
|
+
const model = import_langium9.AstUtils.getContainerOfType(context.container, isModel);
|
|
7457
7469
|
if (!model) {
|
|
7458
|
-
return
|
|
7470
|
+
return import_langium9.EMPTY_SCOPE;
|
|
7459
7471
|
}
|
|
7460
7472
|
const importedUris = model.imports.map(resolveImportUri).filter((url) => !!url);
|
|
7461
7473
|
const importedElements = this.indexManager.allElements(referenceType).filter((des) => (
|
|
7462
7474
|
// allow current document
|
|
7463
|
-
|
|
7475
|
+
import_langium9.UriUtils.equals(des.documentUri, model.$document?.uri) || // allow stdlib
|
|
7464
7476
|
des.documentUri.path.endsWith(STD_LIB_MODULE_NAME) || // allow plugin models
|
|
7465
7477
|
des.documentUri.path.endsWith(PLUGIN_MODULE_NAME) || // allow imported documents
|
|
7466
|
-
importedUris.some((importedUri) =>
|
|
7478
|
+
importedUris.some((importedUri) => import_langium9.UriUtils.equals(des.documentUri, importedUri))
|
|
7467
7479
|
));
|
|
7468
|
-
return new
|
|
7480
|
+
return new import_langium9.StreamScope(importedElements);
|
|
7469
7481
|
}
|
|
7470
7482
|
getScope(context) {
|
|
7471
7483
|
if (isMemberAccessExpr(context.container) && context.container.operand && context.property === "member") {
|
|
@@ -7485,20 +7497,20 @@ var ZModelScopeProvider = class extends import_langium8.DefaultScopeProvider {
|
|
|
7485
7497
|
const node = context.container;
|
|
7486
7498
|
const allowTypeDefScope = (
|
|
7487
7499
|
// isAuthOrAuthMemberAccess(node.operand) ||
|
|
7488
|
-
!!
|
|
7500
|
+
!!import_langium9.AstUtils.getContainerOfType(node, isTypeDef)
|
|
7489
7501
|
);
|
|
7490
7502
|
return (0, import_ts_pattern3.match)(node.operand).when(isReferenceExpr, (operand) => {
|
|
7491
7503
|
const ref = operand.target.ref;
|
|
7492
7504
|
if (isDataField(ref)) {
|
|
7493
7505
|
return this.createScopeForContainer(ref.type.reference?.ref, globalScope, allowTypeDefScope);
|
|
7494
7506
|
}
|
|
7495
|
-
return
|
|
7507
|
+
return import_langium9.EMPTY_SCOPE;
|
|
7496
7508
|
}).when(isMemberAccessExpr, (operand) => {
|
|
7497
7509
|
const ref = operand.member.ref;
|
|
7498
7510
|
if (isDataField(ref) && !ref.type.array) {
|
|
7499
7511
|
return this.createScopeForContainer(ref.type.reference?.ref, globalScope, allowTypeDefScope);
|
|
7500
7512
|
}
|
|
7501
|
-
return
|
|
7513
|
+
return import_langium9.EMPTY_SCOPE;
|
|
7502
7514
|
}).when(isThisExpr, () => {
|
|
7503
7515
|
return this.createScopeForContainingModel(node, globalScope);
|
|
7504
7516
|
}).when(isInvocationExpr, (operand) => {
|
|
@@ -7508,8 +7520,8 @@ var ZModelScopeProvider = class extends import_langium8.DefaultScopeProvider {
|
|
|
7508
7520
|
if (isFutureInvocation(operand)) {
|
|
7509
7521
|
return this.createScopeForContainingModel(node, globalScope);
|
|
7510
7522
|
}
|
|
7511
|
-
return
|
|
7512
|
-
}).otherwise(() =>
|
|
7523
|
+
return import_langium9.EMPTY_SCOPE;
|
|
7524
|
+
}).otherwise(() => import_langium9.EMPTY_SCOPE);
|
|
7513
7525
|
}
|
|
7514
7526
|
getCollectionPredicateScope(context, collectionPredicate) {
|
|
7515
7527
|
const referenceType = this.reflection.getReferenceType(context);
|
|
@@ -7521,30 +7533,30 @@ var ZModelScopeProvider = class extends import_langium8.DefaultScopeProvider {
|
|
|
7521
7533
|
if (isDataField(ref)) {
|
|
7522
7534
|
return this.createScopeForContainer(ref.type.reference?.ref, globalScope, allowTypeDefScope);
|
|
7523
7535
|
}
|
|
7524
|
-
return
|
|
7536
|
+
return import_langium9.EMPTY_SCOPE;
|
|
7525
7537
|
}).when(isMemberAccessExpr, (expr) => {
|
|
7526
7538
|
const ref = expr.member.ref;
|
|
7527
7539
|
if (isDataField(ref)) {
|
|
7528
7540
|
return this.createScopeForContainer(ref.type.reference?.ref, globalScope, allowTypeDefScope);
|
|
7529
7541
|
}
|
|
7530
|
-
return
|
|
7542
|
+
return import_langium9.EMPTY_SCOPE;
|
|
7531
7543
|
}).when(isInvocationExpr, (expr) => {
|
|
7532
7544
|
const returnTypeDecl = expr.function.ref?.returnType.reference?.ref;
|
|
7533
7545
|
if (isDataModel(returnTypeDecl)) {
|
|
7534
7546
|
return this.createScopeForContainer(returnTypeDecl, globalScope, allowTypeDefScope);
|
|
7535
7547
|
} else {
|
|
7536
|
-
return
|
|
7548
|
+
return import_langium9.EMPTY_SCOPE;
|
|
7537
7549
|
}
|
|
7538
7550
|
}).when(isAuthInvocation, (expr) => {
|
|
7539
7551
|
return this.createScopeForAuth(expr, globalScope);
|
|
7540
|
-
}).otherwise(() =>
|
|
7552
|
+
}).otherwise(() => import_langium9.EMPTY_SCOPE);
|
|
7541
7553
|
}
|
|
7542
7554
|
createScopeForContainingModel(node, globalScope) {
|
|
7543
|
-
const model =
|
|
7555
|
+
const model = import_langium9.AstUtils.getContainerOfType(node, isDataModel);
|
|
7544
7556
|
if (model) {
|
|
7545
7557
|
return this.createScopeForContainer(model, globalScope);
|
|
7546
7558
|
} else {
|
|
7547
|
-
return
|
|
7559
|
+
return import_langium9.EMPTY_SCOPE;
|
|
7548
7560
|
}
|
|
7549
7561
|
}
|
|
7550
7562
|
createScopeForContainer(node, globalScope, includeTypeDefScope = false) {
|
|
@@ -7553,16 +7565,16 @@ var ZModelScopeProvider = class extends import_langium8.DefaultScopeProvider {
|
|
|
7553
7565
|
} else if (includeTypeDefScope && isTypeDef(node)) {
|
|
7554
7566
|
return this.createScopeForNodes(node.fields, globalScope);
|
|
7555
7567
|
} else {
|
|
7556
|
-
return
|
|
7568
|
+
return import_langium9.EMPTY_SCOPE;
|
|
7557
7569
|
}
|
|
7558
7570
|
}
|
|
7559
7571
|
createScopeForAuth(node, globalScope) {
|
|
7560
|
-
const decls = getAllLoadedAndReachableDataModelsAndTypeDefs(this.services.shared.workspace.LangiumDocuments,
|
|
7572
|
+
const decls = getAllLoadedAndReachableDataModelsAndTypeDefs(this.services.shared.workspace.LangiumDocuments, import_langium9.AstUtils.getContainerOfType(node, isDataModel));
|
|
7561
7573
|
const authDecl = getAuthDecl(decls);
|
|
7562
7574
|
if (authDecl) {
|
|
7563
7575
|
return this.createScopeForContainer(authDecl, globalScope, true);
|
|
7564
7576
|
} else {
|
|
7565
|
-
return
|
|
7577
|
+
return import_langium9.EMPTY_SCOPE;
|
|
7566
7578
|
}
|
|
7567
7579
|
}
|
|
7568
7580
|
};
|
|
@@ -7579,12 +7591,12 @@ function getCollectionPredicateContext(node) {
|
|
|
7579
7591
|
__name(getCollectionPredicateContext, "getCollectionPredicateContext");
|
|
7580
7592
|
|
|
7581
7593
|
// src/zmodel-workspace-manager.ts
|
|
7582
|
-
var
|
|
7594
|
+
var import_langium10 = require("langium");
|
|
7583
7595
|
var import_node_fs2 = __toESM(require("fs"), 1);
|
|
7584
7596
|
var import_node_path = __toESM(require("path"), 1);
|
|
7585
7597
|
var import_node_url = require("url");
|
|
7586
7598
|
var import_meta = {};
|
|
7587
|
-
var ZModelWorkspaceManager = class extends
|
|
7599
|
+
var ZModelWorkspaceManager = class extends import_langium10.DefaultWorkspaceManager {
|
|
7588
7600
|
static {
|
|
7589
7601
|
__name(this, "ZModelWorkspaceManager");
|
|
7590
7602
|
}
|
|
@@ -7623,7 +7635,7 @@ var ZModelWorkspaceManager = class extends import_langium9.DefaultWorkspaceManag
|
|
|
7623
7635
|
stdLibPath = import_node_path.default.join(_dirname, "../res", STD_LIB_MODULE_NAME);
|
|
7624
7636
|
console.log(`Using bundled stdlib in extension:`, stdLibPath);
|
|
7625
7637
|
}
|
|
7626
|
-
const stdlib = await this.documentFactory.fromUri(
|
|
7638
|
+
const stdlib = await this.documentFactory.fromUri(import_langium10.URI.file(stdLibPath));
|
|
7627
7639
|
collector(stdlib);
|
|
7628
7640
|
const documents = this.langiumDocuments.all;
|
|
7629
7641
|
const pluginModels = /* @__PURE__ */ new Set();
|
|
@@ -7653,7 +7665,7 @@ var ZModelWorkspaceManager = class extends import_langium9.DefaultWorkspaceManag
|
|
|
7653
7665
|
async loadPluginModels(workspaceFolder, folderPath, pendingPluginModels, collector) {
|
|
7654
7666
|
const content = (await this.fileSystemProvider.readDirectory(folderPath)).sort((a, b) => {
|
|
7655
7667
|
if (a.isDirectory && b.isDirectory) {
|
|
7656
|
-
const aName =
|
|
7668
|
+
const aName = import_langium10.UriUtils.basename(a.uri);
|
|
7657
7669
|
if (aName === "node_modules") {
|
|
7658
7670
|
return -1;
|
|
7659
7671
|
} else {
|
|
@@ -7665,10 +7677,10 @@ var ZModelWorkspaceManager = class extends import_langium9.DefaultWorkspaceManag
|
|
|
7665
7677
|
});
|
|
7666
7678
|
for (const entry of content) {
|
|
7667
7679
|
if (entry.isDirectory) {
|
|
7668
|
-
const name =
|
|
7680
|
+
const name = import_langium10.UriUtils.basename(entry.uri);
|
|
7669
7681
|
if (name === "node_modules") {
|
|
7670
7682
|
for (const plugin of Array.from(pendingPluginModels)) {
|
|
7671
|
-
const path4 =
|
|
7683
|
+
const path4 = import_langium10.UriUtils.joinPath(entry.uri, plugin, PLUGIN_MODULE_NAME);
|
|
7672
7684
|
try {
|
|
7673
7685
|
await this.fileSystemProvider.readFile(path4);
|
|
7674
7686
|
const document = await this.langiumDocuments.getOrCreateDocument(path4);
|
|
@@ -7702,12 +7714,13 @@ var ZModelLanguageModule = {
|
|
|
7702
7714
|
};
|
|
7703
7715
|
var ZModelSharedModule = {
|
|
7704
7716
|
workspace: {
|
|
7717
|
+
DocumentBuilder: /* @__PURE__ */ __name((services) => new ZModelDocumentBuilder(services), "DocumentBuilder"),
|
|
7705
7718
|
WorkspaceManager: /* @__PURE__ */ __name((services) => new ZModelWorkspaceManager(services), "WorkspaceManager")
|
|
7706
7719
|
}
|
|
7707
7720
|
};
|
|
7708
7721
|
function createZModelLanguageServices(context) {
|
|
7709
|
-
const shared = (0,
|
|
7710
|
-
const ZModelLanguage = (0,
|
|
7722
|
+
const shared = (0, import_langium11.inject)((0, import_lsp.createDefaultSharedModule)(context), ZModelGeneratedSharedModule, ZModelSharedModule);
|
|
7723
|
+
const ZModelLanguage = (0, import_langium11.inject)((0, import_lsp.createDefaultModule)({
|
|
7711
7724
|
shared
|
|
7712
7725
|
}), ZModelGeneratedModule, ZModelLanguageModule);
|
|
7713
7726
|
shared.ServiceRegistry.register(ZModelLanguage);
|
|
@@ -7758,10 +7771,10 @@ async function loadDocument(fileName, pluginModelFiles = []) {
|
|
|
7758
7771
|
};
|
|
7759
7772
|
}
|
|
7760
7773
|
const _dirname = typeof __dirname !== "undefined" ? __dirname : import_node_path2.default.dirname((0, import_node_url2.fileURLToPath)(import_meta2.url));
|
|
7761
|
-
const stdLib = await services.shared.workspace.LangiumDocuments.getOrCreateDocument(
|
|
7762
|
-
const pluginDocs = await Promise.all(pluginModelFiles.map((file) => services.shared.workspace.LangiumDocuments.getOrCreateDocument(
|
|
7774
|
+
const stdLib = await services.shared.workspace.LangiumDocuments.getOrCreateDocument(import_langium12.URI.file(import_node_path2.default.resolve(import_node_path2.default.join(_dirname, "../res", STD_LIB_MODULE_NAME))));
|
|
7775
|
+
const pluginDocs = await Promise.all(pluginModelFiles.map((file) => services.shared.workspace.LangiumDocuments.getOrCreateDocument(import_langium12.URI.file(import_node_path2.default.resolve(file)))));
|
|
7763
7776
|
const langiumDocuments = services.shared.workspace.LangiumDocuments;
|
|
7764
|
-
const document = await langiumDocuments.getOrCreateDocument(
|
|
7777
|
+
const document = await langiumDocuments.getOrCreateDocument(import_langium12.URI.file(import_node_path2.default.resolve(fileName)));
|
|
7765
7778
|
const importedURIs = await loadImports(document, langiumDocuments);
|
|
7766
7779
|
const importedDocuments = [];
|
|
7767
7780
|
for (const uri of importedURIs) {
|
|
@@ -7832,7 +7845,7 @@ async function loadImports(document, documents, uris = /* @__PURE__ */ new Set()
|
|
|
7832
7845
|
}
|
|
7833
7846
|
}
|
|
7834
7847
|
}
|
|
7835
|
-
return Array.from(uris).filter((x) => uriString != x).map((e) =>
|
|
7848
|
+
return Array.from(uris).filter((x) => uriString != x).map((e) => import_langium12.URI.parse(e));
|
|
7836
7849
|
}
|
|
7837
7850
|
__name(loadImports, "loadImports");
|
|
7838
7851
|
function mergeImportsDeclarations(documents, model) {
|
|
@@ -7849,13 +7862,13 @@ function linkContentToContainer(node) {
|
|
|
7849
7862
|
if (!name.startsWith("$")) {
|
|
7850
7863
|
if (Array.isArray(value)) {
|
|
7851
7864
|
value.forEach((item, index) => {
|
|
7852
|
-
if ((0,
|
|
7865
|
+
if ((0, import_langium12.isAstNode)(item)) {
|
|
7853
7866
|
item.$container = node;
|
|
7854
7867
|
item.$containerProperty = name;
|
|
7855
7868
|
item.$containerIndex = index;
|
|
7856
7869
|
}
|
|
7857
7870
|
});
|
|
7858
|
-
} else if ((0,
|
|
7871
|
+
} else if ((0, import_langium12.isAstNode)(value)) {
|
|
7859
7872
|
value.$container = node;
|
|
7860
7873
|
value.$containerProperty = name;
|
|
7861
7874
|
}
|