Skip to content

Commit 993108a

Browse files
committed
fix(language): ref resolution failure causes exception in validator
1 parent 9bf6d7f commit 993108a

File tree

2 files changed

+13
-9
lines changed

2 files changed

+13
-9
lines changed

packages/ide/vscode/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "zenstack-v3",
33
"publisher": "zenstack",
4-
"version": "3.0.6",
4+
"version": "3.0.8",
55
"displayName": "ZenStack V3 Language Tools",
66
"description": "VSCode extension for ZenStack (v3) ZModel language",
77
"private": true,

packages/language/src/utils.ts

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -517,13 +517,15 @@ export function getAllFields(
517517

518518
const fields: DataField[] = [];
519519
for (const mixin of decl.mixins) {
520-
invariant(mixin.ref, `Mixin ${mixin.$refText} is not resolved`);
521-
fields.push(...getAllFields(mixin.ref, includeIgnored, seen));
520+
if (mixin.ref) {
521+
fields.push(...getAllFields(mixin.ref, includeIgnored, seen));
522+
}
522523
}
523524

524525
if (isDataModel(decl) && decl.baseModel) {
525-
invariant(decl.baseModel.ref, `Base model ${decl.baseModel.$refText} is not resolved`);
526-
fields.push(...getAllFields(decl.baseModel.ref, includeIgnored, seen));
526+
if (decl.baseModel.ref) {
527+
fields.push(...getAllFields(decl.baseModel.ref, includeIgnored, seen));
528+
}
527529
}
528530

529531
fields.push(...decl.fields.filter((f) => includeIgnored || !hasAttribute(f, '@ignore')));
@@ -541,13 +543,15 @@ export function getAllAttributes(
541543

542544
const attributes: DataModelAttribute[] = [];
543545
for (const mixin of decl.mixins) {
544-
invariant(mixin.ref, `Mixin ${mixin.$refText} is not resolved`);
545-
attributes.push(...getAllAttributes(mixin.ref, seen));
546+
if (mixin.ref) {
547+
attributes.push(...getAllAttributes(mixin.ref, seen));
548+
}
546549
}
547550

548551
if (isDataModel(decl) && decl.baseModel) {
549-
invariant(decl.baseModel.ref, `Base model ${decl.baseModel.$refText} is not resolved`);
550-
attributes.push(...getAllAttributes(decl.baseModel.ref, seen));
552+
if (decl.baseModel.ref) {
553+
attributes.push(...getAllAttributes(decl.baseModel.ref, seen));
554+
}
551555
}
552556

553557
attributes.push(...decl.attributes);

0 commit comments

Comments
 (0)