@zenstackhq/language 3.0.0-alpha.4 → 3.0.0-alpha.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/ast.cjs +12 -2
- package/dist/ast.cjs.map +1 -1
- package/dist/ast.d.cts +63 -62
- package/dist/ast.d.ts +63 -62
- package/dist/ast.js +2 -2
- package/dist/ast.js.map +1 -1
- package/dist/index.cjs +79 -80
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +23 -24
- package/dist/index.js.map +1 -1
- package/package.json +6 -9
- package/res/stdlib.zmodel +11 -11
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_langium11 = 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);
|
|
@@ -76,11 +76,11 @@ var ExpressionContext = /* @__PURE__ */ function(ExpressionContext2) {
|
|
|
76
76
|
}({});
|
|
77
77
|
|
|
78
78
|
// src/module.ts
|
|
79
|
-
var
|
|
79
|
+
var import_langium10 = require("langium");
|
|
80
80
|
var import_lsp = require("langium/lsp");
|
|
81
81
|
|
|
82
82
|
// src/generated/ast.ts
|
|
83
|
-
var
|
|
83
|
+
var langium = __toESM(require("langium"), 1);
|
|
84
84
|
var AbstractDeclaration = "AbstractDeclaration";
|
|
85
85
|
var ConfigExpr = "ConfigExpr";
|
|
86
86
|
var Expression = "Expression";
|
|
@@ -239,7 +239,7 @@ __name(isTypeDefField, "isTypeDefField");
|
|
|
239
239
|
var TypeDefFieldType = "TypeDefFieldType";
|
|
240
240
|
var UnaryExpr = "UnaryExpr";
|
|
241
241
|
var UnsupportedFieldType = "UnsupportedFieldType";
|
|
242
|
-
var ZModelAstReflection = class extends
|
|
242
|
+
var ZModelAstReflection = class extends langium.AbstractAstReflection {
|
|
243
243
|
static {
|
|
244
244
|
__name(this, "ZModelAstReflection");
|
|
245
245
|
}
|
|
@@ -1125,17 +1125,17 @@ var ZModelAstReflection = class extends import_langium.AbstractAstReflection {
|
|
|
1125
1125
|
var reflection = new ZModelAstReflection();
|
|
1126
1126
|
|
|
1127
1127
|
// src/generated/grammar.ts
|
|
1128
|
-
var
|
|
1128
|
+
var import_langium = require("langium");
|
|
1129
1129
|
var loadedZModelGrammar;
|
|
1130
|
-
var ZModelGrammar = /* @__PURE__ */ __name(() => loadedZModelGrammar ?? (loadedZModelGrammar = (0,
|
|
1130
|
+
var ZModelGrammar = /* @__PURE__ */ __name(() => loadedZModelGrammar ?? (loadedZModelGrammar = (0, import_langium.loadGrammarFromJson)(`{
|
|
1131
1131
|
"$type": "Grammar",
|
|
1132
1132
|
"isDeclared": true,
|
|
1133
1133
|
"name": "ZModel",
|
|
1134
1134
|
"rules": [
|
|
1135
1135
|
{
|
|
1136
1136
|
"$type": "ParserRule",
|
|
1137
|
-
"name": "Model",
|
|
1138
1137
|
"entry": true,
|
|
1138
|
+
"name": "Model",
|
|
1139
1139
|
"definition": {
|
|
1140
1140
|
"$type": "Group",
|
|
1141
1141
|
"elements": [
|
|
@@ -1821,8 +1821,8 @@ var ZModelGrammar = /* @__PURE__ */ __name(() => loadedZModelGrammar ?? (loadedZ
|
|
|
1821
1821
|
},
|
|
1822
1822
|
{
|
|
1823
1823
|
"$type": "ParserRule",
|
|
1824
|
-
"name": "ConfigInvocationArgList",
|
|
1825
1824
|
"fragment": true,
|
|
1825
|
+
"name": "ConfigInvocationArgList",
|
|
1826
1826
|
"definition": {
|
|
1827
1827
|
"$type": "Group",
|
|
1828
1828
|
"elements": [
|
|
@@ -2129,8 +2129,8 @@ var ZModelGrammar = /* @__PURE__ */ __name(() => loadedZModelGrammar ?? (loadedZ
|
|
|
2129
2129
|
},
|
|
2130
2130
|
{
|
|
2131
2131
|
"$type": "ParserRule",
|
|
2132
|
-
"name": "ReferenceArgList",
|
|
2133
2132
|
"fragment": true,
|
|
2133
|
+
"name": "ReferenceArgList",
|
|
2134
2134
|
"definition": {
|
|
2135
2135
|
"$type": "Group",
|
|
2136
2136
|
"elements": [
|
|
@@ -2946,8 +2946,8 @@ var ZModelGrammar = /* @__PURE__ */ __name(() => loadedZModelGrammar ?? (loadedZ
|
|
|
2946
2946
|
},
|
|
2947
2947
|
{
|
|
2948
2948
|
"$type": "ParserRule",
|
|
2949
|
-
"name": "ArgumentList",
|
|
2950
2949
|
"fragment": true,
|
|
2950
|
+
"name": "ArgumentList",
|
|
2951
2951
|
"definition": {
|
|
2952
2952
|
"$type": "Group",
|
|
2953
2953
|
"elements": [
|
|
@@ -4815,8 +4815,8 @@ var ZModelGrammar = /* @__PURE__ */ __name(() => loadedZModelGrammar ?? (loadedZ
|
|
|
4815
4815
|
},
|
|
4816
4816
|
{
|
|
4817
4817
|
"$type": "ParserRule",
|
|
4818
|
-
"name": "AttributeArgList",
|
|
4819
4818
|
"fragment": true,
|
|
4819
|
+
"name": "AttributeArgList",
|
|
4820
4820
|
"definition": {
|
|
4821
4821
|
"$type": "Group",
|
|
4822
4822
|
"elements": [
|
|
@@ -5270,11 +5270,11 @@ var ZModelGeneratedModule = {
|
|
|
5270
5270
|
};
|
|
5271
5271
|
|
|
5272
5272
|
// src/validators/attribute-application-validator.ts
|
|
5273
|
-
var
|
|
5273
|
+
var import_langium3 = require("langium");
|
|
5274
5274
|
var import_pluralize = __toESM(require("pluralize"), 1);
|
|
5275
5275
|
|
|
5276
5276
|
// src/utils.ts
|
|
5277
|
-
var
|
|
5277
|
+
var import_langium2 = require("langium");
|
|
5278
5278
|
var import_path = __toESM(require("path"), 1);
|
|
5279
5279
|
var import_node_fs = __toESM(require("fs"), 1);
|
|
5280
5280
|
function hasAttribute(decl, name) {
|
|
@@ -5286,7 +5286,7 @@ function getAttribute(decl, name) {
|
|
|
5286
5286
|
}
|
|
5287
5287
|
__name(getAttribute, "getAttribute");
|
|
5288
5288
|
function isFromStdlib(node) {
|
|
5289
|
-
const model =
|
|
5289
|
+
const model = import_langium2.AstUtils.getContainerOfType(node, isModel);
|
|
5290
5290
|
return !!model && !!model.$document && model.$document.uri.path.endsWith(STD_LIB_MODULE_NAME);
|
|
5291
5291
|
}
|
|
5292
5292
|
__name(isFromStdlib, "isFromStdlib");
|
|
@@ -5557,8 +5557,8 @@ function resolveTransitiveImports(documents, model) {
|
|
|
5557
5557
|
}
|
|
5558
5558
|
__name(resolveTransitiveImports, "resolveTransitiveImports");
|
|
5559
5559
|
function resolveTransitiveImportsInternal(documents, model, initialModel = model, visited = /* @__PURE__ */ new Set(), models = /* @__PURE__ */ new Set()) {
|
|
5560
|
-
const doc =
|
|
5561
|
-
const initialDoc =
|
|
5560
|
+
const doc = import_langium2.AstUtils.getDocument(model);
|
|
5561
|
+
const initialDoc = import_langium2.AstUtils.getDocument(initialModel);
|
|
5562
5562
|
if (initialDoc.uri.fsPath.toLowerCase() !== doc.uri.fsPath.toLowerCase()) {
|
|
5563
5563
|
models.add(model);
|
|
5564
5564
|
}
|
|
@@ -5604,9 +5604,9 @@ function resolveImportUri(imp) {
|
|
|
5604
5604
|
const contextPath = imp.$container.$document ? import_path.default.dirname(imp.$container.$document.uri.fsPath) : process.cwd();
|
|
5605
5605
|
imp.path = findNodeModulesFile(imp.path, contextPath) ?? imp.path;
|
|
5606
5606
|
}
|
|
5607
|
-
const doc =
|
|
5607
|
+
const doc = import_langium2.AstUtils.getDocument(imp);
|
|
5608
5608
|
const dir = import_path.default.dirname(doc.uri.fsPath);
|
|
5609
|
-
return
|
|
5609
|
+
return import_langium2.URI.file(import_path.default.resolve(dir, imp.path));
|
|
5610
5610
|
}
|
|
5611
5611
|
__name(resolveImportUri, "resolveImportUri");
|
|
5612
5612
|
function findNodeModulesFile(name, cwd = process.cwd()) {
|
|
@@ -5618,7 +5618,7 @@ function findNodeModulesFile(name, cwd = process.cwd()) {
|
|
|
5618
5618
|
]
|
|
5619
5619
|
});
|
|
5620
5620
|
return resolvedPath;
|
|
5621
|
-
} catch
|
|
5621
|
+
} catch {
|
|
5622
5622
|
return void 0;
|
|
5623
5623
|
}
|
|
5624
5624
|
}
|
|
@@ -5659,7 +5659,7 @@ __name(getAllDataModelsIncludingImports, "getAllDataModelsIncludingImports");
|
|
|
5659
5659
|
function getAllLoadedAndReachableDataModelsAndTypeDefs(langiumDocuments, fromModel) {
|
|
5660
5660
|
const allDataModels = getAllLoadedDataModelsAndTypeDefs(langiumDocuments);
|
|
5661
5661
|
if (fromModel) {
|
|
5662
|
-
const model =
|
|
5662
|
+
const model = import_langium2.AstUtils.getContainerOfType(fromModel, isModel);
|
|
5663
5663
|
if (model) {
|
|
5664
5664
|
const transitiveDataModels = getAllDataModelsIncludingImports(langiumDocuments, model);
|
|
5665
5665
|
transitiveDataModels.forEach((dm) => {
|
|
@@ -5819,7 +5819,7 @@ var AttributeApplicationValidator = class {
|
|
|
5819
5819
|
"all"
|
|
5820
5820
|
], attr, accept);
|
|
5821
5821
|
const expr = attr.args[1]?.value;
|
|
5822
|
-
if (expr &&
|
|
5822
|
+
if (expr && import_langium3.AstUtils.streamAst(expr).some((node) => isFutureExpr(node))) {
|
|
5823
5823
|
accept("error", `"future()" is not allowed in field-level policy rules`, {
|
|
5824
5824
|
node: expr
|
|
5825
5825
|
});
|
|
@@ -5836,7 +5836,7 @@ var AttributeApplicationValidator = class {
|
|
|
5836
5836
|
}
|
|
5837
5837
|
_checkValidate(attr, accept) {
|
|
5838
5838
|
const condition = attr.args[0]?.value;
|
|
5839
|
-
if (condition &&
|
|
5839
|
+
if (condition && import_langium3.AstUtils.streamAst(condition).some((node) => isDataModelFieldReference(node) && isDataModel(node.$resolvedType?.decl))) {
|
|
5840
5840
|
accept("error", `\`@@validate\` condition cannot use relation fields`, {
|
|
5841
5841
|
node: condition
|
|
5842
5842
|
});
|
|
@@ -5874,7 +5874,7 @@ var AttributeApplicationValidator = class {
|
|
|
5874
5874
|
}
|
|
5875
5875
|
}
|
|
5876
5876
|
rejectEncryptedFields(attr, accept) {
|
|
5877
|
-
|
|
5877
|
+
import_langium3.AstUtils.streamAllContents(attr).forEach((node) => {
|
|
5878
5878
|
if (isDataModelFieldReference(node) && hasAttribute(node.target.ref, "@encrypted")) {
|
|
5879
5879
|
accept("error", `Encrypted fields cannot be used in policy rules`, {
|
|
5880
5880
|
node
|
|
@@ -6058,7 +6058,7 @@ var AttributeValidator = class {
|
|
|
6058
6058
|
};
|
|
6059
6059
|
|
|
6060
6060
|
// src/validators/datamodel-validator.ts
|
|
6061
|
-
var
|
|
6061
|
+
var import_langium4 = require("langium");
|
|
6062
6062
|
|
|
6063
6063
|
// src/validators/common.ts
|
|
6064
6064
|
function validateDuplicatedDeclarations(container, decls, accept) {
|
|
@@ -6154,7 +6154,7 @@ var DataModelValidator = class {
|
|
|
6154
6154
|
});
|
|
6155
6155
|
}
|
|
6156
6156
|
if (field.type.array && !isDataModel(field.type.reference?.ref)) {
|
|
6157
|
-
const provider = this.getDataSourceProvider(
|
|
6157
|
+
const provider = this.getDataSourceProvider(import_langium4.AstUtils.getContainerOfType(field, isModel));
|
|
6158
6158
|
if (provider === "sqlite") {
|
|
6159
6159
|
accept("error", `Array type is not supported for "${provider}" provider.`, {
|
|
6160
6160
|
node: field.type
|
|
@@ -6317,7 +6317,7 @@ var DataModelValidator = class {
|
|
|
6317
6317
|
};
|
|
6318
6318
|
info.property = "name";
|
|
6319
6319
|
const container = field.$container;
|
|
6320
|
-
const relationFieldDocUri =
|
|
6320
|
+
const relationFieldDocUri = import_langium4.AstUtils.getDocument(container).textDocument.uri;
|
|
6321
6321
|
const relationDataModelName = container.name;
|
|
6322
6322
|
const data = {
|
|
6323
6323
|
relationFieldName: field.name,
|
|
@@ -6522,7 +6522,6 @@ var EnumValidator = class {
|
|
|
6522
6522
|
static {
|
|
6523
6523
|
__name(this, "EnumValidator");
|
|
6524
6524
|
}
|
|
6525
|
-
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types
|
|
6526
6525
|
validate(_enum, accept) {
|
|
6527
6526
|
validateDuplicatedDeclarations(_enum, _enum.fields, accept);
|
|
6528
6527
|
this.validateAttributes(_enum, accept);
|
|
@@ -6539,7 +6538,7 @@ var EnumValidator = class {
|
|
|
6539
6538
|
};
|
|
6540
6539
|
|
|
6541
6540
|
// src/validators/expression-validator.ts
|
|
6542
|
-
var
|
|
6541
|
+
var import_langium5 = require("langium");
|
|
6543
6542
|
var ExpressionValidator = class {
|
|
6544
6543
|
static {
|
|
6545
6544
|
__name(this, "ExpressionValidator");
|
|
@@ -6551,7 +6550,7 @@ var ExpressionValidator = class {
|
|
|
6551
6550
|
node: expr
|
|
6552
6551
|
});
|
|
6553
6552
|
} else {
|
|
6554
|
-
const hasReferenceResolutionError =
|
|
6553
|
+
const hasReferenceResolutionError = import_langium5.AstUtils.streamAst(expr).some((node) => {
|
|
6555
6554
|
if (isMemberAccessExpr(node)) {
|
|
6556
6555
|
return !!node.member.error;
|
|
6557
6556
|
}
|
|
@@ -6737,7 +6736,7 @@ var FunctionDeclValidator = class {
|
|
|
6737
6736
|
};
|
|
6738
6737
|
|
|
6739
6738
|
// src/validators/function-invocation-validator.ts
|
|
6740
|
-
var
|
|
6739
|
+
var import_langium6 = require("langium");
|
|
6741
6740
|
var import_ts_pattern = require("ts-pattern");
|
|
6742
6741
|
function _ts_decorate2(decorators, target, key, desc) {
|
|
6743
6742
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
@@ -6939,7 +6938,7 @@ var FunctionInvocationValidator = class {
|
|
|
6939
6938
|
if (!rule) {
|
|
6940
6939
|
continue;
|
|
6941
6940
|
}
|
|
6942
|
-
|
|
6941
|
+
import_langium6.AstUtils.streamAst(rule).forEach((node) => {
|
|
6943
6942
|
if (isCheckInvocation(node)) {
|
|
6944
6943
|
tasks.push(node);
|
|
6945
6944
|
}
|
|
@@ -6967,10 +6966,10 @@ var SchemaValidator = class {
|
|
|
6967
6966
|
constructor(documents) {
|
|
6968
6967
|
this.documents = documents;
|
|
6969
6968
|
}
|
|
6970
|
-
|
|
6971
|
-
|
|
6969
|
+
validate(model, accept) {
|
|
6970
|
+
this.validateImports(model, accept);
|
|
6972
6971
|
validateDuplicatedDeclarations(model, model.declarations, accept);
|
|
6973
|
-
const importedModels =
|
|
6972
|
+
const importedModels = resolveTransitiveImports(this.documents, model);
|
|
6974
6973
|
const importedNames = new Set(importedModels.flatMap((m) => m.declarations.map((d) => d.name)));
|
|
6975
6974
|
for (const declaration of model.declarations) {
|
|
6976
6975
|
if (importedNames.has(declaration.name)) {
|
|
@@ -6992,16 +6991,16 @@ var SchemaValidator = class {
|
|
|
6992
6991
|
});
|
|
6993
6992
|
}
|
|
6994
6993
|
}
|
|
6995
|
-
|
|
6996
|
-
|
|
6997
|
-
const importedModel =
|
|
6994
|
+
validateImports(model, accept) {
|
|
6995
|
+
model.imports.forEach((imp) => {
|
|
6996
|
+
const importedModel = resolveImport(this.documents, imp);
|
|
6998
6997
|
const importPath = imp.path.endsWith(".zmodel") ? imp.path : `${imp.path}.zmodel`;
|
|
6999
6998
|
if (!importedModel) {
|
|
7000
6999
|
accept("error", `Cannot find model file ${importPath}`, {
|
|
7001
7000
|
node: imp
|
|
7002
7001
|
});
|
|
7003
7002
|
}
|
|
7004
|
-
})
|
|
7003
|
+
});
|
|
7005
7004
|
}
|
|
7006
7005
|
};
|
|
7007
7006
|
|
|
@@ -7094,9 +7093,9 @@ var ZModelValidator = class {
|
|
|
7094
7093
|
};
|
|
7095
7094
|
|
|
7096
7095
|
// src/zmodel-linker.ts
|
|
7097
|
-
var
|
|
7096
|
+
var import_langium7 = require("langium");
|
|
7098
7097
|
var import_ts_pattern2 = require("ts-pattern");
|
|
7099
|
-
var ZModelLinker = class extends
|
|
7098
|
+
var ZModelLinker = class extends import_langium7.DefaultLinker {
|
|
7100
7099
|
static {
|
|
7101
7100
|
__name(this, "ZModelLinker");
|
|
7102
7101
|
}
|
|
@@ -7106,15 +7105,15 @@ var ZModelLinker = class extends import_langium8.DefaultLinker {
|
|
|
7106
7105
|
this.descriptions = services.workspace.AstNodeDescriptionProvider;
|
|
7107
7106
|
}
|
|
7108
7107
|
//#region Reference linking
|
|
7109
|
-
async link(document, cancelToken =
|
|
7108
|
+
async link(document, cancelToken = import_langium7.Cancellation.CancellationToken.None) {
|
|
7110
7109
|
if (document.parseResult.lexerErrors?.length > 0 || document.parseResult.parserErrors?.length > 0) {
|
|
7111
7110
|
return;
|
|
7112
7111
|
}
|
|
7113
|
-
for (const node of
|
|
7114
|
-
await (0,
|
|
7112
|
+
for (const node of import_langium7.AstUtils.streamContents(document.parseResult.value)) {
|
|
7113
|
+
await (0, import_langium7.interruptAndCheck)(cancelToken);
|
|
7115
7114
|
this.resolve(node, document);
|
|
7116
7115
|
}
|
|
7117
|
-
document.state =
|
|
7116
|
+
document.state = import_langium7.DocumentState.Linked;
|
|
7118
7117
|
}
|
|
7119
7118
|
linkReference(container, property, document, extraScopes) {
|
|
7120
7119
|
if (this.resolveFromScopeProviders(container, property, document, extraScopes)) {
|
|
@@ -7264,7 +7263,7 @@ var ZModelLinker = class extends import_langium8.DefaultLinker {
|
|
|
7264
7263
|
if (node.function.ref) {
|
|
7265
7264
|
const funcDecl = node.function.ref;
|
|
7266
7265
|
if (isAuthInvocation(node)) {
|
|
7267
|
-
const allDecls = getAllLoadedAndReachableDataModelsAndTypeDefs(this.langiumDocuments(),
|
|
7266
|
+
const allDecls = getAllLoadedAndReachableDataModelsAndTypeDefs(this.langiumDocuments(), import_langium7.AstUtils.getContainerOfType(node, isDataModel));
|
|
7268
7267
|
const authDecl = getAuthDecl(allDecls);
|
|
7269
7268
|
if (authDecl) {
|
|
7270
7269
|
node.$resolvedType = {
|
|
@@ -7404,12 +7403,12 @@ var ZModelLinker = class extends import_langium8.DefaultLinker {
|
|
|
7404
7403
|
resolveDefault(node, document, extraScopes) {
|
|
7405
7404
|
for (const [property, value] of Object.entries(node)) {
|
|
7406
7405
|
if (!property.startsWith("$")) {
|
|
7407
|
-
if ((0,
|
|
7406
|
+
if ((0, import_langium7.isReference)(value)) {
|
|
7408
7407
|
this.linkReference(node, property, document, extraScopes);
|
|
7409
7408
|
}
|
|
7410
7409
|
}
|
|
7411
7410
|
}
|
|
7412
|
-
for (const child of
|
|
7411
|
+
for (const child of import_langium7.AstUtils.streamContents(node)) {
|
|
7413
7412
|
this.resolve(child, document, extraScopes);
|
|
7414
7413
|
}
|
|
7415
7414
|
}
|
|
@@ -7453,9 +7452,9 @@ var ZModelLinker = class extends import_langium8.DefaultLinker {
|
|
|
7453
7452
|
};
|
|
7454
7453
|
|
|
7455
7454
|
// src/zmodel-scope.ts
|
|
7456
|
-
var
|
|
7455
|
+
var import_langium8 = require("langium");
|
|
7457
7456
|
var import_ts_pattern3 = require("ts-pattern");
|
|
7458
|
-
var ZModelScopeComputation = class extends
|
|
7457
|
+
var ZModelScopeComputation = class extends import_langium8.DefaultScopeComputation {
|
|
7459
7458
|
static {
|
|
7460
7459
|
__name(this, "ZModelScopeComputation");
|
|
7461
7460
|
}
|
|
@@ -7465,9 +7464,9 @@ var ZModelScopeComputation = class extends import_langium9.DefaultScopeComputati
|
|
|
7465
7464
|
}
|
|
7466
7465
|
async computeExports(document, cancelToken) {
|
|
7467
7466
|
const result = await super.computeExports(document, cancelToken);
|
|
7468
|
-
for (const node of
|
|
7467
|
+
for (const node of import_langium8.AstUtils.streamAllContents(document.parseResult.value)) {
|
|
7469
7468
|
if (cancelToken) {
|
|
7470
|
-
await (0,
|
|
7469
|
+
await (0, import_langium8.interruptAndCheck)(cancelToken);
|
|
7471
7470
|
}
|
|
7472
7471
|
if (isEnumField(node)) {
|
|
7473
7472
|
const desc = this.services.workspace.AstNodeDescriptionProvider.createDescription(node, node.name, document);
|
|
@@ -7480,7 +7479,7 @@ var ZModelScopeComputation = class extends import_langium9.DefaultScopeComputati
|
|
|
7480
7479
|
super.processNode(node, document, scopes);
|
|
7481
7480
|
}
|
|
7482
7481
|
};
|
|
7483
|
-
var ZModelScopeProvider = class extends
|
|
7482
|
+
var ZModelScopeProvider = class extends import_langium8.DefaultScopeProvider {
|
|
7484
7483
|
static {
|
|
7485
7484
|
__name(this, "ZModelScopeProvider");
|
|
7486
7485
|
}
|
|
@@ -7489,19 +7488,19 @@ var ZModelScopeProvider = class extends import_langium9.DefaultScopeProvider {
|
|
|
7489
7488
|
super(services), this.services = services;
|
|
7490
7489
|
}
|
|
7491
7490
|
getGlobalScope(referenceType, context) {
|
|
7492
|
-
const model =
|
|
7491
|
+
const model = import_langium8.AstUtils.getContainerOfType(context.container, isModel);
|
|
7493
7492
|
if (!model) {
|
|
7494
|
-
return
|
|
7493
|
+
return import_langium8.EMPTY_SCOPE;
|
|
7495
7494
|
}
|
|
7496
7495
|
const importedUris = model.imports.map(resolveImportUri).filter((url) => !!url);
|
|
7497
7496
|
const importedElements = this.indexManager.allElements(referenceType).filter((des) => (
|
|
7498
7497
|
// allow current document
|
|
7499
|
-
|
|
7498
|
+
import_langium8.UriUtils.equals(des.documentUri, model.$document?.uri) || // allow stdlib
|
|
7500
7499
|
des.documentUri.path.endsWith(STD_LIB_MODULE_NAME) || // allow plugin models
|
|
7501
7500
|
des.documentUri.path.endsWith(PLUGIN_MODULE_NAME) || // allow imported documents
|
|
7502
|
-
importedUris.some((importedUri) =>
|
|
7501
|
+
importedUris.some((importedUri) => import_langium8.UriUtils.equals(des.documentUri, importedUri))
|
|
7503
7502
|
));
|
|
7504
|
-
return new
|
|
7503
|
+
return new import_langium8.StreamScope(importedElements);
|
|
7505
7504
|
}
|
|
7506
7505
|
getScope(context) {
|
|
7507
7506
|
if (isMemberAccessExpr(context.container) && context.container.operand && context.property === "member") {
|
|
@@ -7521,14 +7520,14 @@ var ZModelScopeProvider = class extends import_langium9.DefaultScopeProvider {
|
|
|
7521
7520
|
const node = context.container;
|
|
7522
7521
|
const allowTypeDefScope = (
|
|
7523
7522
|
// isAuthOrAuthMemberAccess(node.operand) ||
|
|
7524
|
-
!!
|
|
7523
|
+
!!import_langium8.AstUtils.getContainerOfType(node, isTypeDef)
|
|
7525
7524
|
);
|
|
7526
7525
|
return (0, import_ts_pattern3.match)(node.operand).when(isReferenceExpr, (operand) => {
|
|
7527
7526
|
const ref = operand.target.ref;
|
|
7528
7527
|
if (isDataModelField(ref) || isTypeDefField(ref)) {
|
|
7529
7528
|
return this.createScopeForContainer(ref.type.reference?.ref, globalScope, allowTypeDefScope);
|
|
7530
7529
|
}
|
|
7531
|
-
return
|
|
7530
|
+
return import_langium8.EMPTY_SCOPE;
|
|
7532
7531
|
}).when(isMemberAccessExpr, (operand) => {
|
|
7533
7532
|
const ref = operand.member.ref;
|
|
7534
7533
|
if (isDataModelField(ref) && !ref.type.array) {
|
|
@@ -7537,7 +7536,7 @@ var ZModelScopeProvider = class extends import_langium9.DefaultScopeProvider {
|
|
|
7537
7536
|
if (isTypeDefField(ref) && !ref.type.array) {
|
|
7538
7537
|
return this.createScopeForContainer(ref.type.reference?.ref, globalScope, allowTypeDefScope);
|
|
7539
7538
|
}
|
|
7540
|
-
return
|
|
7539
|
+
return import_langium8.EMPTY_SCOPE;
|
|
7541
7540
|
}).when(isThisExpr, () => {
|
|
7542
7541
|
return this.createScopeForContainingModel(node, globalScope);
|
|
7543
7542
|
}).when(isInvocationExpr, (operand) => {
|
|
@@ -7547,8 +7546,8 @@ var ZModelScopeProvider = class extends import_langium9.DefaultScopeProvider {
|
|
|
7547
7546
|
if (isFutureInvocation(operand)) {
|
|
7548
7547
|
return this.createScopeForContainingModel(node, globalScope);
|
|
7549
7548
|
}
|
|
7550
|
-
return
|
|
7551
|
-
}).otherwise(() =>
|
|
7549
|
+
return import_langium8.EMPTY_SCOPE;
|
|
7550
|
+
}).otherwise(() => import_langium8.EMPTY_SCOPE);
|
|
7552
7551
|
}
|
|
7553
7552
|
getCollectionPredicateScope(context, collectionPredicate) {
|
|
7554
7553
|
const referenceType = this.reflection.getReferenceType(context);
|
|
@@ -7560,30 +7559,30 @@ var ZModelScopeProvider = class extends import_langium9.DefaultScopeProvider {
|
|
|
7560
7559
|
if (isDataModelField(ref) || isTypeDefField(ref)) {
|
|
7561
7560
|
return this.createScopeForContainer(ref.type.reference?.ref, globalScope, allowTypeDefScope);
|
|
7562
7561
|
}
|
|
7563
|
-
return
|
|
7562
|
+
return import_langium8.EMPTY_SCOPE;
|
|
7564
7563
|
}).when(isMemberAccessExpr, (expr) => {
|
|
7565
7564
|
const ref = expr.member.ref;
|
|
7566
7565
|
if (isDataModelField(ref) || isTypeDefField(ref)) {
|
|
7567
7566
|
return this.createScopeForContainer(ref.type.reference?.ref, globalScope, allowTypeDefScope);
|
|
7568
7567
|
}
|
|
7569
|
-
return
|
|
7568
|
+
return import_langium8.EMPTY_SCOPE;
|
|
7570
7569
|
}).when(isInvocationExpr, (expr) => {
|
|
7571
7570
|
const returnTypeDecl = expr.function.ref?.returnType.reference?.ref;
|
|
7572
7571
|
if (isDataModel(returnTypeDecl)) {
|
|
7573
7572
|
return this.createScopeForContainer(returnTypeDecl, globalScope, allowTypeDefScope);
|
|
7574
7573
|
} else {
|
|
7575
|
-
return
|
|
7574
|
+
return import_langium8.EMPTY_SCOPE;
|
|
7576
7575
|
}
|
|
7577
7576
|
}).when(isAuthInvocation, (expr) => {
|
|
7578
7577
|
return this.createScopeForAuth(expr, globalScope);
|
|
7579
|
-
}).otherwise(() =>
|
|
7578
|
+
}).otherwise(() => import_langium8.EMPTY_SCOPE);
|
|
7580
7579
|
}
|
|
7581
7580
|
createScopeForContainingModel(node, globalScope) {
|
|
7582
|
-
const model =
|
|
7581
|
+
const model = import_langium8.AstUtils.getContainerOfType(node, isDataModel);
|
|
7583
7582
|
if (model) {
|
|
7584
7583
|
return this.createScopeForContainer(model, globalScope);
|
|
7585
7584
|
} else {
|
|
7586
|
-
return
|
|
7585
|
+
return import_langium8.EMPTY_SCOPE;
|
|
7587
7586
|
}
|
|
7588
7587
|
}
|
|
7589
7588
|
createScopeForContainer(node, globalScope, includeTypeDefScope = false) {
|
|
@@ -7592,16 +7591,16 @@ var ZModelScopeProvider = class extends import_langium9.DefaultScopeProvider {
|
|
|
7592
7591
|
} else if (includeTypeDefScope && isTypeDef(node)) {
|
|
7593
7592
|
return this.createScopeForNodes(node.fields, globalScope);
|
|
7594
7593
|
} else {
|
|
7595
|
-
return
|
|
7594
|
+
return import_langium8.EMPTY_SCOPE;
|
|
7596
7595
|
}
|
|
7597
7596
|
}
|
|
7598
7597
|
createScopeForAuth(node, globalScope) {
|
|
7599
|
-
const decls = getAllLoadedAndReachableDataModelsAndTypeDefs(this.services.shared.workspace.LangiumDocuments,
|
|
7598
|
+
const decls = getAllLoadedAndReachableDataModelsAndTypeDefs(this.services.shared.workspace.LangiumDocuments, import_langium8.AstUtils.getContainerOfType(node, isDataModel));
|
|
7600
7599
|
const authDecl = getAuthDecl(decls);
|
|
7601
7600
|
if (authDecl) {
|
|
7602
7601
|
return this.createScopeForContainer(authDecl, globalScope, true);
|
|
7603
7602
|
} else {
|
|
7604
|
-
return
|
|
7603
|
+
return import_langium8.EMPTY_SCOPE;
|
|
7605
7604
|
}
|
|
7606
7605
|
}
|
|
7607
7606
|
};
|
|
@@ -7618,12 +7617,12 @@ function getCollectionPredicateContext(node) {
|
|
|
7618
7617
|
__name(getCollectionPredicateContext, "getCollectionPredicateContext");
|
|
7619
7618
|
|
|
7620
7619
|
// src/zmodel-workspace-manager.ts
|
|
7621
|
-
var
|
|
7620
|
+
var import_langium9 = require("langium");
|
|
7622
7621
|
var import_node_fs2 = __toESM(require("fs"), 1);
|
|
7623
7622
|
var import_node_path = __toESM(require("path"), 1);
|
|
7624
7623
|
var import_node_url = require("url");
|
|
7625
7624
|
var import_meta = {};
|
|
7626
|
-
var ZModelWorkspaceManager = class extends
|
|
7625
|
+
var ZModelWorkspaceManager = class extends import_langium9.DefaultWorkspaceManager {
|
|
7627
7626
|
static {
|
|
7628
7627
|
__name(this, "ZModelWorkspaceManager");
|
|
7629
7628
|
}
|
|
@@ -7651,7 +7650,7 @@ var ZModelWorkspaceManager = class extends import_langium10.DefaultWorkspaceMana
|
|
|
7651
7650
|
console.log(`Found installed zenstack package stdlib at: ${installedStdlibPath}`);
|
|
7652
7651
|
break;
|
|
7653
7652
|
}
|
|
7654
|
-
} catch
|
|
7653
|
+
} catch {
|
|
7655
7654
|
continue;
|
|
7656
7655
|
}
|
|
7657
7656
|
}
|
|
@@ -7662,7 +7661,7 @@ var ZModelWorkspaceManager = class extends import_langium10.DefaultWorkspaceMana
|
|
|
7662
7661
|
stdLibPath = import_node_path.default.join(_dirname, "../res", STD_LIB_MODULE_NAME);
|
|
7663
7662
|
console.log(`Using bundled stdlib in extension:`, stdLibPath);
|
|
7664
7663
|
}
|
|
7665
|
-
const stdlib = await this.documentFactory.fromUri(
|
|
7664
|
+
const stdlib = await this.documentFactory.fromUri(import_langium9.URI.file(stdLibPath));
|
|
7666
7665
|
collector(stdlib);
|
|
7667
7666
|
}
|
|
7668
7667
|
};
|
|
@@ -7684,8 +7683,8 @@ var ZModelSharedModule = {
|
|
|
7684
7683
|
}
|
|
7685
7684
|
};
|
|
7686
7685
|
function createZModelLanguageServices(context) {
|
|
7687
|
-
const shared = (0,
|
|
7688
|
-
const ZModelLanguage = (0,
|
|
7686
|
+
const shared = (0, import_langium10.inject)((0, import_lsp.createDefaultSharedModule)(context), ZModelGeneratedSharedModule, ZModelSharedModule);
|
|
7687
|
+
const ZModelLanguage = (0, import_langium10.inject)((0, import_lsp.createDefaultModule)({
|
|
7689
7688
|
shared
|
|
7690
7689
|
}), ZModelGeneratedModule, ZModelLanguageModule);
|
|
7691
7690
|
shared.ServiceRegistry.register(ZModelLanguage);
|
|
@@ -7736,10 +7735,10 @@ async function loadDocument(fileName, pluginModelFiles = []) {
|
|
|
7736
7735
|
};
|
|
7737
7736
|
}
|
|
7738
7737
|
const _dirname = typeof __dirname !== "undefined" ? __dirname : import_node_path2.default.dirname((0, import_node_url2.fileURLToPath)(import_meta2.url));
|
|
7739
|
-
const stdLib = await services.shared.workspace.LangiumDocuments.getOrCreateDocument(
|
|
7740
|
-
const pluginDocs = await Promise.all(pluginModelFiles.map((file) => services.shared.workspace.LangiumDocuments.getOrCreateDocument(
|
|
7738
|
+
const stdLib = await services.shared.workspace.LangiumDocuments.getOrCreateDocument(import_langium11.URI.file(import_node_path2.default.resolve(import_node_path2.default.join(_dirname, "../res", STD_LIB_MODULE_NAME))));
|
|
7739
|
+
const pluginDocs = await Promise.all(pluginModelFiles.map((file) => services.shared.workspace.LangiumDocuments.getOrCreateDocument(import_langium11.URI.file(import_node_path2.default.resolve(file)))));
|
|
7741
7740
|
const langiumDocuments = services.shared.workspace.LangiumDocuments;
|
|
7742
|
-
const document = await langiumDocuments.getOrCreateDocument(
|
|
7741
|
+
const document = await langiumDocuments.getOrCreateDocument(import_langium11.URI.file(import_node_path2.default.resolve(fileName)));
|
|
7743
7742
|
await services.shared.workspace.DocumentBuilder.build([
|
|
7744
7743
|
stdLib,
|
|
7745
7744
|
...pluginDocs,
|