sysml-validate 0.17.0 → 0.18.0
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/out/main.js +1013 -644
- package/out/main.js.map +4 -4
- package/package.json +1 -1
- package/resources/sysml.dimension-table.json +1 -1
- package/resources/sysml.library.index.json +1 -1
package/out/main.js
CHANGED
|
@@ -57816,229 +57816,640 @@ function asDiagnosticLevel(value, fallback = "off") {
|
|
|
57816
57816
|
return value === "off" || value === "warning" || value === "error" ? value : fallback;
|
|
57817
57817
|
}
|
|
57818
57818
|
|
|
57819
|
-
// ../language-server/out/src/services/
|
|
57820
|
-
var
|
|
57821
|
-
|
|
57822
|
-
|
|
57823
|
-
|
|
57819
|
+
// ../language-server/out/src/services/requirement-eval.js
|
|
57820
|
+
var UNRESOLVED = { kind: "unresolved" };
|
|
57821
|
+
var INCONCLUSIVE = { kind: "inconclusive" };
|
|
57822
|
+
var NULL_VALUE = { kind: "null" };
|
|
57823
|
+
var REDEFINE_KINDS = /* @__PURE__ */ new Set([":>>", ":>", "redefines", "subsets"]);
|
|
57824
|
+
function declaresFeature(node, name) {
|
|
57825
|
+
if (node.name === name)
|
|
57826
|
+
return true;
|
|
57827
|
+
for (const rel of [...node.preRelationships ?? [], ...node.relationships ?? []]) {
|
|
57828
|
+
if (rel.kind && REDEFINE_KINDS.has(rel.kind) && (rel.targets ?? []).includes(name))
|
|
57829
|
+
return true;
|
|
57824
57830
|
}
|
|
57825
|
-
|
|
57826
|
-
|
|
57827
|
-
|
|
57828
|
-
|
|
57829
|
-
|
|
57830
|
-
|
|
57831
|
-
|
|
57832
|
-
|
|
57833
|
-
|
|
57834
|
-
|
|
57835
|
-
|
|
57836
|
-
|
|
57837
|
-
|
|
57838
|
-
|
|
57839
|
-
|
|
57840
|
-
|
|
57841
|
-
|
|
57842
|
-
|
|
57831
|
+
return false;
|
|
57832
|
+
}
|
|
57833
|
+
function evaluateExpr(node, scope, ext) {
|
|
57834
|
+
if (!node)
|
|
57835
|
+
return INCONCLUSIVE;
|
|
57836
|
+
const extended = ext?.(node, (child) => evaluateExpr(child, scope, ext));
|
|
57837
|
+
if (extended)
|
|
57838
|
+
return extended;
|
|
57839
|
+
const n = node;
|
|
57840
|
+
switch (n.$type) {
|
|
57841
|
+
case "NumericPrimary":
|
|
57842
|
+
return typeof n.numVal === "number" ? { kind: "number", value: n.numVal } : INCONCLUSIVE;
|
|
57843
|
+
case "LiteralBool":
|
|
57844
|
+
return { kind: "boolean", value: n.value === "true" };
|
|
57845
|
+
case "LiteralStr":
|
|
57846
|
+
return { kind: "string", value: decodeStringLiteral(String(n.value ?? "")) };
|
|
57847
|
+
case "LiteralNull":
|
|
57848
|
+
return INCONCLUSIVE;
|
|
57849
|
+
case "ParenExpr": {
|
|
57850
|
+
const items = n.items ?? [];
|
|
57851
|
+
return items.length === 1 ? evaluateExpr(items[0], scope, ext) : INCONCLUSIVE;
|
|
57843
57852
|
}
|
|
57853
|
+
case "UnaryMinusExpr": {
|
|
57854
|
+
const v = evaluateExpr(n.operand, scope, ext);
|
|
57855
|
+
return v.kind === "number" ? { kind: "number", value: -v.value } : passThrough(v);
|
|
57856
|
+
}
|
|
57857
|
+
case "UnaryPlusExpr":
|
|
57858
|
+
return evaluateExpr(n.operand, scope, ext);
|
|
57859
|
+
case "NotExpr": {
|
|
57860
|
+
if (!n.operand)
|
|
57861
|
+
return INCONCLUSIVE;
|
|
57862
|
+
const v = evaluateExpr(n.operand, scope, ext);
|
|
57863
|
+
return v.kind === "boolean" ? { kind: "boolean", value: !v.value } : passThrough(v);
|
|
57864
|
+
}
|
|
57865
|
+
case "PathExpr":
|
|
57866
|
+
return scope(String(n.path).split("."));
|
|
57867
|
+
case "IfExpr": {
|
|
57868
|
+
const cond = evaluateExpr(n.cond, scope, ext);
|
|
57869
|
+
if (cond.kind !== "boolean")
|
|
57870
|
+
return passThrough(cond);
|
|
57871
|
+
return cond.value ? evaluateExpr(n.thenExpr, scope, ext) : evaluateExpr(n.elseExpr, scope, ext);
|
|
57872
|
+
}
|
|
57873
|
+
case "PostfixOp": {
|
|
57874
|
+
if (n.unit && n.unitValue)
|
|
57875
|
+
return evaluateExpr(n.unitValue, scope, ext);
|
|
57876
|
+
if (n.operand)
|
|
57877
|
+
return evaluateExpr(n.operand, scope, ext);
|
|
57878
|
+
return INCONCLUSIVE;
|
|
57879
|
+
}
|
|
57880
|
+
case "BinExpr":
|
|
57881
|
+
return evaluateBin(n, scope, ext);
|
|
57882
|
+
default:
|
|
57883
|
+
return INCONCLUSIVE;
|
|
57844
57884
|
}
|
|
57845
|
-
named(name) {
|
|
57846
|
-
return this.byName.get(name) ?? EMPTY_DESCRIPTIONS;
|
|
57847
|
-
}
|
|
57848
|
-
firstNamed(name) {
|
|
57849
|
-
return this.byName.get(name)?.[0];
|
|
57850
|
-
}
|
|
57851
|
-
membersOf(path10, wildcard) {
|
|
57852
|
-
const map3 = wildcard === "shallow" ? this.directMembers : this.nestedMembers;
|
|
57853
|
-
return map3.get(path10) ?? EMPTY_DESCRIPTIONS;
|
|
57854
|
-
}
|
|
57855
|
-
};
|
|
57856
|
-
var EMPTY_DESCRIPTIONS = [];
|
|
57857
|
-
function push(map3, key, desc) {
|
|
57858
|
-
const list = map3.get(key);
|
|
57859
|
-
if (list)
|
|
57860
|
-
list.push(desc);
|
|
57861
|
-
else
|
|
57862
|
-
map3.set(key, [desc]);
|
|
57863
57885
|
}
|
|
57864
|
-
function
|
|
57865
|
-
|
|
57866
|
-
expandImportInto(imp, GlobalDescriptionIndex.from(globalDescriptions), out, options, /* @__PURE__ */ new Set());
|
|
57867
|
-
return dedupeEntries(out);
|
|
57886
|
+
function passThrough(v) {
|
|
57887
|
+
return v.kind === "unresolved" ? UNRESOLVED : INCONCLUSIVE;
|
|
57868
57888
|
}
|
|
57869
|
-
function
|
|
57870
|
-
|
|
57871
|
-
|
|
57872
|
-
|
|
57873
|
-
segments.push(seg.name);
|
|
57889
|
+
function decodeStringLiteral(raw) {
|
|
57890
|
+
let body = raw;
|
|
57891
|
+
if (body.length >= 2 && body.startsWith('"') && body.endsWith('"')) {
|
|
57892
|
+
body = body.slice(1, -1);
|
|
57874
57893
|
}
|
|
57875
|
-
return
|
|
57894
|
+
return body.replace(/\\(.)/gu, (_m, ch) => {
|
|
57895
|
+
switch (ch) {
|
|
57896
|
+
case "n":
|
|
57897
|
+
return "\n";
|
|
57898
|
+
case "t":
|
|
57899
|
+
return " ";
|
|
57900
|
+
case "b":
|
|
57901
|
+
return "\b";
|
|
57902
|
+
case "f":
|
|
57903
|
+
return "\f";
|
|
57904
|
+
default:
|
|
57905
|
+
return ch;
|
|
57906
|
+
}
|
|
57907
|
+
});
|
|
57876
57908
|
}
|
|
57877
|
-
function
|
|
57878
|
-
|
|
57879
|
-
|
|
57880
|
-
|
|
57881
|
-
|
|
57882
|
-
|
|
57883
|
-
|
|
57909
|
+
function evaluateBin(node, scope, ext) {
|
|
57910
|
+
const op = String(node.op);
|
|
57911
|
+
const left = evaluateExpr(node.left, scope, ext);
|
|
57912
|
+
if (op === "and" || op === "&") {
|
|
57913
|
+
if (left.kind === "boolean" && !left.value)
|
|
57914
|
+
return { kind: "boolean", value: false };
|
|
57915
|
+
} else if (op === "or" || op === "|") {
|
|
57916
|
+
if (left.kind === "boolean" && left.value)
|
|
57917
|
+
return { kind: "boolean", value: true };
|
|
57918
|
+
} else if (op === "implies") {
|
|
57919
|
+
if (left.kind === "boolean" && !left.value)
|
|
57920
|
+
return { kind: "boolean", value: true };
|
|
57884
57921
|
}
|
|
57885
|
-
|
|
57886
|
-
|
|
57887
|
-
|
|
57888
|
-
|
|
57889
|
-
|
|
57890
|
-
|
|
57891
|
-
|
|
57892
|
-
|
|
57893
|
-
|
|
57894
|
-
|
|
57895
|
-
|
|
57896
|
-
|
|
57897
|
-
|
|
57898
|
-
|
|
57899
|
-
|
|
57900
|
-
|
|
57901
|
-
|
|
57902
|
-
|
|
57903
|
-
|
|
57904
|
-
|
|
57905
|
-
|
|
57906
|
-
|
|
57907
|
-
|
|
57908
|
-
|
|
57909
|
-
|
|
57910
|
-
|
|
57911
|
-
|
|
57912
|
-
|
|
57913
|
-
|
|
57914
|
-
|
|
57915
|
-
|
|
57916
|
-
|
|
57917
|
-
|
|
57918
|
-
out.push({ name: alias, targetName: targetDesc.name, description: targetDesc });
|
|
57922
|
+
const right = evaluateExpr(node.right, scope, ext);
|
|
57923
|
+
if (left.kind === "unresolved" || right.kind === "unresolved")
|
|
57924
|
+
return UNRESOLVED;
|
|
57925
|
+
if (left.kind === "inconclusive" || right.kind === "inconclusive")
|
|
57926
|
+
return INCONCLUSIVE;
|
|
57927
|
+
switch (op) {
|
|
57928
|
+
case "+":
|
|
57929
|
+
case "-":
|
|
57930
|
+
case "*":
|
|
57931
|
+
case "/":
|
|
57932
|
+
case "%":
|
|
57933
|
+
case "**":
|
|
57934
|
+
case "^":
|
|
57935
|
+
if (left.kind === "number" && right.kind === "number") {
|
|
57936
|
+
return { kind: "number", value: arith(op, left.value, right.value) };
|
|
57937
|
+
}
|
|
57938
|
+
return INCONCLUSIVE;
|
|
57939
|
+
case "<":
|
|
57940
|
+
case ">":
|
|
57941
|
+
case "<=":
|
|
57942
|
+
case ">=":
|
|
57943
|
+
if (left.kind === "number" && right.kind === "number") {
|
|
57944
|
+
return { kind: "boolean", value: compare(op, left.value, right.value) };
|
|
57945
|
+
}
|
|
57946
|
+
return INCONCLUSIVE;
|
|
57947
|
+
case "==":
|
|
57948
|
+
case "!=":
|
|
57949
|
+
case "===":
|
|
57950
|
+
case "!==": {
|
|
57951
|
+
const eq3 = valuesEqual(left, right);
|
|
57952
|
+
if (eq3 === void 0)
|
|
57953
|
+
return INCONCLUSIVE;
|
|
57954
|
+
return { kind: "boolean", value: op.startsWith("!") ? !eq3 : eq3 };
|
|
57919
57955
|
}
|
|
57920
|
-
|
|
57921
|
-
|
|
57922
|
-
|
|
57956
|
+
case "and":
|
|
57957
|
+
case "&":
|
|
57958
|
+
return bothBool(left, right, (a2, b) => a2 && b);
|
|
57959
|
+
case "or":
|
|
57960
|
+
case "|":
|
|
57961
|
+
return bothBool(left, right, (a2, b) => a2 || b);
|
|
57962
|
+
case "xor":
|
|
57963
|
+
return bothBool(left, right, (a2, b) => a2 !== b);
|
|
57964
|
+
case "implies":
|
|
57965
|
+
return bothBool(left, right, (a2, b) => !a2 || b);
|
|
57966
|
+
default:
|
|
57967
|
+
return INCONCLUSIVE;
|
|
57923
57968
|
}
|
|
57924
|
-
applyImportFilters(imp, out, start, options);
|
|
57925
57969
|
}
|
|
57926
|
-
function
|
|
57927
|
-
|
|
57928
|
-
|
|
57929
|
-
|
|
57930
|
-
|
|
57931
|
-
|
|
57932
|
-
|
|
57933
|
-
|
|
57934
|
-
|
|
57935
|
-
|
|
57936
|
-
|
|
57970
|
+
function arith(op, a2, b) {
|
|
57971
|
+
switch (op) {
|
|
57972
|
+
case "+":
|
|
57973
|
+
return a2 + b;
|
|
57974
|
+
case "-":
|
|
57975
|
+
return a2 - b;
|
|
57976
|
+
case "*":
|
|
57977
|
+
return a2 * b;
|
|
57978
|
+
case "/":
|
|
57979
|
+
return a2 / b;
|
|
57980
|
+
case "%":
|
|
57981
|
+
return a2 % b;
|
|
57982
|
+
case "**":
|
|
57983
|
+
case "^":
|
|
57984
|
+
return a2 ** b;
|
|
57985
|
+
default:
|
|
57986
|
+
return NaN;
|
|
57937
57987
|
}
|
|
57938
|
-
out.length = start;
|
|
57939
|
-
out.push(...kept);
|
|
57940
57988
|
}
|
|
57941
|
-
function
|
|
57942
|
-
|
|
57943
|
-
|
|
57944
|
-
|
|
57945
|
-
|
|
57989
|
+
function compare(op, a2, b) {
|
|
57990
|
+
switch (op) {
|
|
57991
|
+
case "<":
|
|
57992
|
+
return a2 < b;
|
|
57993
|
+
case ">":
|
|
57994
|
+
return a2 > b;
|
|
57995
|
+
case "<=":
|
|
57996
|
+
return a2 <= b;
|
|
57997
|
+
case ">=":
|
|
57998
|
+
return a2 >= b;
|
|
57999
|
+
default:
|
|
57946
58000
|
return false;
|
|
57947
58001
|
}
|
|
57948
|
-
return true;
|
|
57949
58002
|
}
|
|
57950
|
-
function
|
|
57951
|
-
if (
|
|
57952
|
-
|
|
57953
|
-
|
|
57954
|
-
return
|
|
57955
|
-
|
|
57956
|
-
|
|
57957
|
-
|
|
57958
|
-
return
|
|
57959
|
-
|
|
57960
|
-
|
|
57961
|
-
|
|
57962
|
-
|
|
57963
|
-
|
|
57964
|
-
|
|
57965
|
-
|
|
57966
|
-
|
|
57967
|
-
|
|
57968
|
-
|
|
57969
|
-
|
|
57970
|
-
|
|
57971
|
-
if (
|
|
57972
|
-
|
|
57973
|
-
|
|
57974
|
-
|
|
57975
|
-
|
|
57976
|
-
return
|
|
58003
|
+
function valuesEqual(a2, b) {
|
|
58004
|
+
if (a2.kind === "null" || b.kind === "null")
|
|
58005
|
+
return a2.kind === b.kind;
|
|
58006
|
+
if (a2.kind === "number" && b.kind === "number")
|
|
58007
|
+
return a2.value === b.value;
|
|
58008
|
+
if (a2.kind === "boolean" && b.kind === "boolean")
|
|
58009
|
+
return a2.value === b.value;
|
|
58010
|
+
if (a2.kind === "string" && b.kind === "string")
|
|
58011
|
+
return a2.value === b.value;
|
|
58012
|
+
return void 0;
|
|
58013
|
+
}
|
|
58014
|
+
function bothBool(a2, b, f) {
|
|
58015
|
+
if (a2.kind === "boolean" && b.kind === "boolean")
|
|
58016
|
+
return { kind: "boolean", value: f(a2.value, b.value) };
|
|
58017
|
+
return INCONCLUSIVE;
|
|
58018
|
+
}
|
|
58019
|
+
function memberNamed(node, name, seen = /* @__PURE__ */ new Set()) {
|
|
58020
|
+
if (!node || seen.has(node))
|
|
58021
|
+
return void 0;
|
|
58022
|
+
seen.add(node);
|
|
58023
|
+
for (const member of node.members ?? []) {
|
|
58024
|
+
if (member.value !== void 0 && declaresFeature(member, name))
|
|
58025
|
+
return member;
|
|
58026
|
+
}
|
|
58027
|
+
for (const member of node.members ?? []) {
|
|
58028
|
+
if (declaresFeature(member, name))
|
|
58029
|
+
return member;
|
|
58030
|
+
}
|
|
58031
|
+
const typeRef = node.typing?.type?.ref;
|
|
58032
|
+
return typeRef ? memberNamed(typeRef, name, seen) : void 0;
|
|
58033
|
+
}
|
|
58034
|
+
function resolveFeatureValue(root3, segments) {
|
|
58035
|
+
let cur = root3;
|
|
58036
|
+
for (const seg of segments) {
|
|
58037
|
+
cur = memberNamed(cur, seg);
|
|
58038
|
+
if (!cur)
|
|
58039
|
+
return UNRESOLVED;
|
|
58040
|
+
}
|
|
58041
|
+
if (cur.value)
|
|
58042
|
+
return evaluateExpr(cur.value, () => INCONCLUSIVE);
|
|
58043
|
+
return INCONCLUSIVE;
|
|
58044
|
+
}
|
|
58045
|
+
function subjectScope(subjectName, subjectBinding) {
|
|
58046
|
+
const binding = subjectBinding;
|
|
58047
|
+
return (segments) => {
|
|
58048
|
+
if (!binding)
|
|
58049
|
+
return INCONCLUSIVE;
|
|
58050
|
+
if (subjectName && segments[0] === subjectName) {
|
|
58051
|
+
const rest = segments.slice(1);
|
|
58052
|
+
if (rest.length === 0)
|
|
58053
|
+
return INCONCLUSIVE;
|
|
58054
|
+
return resolveFeatureValue(binding, rest);
|
|
58055
|
+
}
|
|
58056
|
+
return resolveFeatureValue(binding, segments);
|
|
58057
|
+
};
|
|
58058
|
+
}
|
|
58059
|
+
function subjectNameOf(req) {
|
|
58060
|
+
const subject = (req.members ?? []).find((m) => m.$type === "SubjectDecl");
|
|
58061
|
+
return subject?.name;
|
|
58062
|
+
}
|
|
58063
|
+
function gatherConstraints(req) {
|
|
58064
|
+
const out = [];
|
|
58065
|
+
for (const member of req.members ?? []) {
|
|
58066
|
+
if (member.$type === "RequireConstraintStmt" && member.body) {
|
|
58067
|
+
out.push({ kind: "require", body: member.body, text: exprText(member.body) });
|
|
58068
|
+
} else if (member.$type === "AssumeConstraintStmt" && member.body) {
|
|
58069
|
+
out.push({ kind: "assume", body: member.body, text: exprText(member.body) });
|
|
57977
58070
|
}
|
|
58071
|
+
}
|
|
58072
|
+
return out;
|
|
58073
|
+
}
|
|
58074
|
+
function exprText(node) {
|
|
58075
|
+
return node.$cstNode?.text?.trim() ?? "";
|
|
58076
|
+
}
|
|
58077
|
+
function evaluateRequirement(req, subjectBinding) {
|
|
58078
|
+
const requirement = req;
|
|
58079
|
+
const subjectName = subjectNameOf(requirement);
|
|
58080
|
+
const scope = subjectScope(subjectName, subjectBinding);
|
|
58081
|
+
const constraints = gatherConstraints(requirement);
|
|
58082
|
+
const details = [];
|
|
58083
|
+
let sawInconclusive = false;
|
|
58084
|
+
let sawUnresolved = false;
|
|
58085
|
+
let failed = false;
|
|
58086
|
+
for (const c of constraints) {
|
|
58087
|
+
const v = evaluateExpr(c.body, scope);
|
|
58088
|
+
let status2;
|
|
58089
|
+
if (v.kind === "unresolved") {
|
|
58090
|
+
status2 = "unresolved";
|
|
58091
|
+
sawUnresolved = true;
|
|
58092
|
+
} else if (v.kind !== "boolean") {
|
|
58093
|
+
status2 = "inconclusive";
|
|
58094
|
+
sawInconclusive = true;
|
|
58095
|
+
} else if (v.value) {
|
|
58096
|
+
status2 = "pass";
|
|
58097
|
+
} else if (c.kind === "require") {
|
|
58098
|
+
status2 = "fail";
|
|
58099
|
+
failed = true;
|
|
58100
|
+
} else {
|
|
58101
|
+
status2 = "inconclusive";
|
|
58102
|
+
sawInconclusive = true;
|
|
58103
|
+
}
|
|
58104
|
+
details.push({ kind: c.kind, status: status2, text: c.text });
|
|
58105
|
+
}
|
|
58106
|
+
let status;
|
|
58107
|
+
if (constraints.length === 0)
|
|
58108
|
+
status = "inconclusive";
|
|
58109
|
+
else if (failed)
|
|
58110
|
+
status = "fail";
|
|
58111
|
+
else if (sawUnresolved)
|
|
58112
|
+
status = "unresolved";
|
|
58113
|
+
else if (sawInconclusive)
|
|
58114
|
+
status = "inconclusive";
|
|
58115
|
+
else
|
|
58116
|
+
status = "pass";
|
|
58117
|
+
return { status, details };
|
|
58118
|
+
}
|
|
58119
|
+
function bindingName(by) {
|
|
58120
|
+
const n = by;
|
|
58121
|
+
if (n?.$type !== "PathExpr")
|
|
57978
58122
|
return void 0;
|
|
58123
|
+
return n.path?.split(/::|\./).pop();
|
|
58124
|
+
}
|
|
58125
|
+
function evaluateVerificationCase(caseNode, resolveRequirement, resolvePart) {
|
|
58126
|
+
const node = caseNode;
|
|
58127
|
+
const subject = (node.members ?? []).find((m) => m.$type === "SubjectDecl");
|
|
58128
|
+
const subjectBoundName = bindingName(subject?.value);
|
|
58129
|
+
const subjectBinding = (subjectBoundName ? resolvePart(subjectBoundName) : void 0) ?? subject;
|
|
58130
|
+
const verifies = [];
|
|
58131
|
+
for (const member of node.members ?? []) {
|
|
58132
|
+
if (member.$type !== "VerifyStmt")
|
|
58133
|
+
continue;
|
|
58134
|
+
const targetName = String(member.target ?? "").split(/::|\./).pop();
|
|
58135
|
+
if (!targetName)
|
|
58136
|
+
continue;
|
|
58137
|
+
const req = resolveRequirement(targetName);
|
|
58138
|
+
if (!req) {
|
|
58139
|
+
verifies.push({ requirement: targetName, status: "unresolved" });
|
|
58140
|
+
continue;
|
|
58141
|
+
}
|
|
58142
|
+
const boundName = bindingName(member.by);
|
|
58143
|
+
const binding = (boundName ? resolvePart(boundName) : void 0) ?? subjectBinding;
|
|
58144
|
+
verifies.push({ requirement: targetName, status: evaluateRequirement(req, binding).status });
|
|
57979
58145
|
}
|
|
57980
|
-
|
|
58146
|
+
let status = "inconclusive";
|
|
58147
|
+
if (verifies.length === 0)
|
|
58148
|
+
status = "inconclusive";
|
|
58149
|
+
else if (verifies.some((v) => v.status === "fail"))
|
|
58150
|
+
status = "fail";
|
|
58151
|
+
else if (verifies.some((v) => v.status === "unresolved"))
|
|
58152
|
+
status = "error";
|
|
58153
|
+
else if (verifies.some((v) => v.status === "inconclusive"))
|
|
58154
|
+
status = "inconclusive";
|
|
58155
|
+
else
|
|
58156
|
+
status = "pass";
|
|
58157
|
+
return { status, verifies };
|
|
57981
58158
|
}
|
|
57982
|
-
|
|
57983
|
-
|
|
57984
|
-
|
|
58159
|
+
|
|
58160
|
+
// ../language-server/out/src/services/metadata-filter.js
|
|
58161
|
+
var INCONCLUSIVE2 = { kind: "inconclusive" };
|
|
58162
|
+
var SPECIALIZATION_KINDS = /* @__PURE__ */ new Set([":>", "specializes", ":>>", "redefines", "subsets"]);
|
|
58163
|
+
var MAX_SPECIALIZATION_DEPTH = 32;
|
|
58164
|
+
var MAX_VALUE_DEPTH = 16;
|
|
58165
|
+
function evaluateFilterCondition(condition, element, options) {
|
|
57985
58166
|
if (!condition)
|
|
57986
58167
|
return void 0;
|
|
57987
|
-
|
|
57988
|
-
|
|
58168
|
+
const ctx = {
|
|
58169
|
+
element,
|
|
58170
|
+
options,
|
|
58171
|
+
metadata: attachedMetadata(element)
|
|
58172
|
+
};
|
|
58173
|
+
const value = evaluateExpr(condition, nameScope(ctx), extensionFor(ctx));
|
|
58174
|
+
return value.kind === "boolean" ? value.value : void 0;
|
|
58175
|
+
}
|
|
58176
|
+
function extensionFor(ctx) {
|
|
58177
|
+
const ext = (node, evaluate2) => {
|
|
58178
|
+
switch (node.$type) {
|
|
58179
|
+
case "SelfClassifyExpr":
|
|
58180
|
+
return classify(node, ctx);
|
|
58181
|
+
case "LiteralNull":
|
|
58182
|
+
return NULL_VALUE;
|
|
58183
|
+
case "PostfixOp":
|
|
58184
|
+
return featureAccess(node, ctx, ext);
|
|
58185
|
+
default:
|
|
58186
|
+
return void 0;
|
|
58187
|
+
}
|
|
58188
|
+
};
|
|
58189
|
+
return ext;
|
|
58190
|
+
}
|
|
58191
|
+
function classify(node, ctx) {
|
|
58192
|
+
const op = node.op;
|
|
58193
|
+
if (op === "@" || op === "@@" || op === "as" || op === "meta") {
|
|
58194
|
+
const found = findMetadata(node.type, ctx);
|
|
58195
|
+
return found === "unknown" ? INCONCLUSIVE2 : { kind: "boolean", value: found !== void 0 };
|
|
57989
58196
|
}
|
|
57990
|
-
if (
|
|
57991
|
-
return
|
|
58197
|
+
if (op === "istype" || op === "hastype")
|
|
58198
|
+
return classifyByType(op, node.type, ctx);
|
|
58199
|
+
return INCONCLUSIVE2;
|
|
58200
|
+
}
|
|
58201
|
+
function featureAccess(node, ctx, ext) {
|
|
58202
|
+
const segments = [];
|
|
58203
|
+
let cur = node;
|
|
58204
|
+
while (cur?.$type === "PostfixOp") {
|
|
58205
|
+
const postfix = cur;
|
|
58206
|
+
if (!(postfix.dot || postfix.select) || !postfix.field)
|
|
58207
|
+
return void 0;
|
|
58208
|
+
segments.unshift(postfix.field);
|
|
58209
|
+
cur = postfix.target;
|
|
57992
58210
|
}
|
|
57993
|
-
|
|
58211
|
+
const root3 = unwrapParen(cur);
|
|
58212
|
+
const rootOp = root3?.op;
|
|
58213
|
+
if (root3?.$type !== "SelfClassifyExpr" || !rootOp)
|
|
57994
58214
|
return void 0;
|
|
57995
|
-
if (
|
|
57996
|
-
return
|
|
58215
|
+
if (rootOp !== "as" && rootOp !== "meta" && rootOp !== "@" && rootOp !== "@@")
|
|
58216
|
+
return void 0;
|
|
58217
|
+
const found = findMetadata(root3.type, ctx);
|
|
58218
|
+
if (found === "unknown")
|
|
58219
|
+
return INCONCLUSIVE2;
|
|
58220
|
+
if (found === void 0)
|
|
58221
|
+
return NULL_VALUE;
|
|
58222
|
+
if (!found.annotation)
|
|
58223
|
+
return INCONCLUSIVE2;
|
|
58224
|
+
return metadataFeatureValue(found.annotation, segments, ctx, ext);
|
|
58225
|
+
}
|
|
58226
|
+
function metadataFeatureValue(annotation, segments, ctx, ext, depth = 0) {
|
|
58227
|
+
if (segments.length === 0 || depth > MAX_VALUE_DEPTH)
|
|
58228
|
+
return INCONCLUSIVE2;
|
|
58229
|
+
const [head2, ...rest] = segments;
|
|
58230
|
+
const definition = typeNodeOf(annotation, ctx);
|
|
58231
|
+
const member = memberNamed2(annotation, head2, ctx) ?? memberNamed2(definition, head2, ctx);
|
|
58232
|
+
if (!member)
|
|
58233
|
+
return INCONCLUSIVE2;
|
|
58234
|
+
if (rest.length > 0)
|
|
58235
|
+
return metadataFeatureValue(member, rest, ctx, ext, depth + 1);
|
|
58236
|
+
if (member.value)
|
|
58237
|
+
return evaluateExpr(member.value, nameScope(ctx), ext);
|
|
58238
|
+
return NULL_VALUE;
|
|
58239
|
+
}
|
|
58240
|
+
function memberNamed2(owner, name, ctx, depth = 0) {
|
|
58241
|
+
if (!owner || depth > MAX_SPECIALIZATION_DEPTH)
|
|
58242
|
+
return void 0;
|
|
58243
|
+
const members = owner.members ?? [];
|
|
58244
|
+
for (const member of members) {
|
|
58245
|
+
if (member.value !== void 0 && declaresFeature2(member, name))
|
|
58246
|
+
return member;
|
|
57997
58247
|
}
|
|
57998
|
-
|
|
57999
|
-
if (
|
|
58000
|
-
return
|
|
58001
|
-
}
|
|
58002
|
-
return { node: condition, construct: `the '${condition.op}' operator` };
|
|
58248
|
+
for (const member of members) {
|
|
58249
|
+
if (declaresFeature2(member, name))
|
|
58250
|
+
return member;
|
|
58003
58251
|
}
|
|
58004
|
-
|
|
58252
|
+
for (const target of specializationTargets(owner)) {
|
|
58253
|
+
const resolved = ctx.options.resolveName?.(target);
|
|
58254
|
+
const inherited = memberNamed2(resolved, name, ctx, depth + 1);
|
|
58255
|
+
if (inherited)
|
|
58256
|
+
return inherited;
|
|
58257
|
+
}
|
|
58258
|
+
const typed = typeNodeOf(owner, ctx);
|
|
58259
|
+
return typed ? memberNamed2(typed, name, ctx, depth + 1) : void 0;
|
|
58005
58260
|
}
|
|
58006
|
-
function
|
|
58007
|
-
if (
|
|
58008
|
-
|
|
58009
|
-
|
|
58010
|
-
if (
|
|
58011
|
-
return
|
|
58012
|
-
return "this postfix expression";
|
|
58261
|
+
function declaresFeature2(node, name) {
|
|
58262
|
+
if (node.name === name)
|
|
58263
|
+
return true;
|
|
58264
|
+
for (const rel of [...node.preRelationships ?? [], ...node.relationships ?? []]) {
|
|
58265
|
+
if (rel.kind && SPECIALIZATION_KINDS.has(rel.kind) && (rel.targets ?? []).includes(name))
|
|
58266
|
+
return true;
|
|
58013
58267
|
}
|
|
58014
|
-
|
|
58015
|
-
return "a plain feature reference";
|
|
58016
|
-
return "this expression form";
|
|
58268
|
+
return false;
|
|
58017
58269
|
}
|
|
58018
|
-
function
|
|
58019
|
-
|
|
58020
|
-
if (!Array.isArray(siblings))
|
|
58021
|
-
return [];
|
|
58022
|
-
const index = siblings.indexOf(node);
|
|
58023
|
-
if (index < 0)
|
|
58270
|
+
function attachedMetadata(node) {
|
|
58271
|
+
if (!node)
|
|
58024
58272
|
return [];
|
|
58025
|
-
const
|
|
58026
|
-
for (
|
|
58027
|
-
|
|
58028
|
-
|
|
58029
|
-
|
|
58030
|
-
|
|
58273
|
+
const found = [];
|
|
58274
|
+
for (const member of node.members ?? []) {
|
|
58275
|
+
if (member.$type === "MetadataAnnotation")
|
|
58276
|
+
addMetadata(found, member, member.type);
|
|
58277
|
+
}
|
|
58278
|
+
const container = node.$container;
|
|
58279
|
+
if (container?.$type === "PrefixMetadataMember") {
|
|
58280
|
+
for (const tag of container.tags ?? [])
|
|
58281
|
+
addMetadata(found, void 0, tag.type);
|
|
58031
58282
|
}
|
|
58032
|
-
|
|
58283
|
+
found.push(...container ? annotationsByMember(container).get(node) ?? [] : []);
|
|
58284
|
+
return found;
|
|
58033
58285
|
}
|
|
58034
|
-
function
|
|
58035
|
-
|
|
58036
|
-
|
|
58037
|
-
|
|
58038
|
-
|
|
58039
|
-
|
|
58040
|
-
|
|
58041
|
-
|
|
58286
|
+
function addMetadata(found, annotation, type) {
|
|
58287
|
+
if (type)
|
|
58288
|
+
found.push({ annotation, type });
|
|
58289
|
+
}
|
|
58290
|
+
var annotationsByContainer = /* @__PURE__ */ new WeakMap();
|
|
58291
|
+
function annotationsByMember(container) {
|
|
58292
|
+
const cached = annotationsByContainer.get(container);
|
|
58293
|
+
if (cached)
|
|
58294
|
+
return cached;
|
|
58295
|
+
const byMember = /* @__PURE__ */ new Map();
|
|
58296
|
+
const byName = /* @__PURE__ */ new Map();
|
|
58297
|
+
const attach = (member, entry) => {
|
|
58298
|
+
const list = byMember.get(member);
|
|
58299
|
+
if (list)
|
|
58300
|
+
list.push(entry);
|
|
58301
|
+
else
|
|
58302
|
+
byMember.set(member, [entry]);
|
|
58303
|
+
};
|
|
58304
|
+
const members = container.members ?? [];
|
|
58305
|
+
let pending = [];
|
|
58306
|
+
for (const member of members) {
|
|
58307
|
+
if (member.$type === "MetadataAnnotation" || member.$type === "MetadataDecl") {
|
|
58308
|
+
const type = member.$type === "MetadataAnnotation" ? member.type : member.typing?.type;
|
|
58309
|
+
if (!type)
|
|
58310
|
+
continue;
|
|
58311
|
+
const entry = { annotation: member, type };
|
|
58312
|
+
const targets = member.targets ?? [];
|
|
58313
|
+
if (targets.length > 0) {
|
|
58314
|
+
for (const target of targets) {
|
|
58315
|
+
const simple = target.split(/::|\./).pop();
|
|
58316
|
+
if (!simple)
|
|
58317
|
+
continue;
|
|
58318
|
+
const list = byName.get(simple);
|
|
58319
|
+
if (list)
|
|
58320
|
+
list.push(entry);
|
|
58321
|
+
else
|
|
58322
|
+
byName.set(simple, [entry]);
|
|
58323
|
+
}
|
|
58324
|
+
} else if (member.$type === "MetadataAnnotation") {
|
|
58325
|
+
pending.push(entry);
|
|
58326
|
+
}
|
|
58327
|
+
continue;
|
|
58328
|
+
}
|
|
58329
|
+
for (const entry of pending)
|
|
58330
|
+
attach(member, entry);
|
|
58331
|
+
pending = [];
|
|
58332
|
+
}
|
|
58333
|
+
if (byName.size > 0) {
|
|
58334
|
+
for (const member of members) {
|
|
58335
|
+
const entries = member.name ? byName.get(member.name) : void 0;
|
|
58336
|
+
if (entries)
|
|
58337
|
+
for (const entry of entries)
|
|
58338
|
+
attach(member, entry);
|
|
58339
|
+
}
|
|
58340
|
+
}
|
|
58341
|
+
annotationsByContainer.set(container, byMember);
|
|
58342
|
+
return byMember;
|
|
58343
|
+
}
|
|
58344
|
+
function findMetadata(type, ctx) {
|
|
58345
|
+
if (!type)
|
|
58346
|
+
return "unknown";
|
|
58347
|
+
for (const meta of ctx.metadata) {
|
|
58348
|
+
if (metadataMatches(type, meta, ctx))
|
|
58349
|
+
return meta;
|
|
58350
|
+
}
|
|
58351
|
+
if (metaclassMatches(type, ctx))
|
|
58352
|
+
return { type };
|
|
58353
|
+
return ctx.element ? void 0 : "unknown";
|
|
58354
|
+
}
|
|
58355
|
+
function metadataMatches(type, meta, ctx) {
|
|
58356
|
+
const filterRef = ctx.options.resolveReferences ? type.ref : void 0;
|
|
58357
|
+
const metaRef = ctx.options.resolveReferences ? meta.type.ref : void 0;
|
|
58358
|
+
if (filterRef && metaRef && filterRef === metaRef)
|
|
58359
|
+
return true;
|
|
58360
|
+
const metaName = meta.type.$refText;
|
|
58361
|
+
if (qualifiedNameMatches(type.$refText, metaName))
|
|
58362
|
+
return true;
|
|
58363
|
+
const metaDefinition = metaRef ?? (metaName ? ctx.options.resolveName?.(metaName) : void 0);
|
|
58364
|
+
return specializes(metaDefinition, type, ctx);
|
|
58365
|
+
}
|
|
58366
|
+
function specializes(node, type, ctx, depth = 0, seen = /* @__PURE__ */ new Set()) {
|
|
58367
|
+
if (!node || depth > MAX_SPECIALIZATION_DEPTH || seen.has(node))
|
|
58368
|
+
return false;
|
|
58369
|
+
seen.add(node);
|
|
58370
|
+
for (const target of specializationTargets(node)) {
|
|
58371
|
+
if (qualifiedNameMatches(type.$refText, target))
|
|
58372
|
+
return true;
|
|
58373
|
+
const resolved = ctx.options.resolveName?.(target);
|
|
58374
|
+
if (resolved && ctx.options.resolveReferences && resolved === type.ref)
|
|
58375
|
+
return true;
|
|
58376
|
+
if (specializes(resolved, type, ctx, depth + 1, seen))
|
|
58377
|
+
return true;
|
|
58378
|
+
}
|
|
58379
|
+
return false;
|
|
58380
|
+
}
|
|
58381
|
+
function metaclassMatches(type, ctx) {
|
|
58382
|
+
if (!ctx.element)
|
|
58383
|
+
return false;
|
|
58384
|
+
const metaclass = metaclassNameOf(ctx.element);
|
|
58385
|
+
const written = type.$refText;
|
|
58386
|
+
if (!written)
|
|
58387
|
+
return false;
|
|
58388
|
+
if (qualifiedNameMatches(written, metaclass))
|
|
58389
|
+
return true;
|
|
58390
|
+
const definition = ctx.options.resolveName?.(`SysML::${metaclass}`) ?? ctx.options.resolveName?.(metaclass);
|
|
58391
|
+
return specializes(definition, type, ctx);
|
|
58392
|
+
}
|
|
58393
|
+
function metaclassNameOf(node) {
|
|
58394
|
+
if (isPackage(node))
|
|
58395
|
+
return "Package";
|
|
58396
|
+
const type = node.$type.endsWith("Decl") ? node.$type.slice(0, -"Decl".length) : node.$type;
|
|
58397
|
+
const isDef = node.isDef;
|
|
58398
|
+
if (typeof isDef === "boolean")
|
|
58399
|
+
return `${type}${isDef ? "Definition" : "Usage"}`;
|
|
58400
|
+
return type;
|
|
58401
|
+
}
|
|
58402
|
+
function classifyByType(op, type, ctx) {
|
|
58403
|
+
if (!type || !ctx.element)
|
|
58404
|
+
return INCONCLUSIVE2;
|
|
58405
|
+
const declared = ctx.element.typing?.type;
|
|
58406
|
+
if (!declared)
|
|
58407
|
+
return INCONCLUSIVE2;
|
|
58408
|
+
if (qualifiedNameMatches(type.$refText, declared.$refText))
|
|
58409
|
+
return { kind: "boolean", value: true };
|
|
58410
|
+
if (ctx.options.resolveReferences && type.ref && declared.ref === type.ref)
|
|
58411
|
+
return { kind: "boolean", value: true };
|
|
58412
|
+
if (op === "hastype")
|
|
58413
|
+
return { kind: "boolean", value: false };
|
|
58414
|
+
const declaredNode = (ctx.options.resolveReferences ? declared.ref : void 0) ?? (declared.$refText ? ctx.options.resolveName?.(declared.$refText) : void 0);
|
|
58415
|
+
if (!declaredNode)
|
|
58416
|
+
return INCONCLUSIVE2;
|
|
58417
|
+
return { kind: "boolean", value: specializes(declaredNode, type, ctx) };
|
|
58418
|
+
}
|
|
58419
|
+
function nameScope(ctx, depth = 0) {
|
|
58420
|
+
return (segments) => {
|
|
58421
|
+
if (depth > MAX_VALUE_DEPTH)
|
|
58422
|
+
return INCONCLUSIVE2;
|
|
58423
|
+
const resolved = ctx.options.resolveName?.(segments.join("::"));
|
|
58424
|
+
if (!resolved?.value)
|
|
58425
|
+
return INCONCLUSIVE2;
|
|
58426
|
+
return evaluateExpr(resolved.value, nameScope(ctx, depth + 1), extensionFor(ctx));
|
|
58427
|
+
};
|
|
58428
|
+
}
|
|
58429
|
+
function specializationTargets(node) {
|
|
58430
|
+
const targets = [];
|
|
58431
|
+
for (const rel of [...node.preRelationships ?? [], ...node.relationships ?? []]) {
|
|
58432
|
+
if (rel.kind && SPECIALIZATION_KINDS.has(rel.kind))
|
|
58433
|
+
targets.push(...rel.targets ?? []);
|
|
58434
|
+
}
|
|
58435
|
+
return targets;
|
|
58436
|
+
}
|
|
58437
|
+
function typeNodeOf(node, ctx) {
|
|
58438
|
+
const type = node?.type ?? node?.typing?.type;
|
|
58439
|
+
if (!type)
|
|
58440
|
+
return void 0;
|
|
58441
|
+
const ref = ctx.options.resolveReferences ? type.ref : void 0;
|
|
58442
|
+
return ref ?? (type.$refText ? ctx.options.resolveName?.(type.$refText) : void 0);
|
|
58443
|
+
}
|
|
58444
|
+
function unwrapParen(node) {
|
|
58445
|
+
let cur = node;
|
|
58446
|
+
while (cur?.$type === "ParenExpr") {
|
|
58447
|
+
const items = cur.items ?? [];
|
|
58448
|
+
if (items.length !== 1)
|
|
58449
|
+
return cur;
|
|
58450
|
+
cur = items[0];
|
|
58451
|
+
}
|
|
58452
|
+
return cur;
|
|
58042
58453
|
}
|
|
58043
58454
|
function qualifiedNameMatches(a2, b) {
|
|
58044
58455
|
if (!a2 || !b)
|
|
@@ -58054,32 +58465,253 @@ function qualifiedNameMatches(a2, b) {
|
|
|
58054
58465
|
}
|
|
58055
58466
|
return true;
|
|
58056
58467
|
}
|
|
58057
|
-
|
|
58058
|
-
|
|
58059
|
-
|
|
58060
|
-
|
|
58061
|
-
|
|
58062
|
-
|
|
58063
|
-
|
|
58064
|
-
|
|
58065
|
-
|
|
58066
|
-
|
|
58067
|
-
|
|
58068
|
-
|
|
58069
|
-
|
|
58070
|
-
|
|
58071
|
-
|
|
58072
|
-
|
|
58073
|
-
|
|
58074
|
-
|
|
58075
|
-
|
|
58076
|
-
|
|
58077
|
-
|
|
58078
|
-
|
|
58079
|
-
|
|
58080
|
-
|
|
58081
|
-
|
|
58082
|
-
|
|
58468
|
+
|
|
58469
|
+
// ../language-server/out/src/services/import-visibility.js
|
|
58470
|
+
var GlobalDescriptionIndex = class _GlobalDescriptionIndex {
|
|
58471
|
+
/** Reuse an existing index; wrap a plain list. */
|
|
58472
|
+
static from(source) {
|
|
58473
|
+
return source instanceof _GlobalDescriptionIndex ? source : new _GlobalDescriptionIndex(source);
|
|
58474
|
+
}
|
|
58475
|
+
/** Exact name → descriptions carrying it (qualified and simple names alike). */
|
|
58476
|
+
byName = /* @__PURE__ */ new Map();
|
|
58477
|
+
/** Namespace path → descriptions for its DIRECT members (`A::B` → `A::B::C`). */
|
|
58478
|
+
directMembers = /* @__PURE__ */ new Map();
|
|
58479
|
+
/** Namespace path → descriptions for all its descendants (`A` → `A::B::C`). */
|
|
58480
|
+
nestedMembers = /* @__PURE__ */ new Map();
|
|
58481
|
+
constructor(descriptions) {
|
|
58482
|
+
for (const desc of descriptions) {
|
|
58483
|
+
push(this.byName, desc.name, desc);
|
|
58484
|
+
let sep2 = desc.name.indexOf("::");
|
|
58485
|
+
while (sep2 >= 0) {
|
|
58486
|
+
const prefix = desc.name.slice(0, sep2);
|
|
58487
|
+
push(this.nestedMembers, prefix, desc);
|
|
58488
|
+
const next = desc.name.indexOf("::", sep2 + 2);
|
|
58489
|
+
if (next < 0)
|
|
58490
|
+
push(this.directMembers, prefix, desc);
|
|
58491
|
+
sep2 = next;
|
|
58492
|
+
}
|
|
58493
|
+
}
|
|
58494
|
+
}
|
|
58495
|
+
named(name) {
|
|
58496
|
+
return this.byName.get(name) ?? EMPTY_DESCRIPTIONS;
|
|
58497
|
+
}
|
|
58498
|
+
firstNamed(name) {
|
|
58499
|
+
return this.byName.get(name)?.[0];
|
|
58500
|
+
}
|
|
58501
|
+
membersOf(path10, wildcard) {
|
|
58502
|
+
const map3 = wildcard === "shallow" ? this.directMembers : this.nestedMembers;
|
|
58503
|
+
return map3.get(path10) ?? EMPTY_DESCRIPTIONS;
|
|
58504
|
+
}
|
|
58505
|
+
};
|
|
58506
|
+
var EMPTY_DESCRIPTIONS = [];
|
|
58507
|
+
function push(map3, key, desc) {
|
|
58508
|
+
const list = map3.get(key);
|
|
58509
|
+
if (list)
|
|
58510
|
+
list.push(desc);
|
|
58511
|
+
else
|
|
58512
|
+
map3.set(key, [desc]);
|
|
58513
|
+
}
|
|
58514
|
+
function expandImportEntries(imp, globalDescriptions, options = {}) {
|
|
58515
|
+
const out = [];
|
|
58516
|
+
expandImportInto(imp, GlobalDescriptionIndex.from(globalDescriptions), out, options, /* @__PURE__ */ new Set());
|
|
58517
|
+
return dedupeEntries(out);
|
|
58518
|
+
}
|
|
58519
|
+
function importedPath(imp) {
|
|
58520
|
+
const segments = [imp.head];
|
|
58521
|
+
for (const seg of imp.segs) {
|
|
58522
|
+
if (seg.name)
|
|
58523
|
+
segments.push(seg.name);
|
|
58524
|
+
}
|
|
58525
|
+
return segments.length > 0 ? segments.join("::") : void 0;
|
|
58526
|
+
}
|
|
58527
|
+
function importForm(imp) {
|
|
58528
|
+
let wildcard = "none";
|
|
58529
|
+
let includesSelf = false;
|
|
58530
|
+
const importAll = imp.isImportAll === true;
|
|
58531
|
+
for (const seg of imp.segs) {
|
|
58532
|
+
if (seg.recursive) {
|
|
58533
|
+
wildcard = "recursive";
|
|
58534
|
+
includesSelf = !seg.star;
|
|
58535
|
+
} else if (seg.star) {
|
|
58536
|
+
wildcard = "shallow";
|
|
58537
|
+
includesSelf = false;
|
|
58538
|
+
}
|
|
58539
|
+
}
|
|
58540
|
+
return { wildcard, includesSelf, importAll };
|
|
58541
|
+
}
|
|
58542
|
+
function importWildcard(imp) {
|
|
58543
|
+
return importForm(imp).wildcard;
|
|
58544
|
+
}
|
|
58545
|
+
function importVisibility(imp) {
|
|
58546
|
+
return imp.visibility ?? "private";
|
|
58547
|
+
}
|
|
58548
|
+
function resolveDescription(name, globalDescriptions) {
|
|
58549
|
+
const index = GlobalDescriptionIndex.from(globalDescriptions);
|
|
58550
|
+
const normalized = name.trim();
|
|
58551
|
+
const direct = index.firstNamed(normalized);
|
|
58552
|
+
if (direct)
|
|
58553
|
+
return direct;
|
|
58554
|
+
const simple = normalized.split(/::|\./).pop();
|
|
58555
|
+
return simple ? index.firstNamed(simple) : void 0;
|
|
58556
|
+
}
|
|
58557
|
+
function descriptionKey(description) {
|
|
58558
|
+
return `${description.documentUri.toString()}#${description.path}`;
|
|
58559
|
+
}
|
|
58560
|
+
function namespaceMembers(node) {
|
|
58561
|
+
const n = node;
|
|
58562
|
+
return [...n?.elements ?? [], ...n?.members ?? []];
|
|
58563
|
+
}
|
|
58564
|
+
function expandImportInto(imp, globalDescriptions, out, options, visitedNamespaces) {
|
|
58565
|
+
const path10 = importedPath(imp);
|
|
58566
|
+
if (!path10)
|
|
58567
|
+
return;
|
|
58568
|
+
const start = out.length;
|
|
58569
|
+
const namedSegments = path10.split("::");
|
|
58570
|
+
const form = importForm(imp);
|
|
58571
|
+
if (form.wildcard === "none") {
|
|
58572
|
+
const targetDesc = resolveImportedDescription(path10, globalDescriptions, options, visitedNamespaces, form.importAll);
|
|
58573
|
+
if (targetDesc) {
|
|
58574
|
+
const alias = imp.alias ?? namedSegments[namedSegments.length - 1];
|
|
58575
|
+
if (alias)
|
|
58576
|
+
out.push({ name: alias, targetName: targetDesc.name, description: targetDesc });
|
|
58577
|
+
}
|
|
58578
|
+
} else {
|
|
58579
|
+
out.push(...selectMemberships(path10, form, globalDescriptions));
|
|
58580
|
+
expandNamespaceImports(path10, globalDescriptions, out, options, visitedNamespaces, form.importAll);
|
|
58581
|
+
}
|
|
58582
|
+
applyImportFilters(imp, out, start, options);
|
|
58583
|
+
}
|
|
58584
|
+
function applyImportFilters(imp, out, start, options) {
|
|
58585
|
+
const conditions = filterConditionsFor(imp);
|
|
58586
|
+
if (conditions.length === 0 || out.length === start)
|
|
58587
|
+
return;
|
|
58588
|
+
const kept = keepMatching(conditions, out.slice(start), options);
|
|
58589
|
+
out.length = start;
|
|
58590
|
+
out.push(...kept);
|
|
58591
|
+
}
|
|
58592
|
+
function applyFilters(imp, entries, options = {}) {
|
|
58593
|
+
const conditions = filterConditionsFor(imp);
|
|
58594
|
+
return conditions.length === 0 ? entries : keepMatching(conditions, entries, options);
|
|
58595
|
+
}
|
|
58596
|
+
function keepMatching(conditions, entries, options) {
|
|
58597
|
+
const evalOptions = {
|
|
58598
|
+
resolveReferences: options.resolveReferences !== false,
|
|
58599
|
+
resolveName: options.resolveName
|
|
58600
|
+
};
|
|
58601
|
+
return entries.filter((entry) => {
|
|
58602
|
+
const node = options.nodeOf?.(entry.description) ?? entry.description.node;
|
|
58603
|
+
return !node || conditions.every((c) => evaluateFilterCondition(c, node, evalOptions) !== false);
|
|
58604
|
+
});
|
|
58605
|
+
}
|
|
58606
|
+
function filterConditionsFor(imp) {
|
|
58607
|
+
const conditions = [];
|
|
58608
|
+
const owner = imp.$container;
|
|
58609
|
+
if (governsImportFilters(owner)) {
|
|
58610
|
+
for (const member of namespaceMembers(owner)) {
|
|
58611
|
+
const condition = member.condition;
|
|
58612
|
+
if (member.$type === "FilterMember" && condition)
|
|
58613
|
+
conditions.push(condition);
|
|
58614
|
+
}
|
|
58615
|
+
}
|
|
58616
|
+
for (const filter3 of imp.filters ?? []) {
|
|
58617
|
+
if (filter3.condition)
|
|
58618
|
+
conditions.push(filter3.condition);
|
|
58619
|
+
}
|
|
58620
|
+
return conditions;
|
|
58621
|
+
}
|
|
58622
|
+
function governsImportFilters(owner) {
|
|
58623
|
+
return !!owner && (isPackage(owner) || owner.$type === "Document");
|
|
58624
|
+
}
|
|
58625
|
+
function undecidableFilterCondition(condition, resolveName) {
|
|
58626
|
+
if (!condition)
|
|
58627
|
+
return void 0;
|
|
58628
|
+
if (isSelfClassifyExpr(condition))
|
|
58629
|
+
return void 0;
|
|
58630
|
+
if (isNotExpr(condition) && condition.operand) {
|
|
58631
|
+
return undecidableFilterCondition(condition.operand, resolveName);
|
|
58632
|
+
}
|
|
58633
|
+
if (condition.$type === "NotExpr")
|
|
58634
|
+
return void 0;
|
|
58635
|
+
if (isParenExpr(condition)) {
|
|
58636
|
+
return condition.items.length === 1 ? undecidableFilterCondition(condition.items[0], resolveName) : { node: condition, construct: "a parenthesized expression list" };
|
|
58637
|
+
}
|
|
58638
|
+
if (isBinExpr(condition)) {
|
|
58639
|
+
return undecidableFilterCondition(condition.left, resolveName) ?? undecidableFilterCondition(condition.right, resolveName);
|
|
58640
|
+
}
|
|
58641
|
+
if (isPostfixOp(condition)) {
|
|
58642
|
+
if ((condition.dot || condition.select) && condition.field) {
|
|
58643
|
+
return undecidableFilterCondition(condition.target, resolveName);
|
|
58644
|
+
}
|
|
58645
|
+
if (condition.arrow && condition.invoke)
|
|
58646
|
+
return { node: condition, construct: `the '->${condition.invoke}' invocation` };
|
|
58647
|
+
return { node: condition, construct: "this postfix expression" };
|
|
58648
|
+
}
|
|
58649
|
+
if (isPathExpr(condition)) {
|
|
58650
|
+
const target = resolveName?.(condition.path);
|
|
58651
|
+
return target?.value !== void 0 ? void 0 : { node: condition, construct: "a plain feature reference" };
|
|
58652
|
+
}
|
|
58653
|
+
if (condition.$type === "IfExpr") {
|
|
58654
|
+
const conditional = condition;
|
|
58655
|
+
return undecidableFilterCondition(conditional.cond, resolveName) ?? undecidableFilterCondition(conditional.thenExpr, resolveName) ?? undecidableFilterCondition(conditional.elseExpr, resolveName);
|
|
58656
|
+
}
|
|
58657
|
+
if (DECIDABLE_LITERAL_TYPES.has(condition.$type))
|
|
58658
|
+
return void 0;
|
|
58659
|
+
return { node: condition, construct: "this expression form" };
|
|
58660
|
+
}
|
|
58661
|
+
var DECIDABLE_LITERAL_TYPES = /* @__PURE__ */ new Set([
|
|
58662
|
+
"NumericPrimary",
|
|
58663
|
+
"LiteralBool",
|
|
58664
|
+
"LiteralStr",
|
|
58665
|
+
"LiteralNull"
|
|
58666
|
+
]);
|
|
58667
|
+
function resolveImportedDescription(path10, globalDescriptions, options, visitedNamespaces, importAll = false) {
|
|
58668
|
+
const direct = globalDescriptions.firstNamed(path10);
|
|
58669
|
+
if (direct)
|
|
58670
|
+
return direct;
|
|
58671
|
+
const split = path10.lastIndexOf("::");
|
|
58672
|
+
if (split < 0)
|
|
58673
|
+
return void 0;
|
|
58674
|
+
const ownerPath = path10.slice(0, split);
|
|
58675
|
+
const simpleName2 = path10.slice(split + 2);
|
|
58676
|
+
const exported = [];
|
|
58677
|
+
expandNamespaceImports(ownerPath, globalDescriptions, exported, options, visitedNamespaces, importAll);
|
|
58678
|
+
return exported.find((entry) => entry.name === simpleName2)?.description;
|
|
58679
|
+
}
|
|
58680
|
+
function selectMemberships(path10, form, globalDescriptions) {
|
|
58681
|
+
if (form.wildcard === "none")
|
|
58682
|
+
return [];
|
|
58683
|
+
const index = GlobalDescriptionIndex.from(globalDescriptions);
|
|
58684
|
+
const entries = [];
|
|
58685
|
+
if (form.includesSelf) {
|
|
58686
|
+
const simple = simpleNameOf(path10);
|
|
58687
|
+
const self2 = index.named(path10).find((desc) => form.importAll || !isPrivateDescription(desc));
|
|
58688
|
+
if (self2)
|
|
58689
|
+
entries.push({ name: simple, targetName: self2.name, description: self2 });
|
|
58690
|
+
}
|
|
58691
|
+
const prefixLength = path10.length + 2;
|
|
58692
|
+
for (const desc of index.membersOf(path10, form.wildcard)) {
|
|
58693
|
+
if (!form.importAll && isPrivateDescription(desc))
|
|
58694
|
+
continue;
|
|
58695
|
+
const rest = desc.name.slice(prefixLength);
|
|
58696
|
+
if (!rest)
|
|
58697
|
+
continue;
|
|
58698
|
+
const nested = rest.includes("::");
|
|
58699
|
+
if (nested && !isOwnedMembership(desc))
|
|
58700
|
+
continue;
|
|
58701
|
+
entries.push({ name: nested ? rest.slice(rest.lastIndexOf("::") + 2) : rest, targetName: desc.name, description: desc });
|
|
58702
|
+
}
|
|
58703
|
+
return entries;
|
|
58704
|
+
}
|
|
58705
|
+
function simpleNameOf(path10) {
|
|
58706
|
+
return path10.includes("::") ? path10.slice(path10.lastIndexOf("::") + 2) : path10;
|
|
58707
|
+
}
|
|
58708
|
+
function isOwnedMembership(desc) {
|
|
58709
|
+
const kind = desc.derivedKind;
|
|
58710
|
+
return kind !== "reexport" && kind !== "inherited";
|
|
58711
|
+
}
|
|
58712
|
+
function expandNamespaceImports(path10, globalDescriptions, out, options, visitedNamespaces, importAll = false) {
|
|
58713
|
+
for (const namespaceDesc of globalDescriptions.named(path10)) {
|
|
58714
|
+
const key = descriptionKey(namespaceDesc);
|
|
58083
58715
|
if (visitedNamespaces.has(key))
|
|
58084
58716
|
continue;
|
|
58085
58717
|
visitedNamespaces.add(key);
|
|
@@ -58087,11 +58719,13 @@ function expandNamespaceImports(path10, globalDescriptions, out, options, visite
|
|
|
58087
58719
|
for (const member of namespaceMembers(owner)) {
|
|
58088
58720
|
if (!isImport(member))
|
|
58089
58721
|
continue;
|
|
58090
|
-
|
|
58091
|
-
|
|
58092
|
-
|
|
58093
|
-
|
|
58094
|
-
|
|
58722
|
+
if (!importAll) {
|
|
58723
|
+
const visibility = importVisibility(member);
|
|
58724
|
+
if (visibility === "private")
|
|
58725
|
+
continue;
|
|
58726
|
+
if (visibility === "protected" && !options.protectedNamespaceKeys?.has(key))
|
|
58727
|
+
continue;
|
|
58728
|
+
}
|
|
58095
58729
|
expandImportInto(member, globalDescriptions, out, options, visitedNamespaces);
|
|
58096
58730
|
}
|
|
58097
58731
|
}
|
|
@@ -58505,11 +59139,11 @@ function evaluate(node, mode, ctx) {
|
|
|
58505
59139
|
return { kind: "unknown" };
|
|
58506
59140
|
}
|
|
58507
59141
|
if (isBinExpr(node)) {
|
|
58508
|
-
return
|
|
59142
|
+
return evaluateBin2(node, mode, ctx);
|
|
58509
59143
|
}
|
|
58510
59144
|
return { kind: "unknown" };
|
|
58511
59145
|
}
|
|
58512
|
-
function
|
|
59146
|
+
function evaluateBin2(node, mode, ctx) {
|
|
58513
59147
|
const op = node.op;
|
|
58514
59148
|
const left = evaluate(node.left, mode, ctx);
|
|
58515
59149
|
const right = evaluate(node.right, mode, ctx);
|
|
@@ -58670,13 +59304,26 @@ var DIAGNOSTIC_MESSAGES = {
|
|
|
58670
59304
|
// implicit-redefinition resolution this validator does not yet model.
|
|
58671
59305
|
RES017_DUPLICATE_MEMBER: (name) => `'${name}' is already declared in this namespace. Members must be distinguishable by name \u2014 rename or remove the duplicate.`,
|
|
58672
59306
|
RES017_DUPLICATE_SHORT_NAME: (name) => `Short name '<${name}>' is already used in this namespace. Members must be distinguishable \u2014 rename the short name.`,
|
|
58673
|
-
// issue #102 — REQ-387. The filter evaluator (`
|
|
58674
|
-
// `evaluateFilterCondition`) decides
|
|
58675
|
-
//
|
|
58676
|
-
// open is the right default — under-importing would manufacture
|
|
58677
|
-
// RES001s — but an unevaluated filter produces a scope or view that
|
|
58678
|
-
// authoritative and is not, so the fail-open is stated
|
|
58679
|
-
RES018_UNEVALUATED_FILTER: (subject, construct) => `${subject} filter is not evaluated: ${construct} is outside the metadata-filter evaluator, which decides
|
|
59307
|
+
// issue #102 — REQ-387. The filter evaluator (`metadata-filter.ts`,
|
|
59308
|
+
// `evaluateFilterCondition`) decides the model-level predicate surface; the
|
|
59309
|
+
// invocation and collection forms outside it fail OPEN, keeping the member.
|
|
59310
|
+
// Failing open is the right default — under-importing would manufacture
|
|
59311
|
+
// spurious RES001s — but an unevaluated filter produces a scope or view that
|
|
59312
|
+
// looks authoritative and is not, so the fail-open is stated, not assumed.
|
|
59313
|
+
RES018_UNEVALUATED_FILTER: (subject, construct) => `${subject} filter is not evaluated: ${construct} is outside the metadata-filter evaluator, which decides metadata tests, the classification operators, metadata feature access, and the Boolean, comparison and arithmetic operators over them. The filter fails open \u2014 it is treated as pass-through and removes nothing.`,
|
|
59314
|
+
// issue #154 — OMG SysML v2 Part 1 §7.5.5 (Root Namespace). The root
|
|
59315
|
+
// namespace of a file is anonymous and unnamed, so nothing can import it:
|
|
59316
|
+
// a `public` or `protected` import owned directly by it claims a re-export
|
|
59317
|
+
// no other namespace is able to consume. The Release BNF requires `private`
|
|
59318
|
+
// there, and rewriting it is mechanical — the import keeps working exactly
|
|
59319
|
+
// as it did, since a root import was never re-exported to begin with.
|
|
59320
|
+
RES021_ROOT_IMPORT_VISIBILITY: (visibility) => `An import in a file's root namespace must be 'private' \u2014 nothing can import the root namespace, so '${visibility}' re-exports to no one.`,
|
|
59321
|
+
// issue #153 — OMG SysML v2 Part 1 §7.5.4 (Filtered Packages) puts an element
|
|
59322
|
+
// filter in a package, where it restricts that package's imported memberships;
|
|
59323
|
+
// a view body is the one other place it is defined for (it restricts what the
|
|
59324
|
+
// view exposes). Anywhere else the member parses but nothing consumes it, so
|
|
59325
|
+
// it silently does nothing.
|
|
59326
|
+
KSM012_FILTER_PLACEMENT: (owner) => `A 'filter' member is only meaningful in a package or a view \u2014 it has no effect in a ${owner} body.`,
|
|
58680
59327
|
// REQ-389 — Namespace qualification versus feature chaining in every written path
|
|
58681
59328
|
// issue #213 — the KerML textual BNF binds `::` tighter than `.`: each
|
|
58682
59329
|
// dot-separated link of a FeatureChain is a complete QualifiedName, and only
|
|
@@ -58923,7 +59570,7 @@ function commentBody(text) {
|
|
|
58923
59570
|
return text.slice(2, -2);
|
|
58924
59571
|
return void 0;
|
|
58925
59572
|
}
|
|
58926
|
-
function
|
|
59573
|
+
function classify2(text) {
|
|
58927
59574
|
const body = commentBody(text);
|
|
58928
59575
|
if (body === void 0)
|
|
58929
59576
|
return void 0;
|
|
@@ -58978,7 +59625,7 @@ function scanFormatDirectives(document) {
|
|
|
58978
59625
|
const leaf = leaves[index];
|
|
58979
59626
|
if (!leaf.hidden)
|
|
58980
59627
|
continue;
|
|
58981
|
-
const classified =
|
|
59628
|
+
const classified = classify2(leaf.text);
|
|
58982
59629
|
if (!classified)
|
|
58983
59630
|
continue;
|
|
58984
59631
|
const comment = { offset: leaf.offset, end: leaf.end };
|
|
@@ -59079,6 +59726,8 @@ var SysmlIndexManager = class extends DefaultIndexManager {
|
|
|
59079
59726
|
// REQ-068 — preserve declared visibility for wildcard re-export.
|
|
59080
59727
|
...symbol.isPrivate ? { isPrivate: true } : {},
|
|
59081
59728
|
...symbol.visibility ? { visibility: symbol.visibility } : {},
|
|
59729
|
+
// issue #152 — a re-exported alias is not owned nesting.
|
|
59730
|
+
...symbol.derivedKind ? { derivedKind: symbol.derivedKind } : {},
|
|
59082
59731
|
// REQ-242 — issue #103 — keeps type completion to definitions.
|
|
59083
59732
|
...symbol.isUsage ? { isUsage: true } : {}
|
|
59084
59733
|
};
|
|
@@ -59154,7 +59803,7 @@ function encodeUnrestrictedName(value) {
|
|
|
59154
59803
|
}
|
|
59155
59804
|
|
|
59156
59805
|
// ../language-server/out/src/services/feature-path-resolver.js
|
|
59157
|
-
var
|
|
59806
|
+
var SPECIALIZATION_KINDS2 = /* @__PURE__ */ new Set([":>", ":>>", "specializes", "subsets", "redefines"]);
|
|
59158
59807
|
function nameOf(node) {
|
|
59159
59808
|
const name = node?.name;
|
|
59160
59809
|
if (typeof name === "string" && name.length > 0)
|
|
@@ -59467,7 +60116,7 @@ var FeaturePathResolver = class {
|
|
|
59467
60116
|
const relNode = node;
|
|
59468
60117
|
const result = [];
|
|
59469
60118
|
for (const relation of [...relNode.preRelationships ?? [], ...relNode.relationships ?? []]) {
|
|
59470
|
-
if (!relation.kind || !
|
|
60119
|
+
if (!relation.kind || !SPECIALIZATION_KINDS2.has(relation.kind))
|
|
59471
60120
|
continue;
|
|
59472
60121
|
for (const target of relation.targets ?? []) {
|
|
59473
60122
|
const description = this.pickDescription(snapshot.byName.get(target)) ?? this.pickDescription(snapshot.byName.get(lastSegment2(target)));
|
|
@@ -59493,7 +60142,7 @@ var FeaturePathResolver = class {
|
|
|
59493
60142
|
const candidates = refText ? snapshot.byName.get(refText) ?? snapshot.byName.get(lastSegment2(refText)) : void 0;
|
|
59494
60143
|
return candidates?.length === 1;
|
|
59495
60144
|
}
|
|
59496
|
-
const semanticRelationships = [...record.preRelationships ?? [], ...record.relationships ?? []].filter((relation) => relation.kind &&
|
|
60145
|
+
const semanticRelationships = [...record.preRelationships ?? [], ...record.relationships ?? []].filter((relation) => relation.kind && SPECIALIZATION_KINDS2.has(relation.kind));
|
|
59497
60146
|
return semanticRelationships.length > 0 && semanticRelationships.every((relation) => (relation.targets ?? []).every((target) => Boolean(this.nodeOf(this.pickDescription(snapshot.byName.get(target))) ?? this.nodeOf(this.pickDescription(snapshot.byName.get(lastSegment2(target)))))));
|
|
59498
60147
|
}
|
|
59499
60148
|
followAlias(target, snapshot) {
|
|
@@ -59877,7 +60526,7 @@ function evaluateRepresentation(parser, rep) {
|
|
|
59877
60526
|
}
|
|
59878
60527
|
|
|
59879
60528
|
// ../language-server/out/src/services/conformance.js
|
|
59880
|
-
var
|
|
60529
|
+
var SPECIALIZATION_KINDS3 = /* @__PURE__ */ new Set([
|
|
59881
60530
|
":>",
|
|
59882
60531
|
":>>",
|
|
59883
60532
|
"specializes",
|
|
@@ -59909,7 +60558,7 @@ function specializedNamesOf(node) {
|
|
|
59909
60558
|
const decl = node;
|
|
59910
60559
|
const out = [];
|
|
59911
60560
|
for (const rel of [...decl.preRelationships ?? [], ...decl.relationships ?? []]) {
|
|
59912
|
-
if (!rel.kind || !
|
|
60561
|
+
if (!rel.kind || !SPECIALIZATION_KINDS3.has(rel.kind))
|
|
59913
60562
|
continue;
|
|
59914
60563
|
for (const target of rel.targets ?? []) {
|
|
59915
60564
|
const text = target.trim();
|
|
@@ -60224,7 +60873,7 @@ function maskNonCode(text) {
|
|
|
60224
60873
|
}
|
|
60225
60874
|
return out.join("");
|
|
60226
60875
|
}
|
|
60227
|
-
var
|
|
60876
|
+
var SPECIALIZATION_KINDS4 = /* @__PURE__ */ new Set([":>", ":>>", "specializes", "subsets", "redefines"]);
|
|
60228
60877
|
var CONSTRAINT_SIDE_EFFECT_TYPES = /* @__PURE__ */ new Set([
|
|
60229
60878
|
"AssignNode",
|
|
60230
60879
|
"SendNode",
|
|
@@ -60556,10 +61205,13 @@ var SysmlValidator = class _SysmlValidator {
|
|
|
60556
61205
|
if (!node.visibility) {
|
|
60557
61206
|
accept(severity("SYN067", "error"), "Import visibility is required by the Release syntax; use 'private import' unless re-export is intended.", { node, code: "SYN067" });
|
|
60558
61207
|
}
|
|
61208
|
+
if (node.visibility && node.visibility !== "private" && node.$container?.$type === "Document") {
|
|
61209
|
+
accept(severity("RES021", "error"), DIAGNOSTIC_MESSAGES.RES021_ROOT_IMPORT_VISIBILITY(node.visibility), { node, property: "visibility", code: "RES021" });
|
|
61210
|
+
}
|
|
60559
61211
|
const headStr = node.head ?? "";
|
|
60560
61212
|
const segsStr = node.segs.map((s) => {
|
|
60561
61213
|
if (s.recursive)
|
|
60562
|
-
return "::**";
|
|
61214
|
+
return s.star ? "::*::**" : "::**";
|
|
60563
61215
|
if (s.star)
|
|
60564
61216
|
return "::*";
|
|
60565
61217
|
return `::${s.name ?? ""}`;
|
|
@@ -61575,6 +62227,7 @@ ${baseIndent}}`;
|
|
|
61575
62227
|
const index = this.buildIndex();
|
|
61576
62228
|
const imports = [];
|
|
61577
62229
|
const exposePaths = [];
|
|
62230
|
+
const filterMembers = [];
|
|
61578
62231
|
const decls = [];
|
|
61579
62232
|
const verifyStmts = [];
|
|
61580
62233
|
const satisfyStmts = [];
|
|
@@ -61588,6 +62241,8 @@ ${baseIndent}}`;
|
|
|
61588
62241
|
aliasMap.set(alias, path10);
|
|
61589
62242
|
} else if (isExposePath(child))
|
|
61590
62243
|
exposePaths.push(child);
|
|
62244
|
+
else if (child.$type === "FilterMember")
|
|
62245
|
+
filterMembers.push(child);
|
|
61591
62246
|
else if (isVerifyStmt(child))
|
|
61592
62247
|
verifyStmts.push(child);
|
|
61593
62248
|
else if (isSatisfyStmt(child))
|
|
@@ -61604,7 +62259,7 @@ ${baseIndent}}`;
|
|
|
61604
62259
|
this.checkPrivateImports(imports, index, accept);
|
|
61605
62260
|
this.checkPrivateWildcardReferences(node, imports, index, accept);
|
|
61606
62261
|
this.checkImportCycles(imports, index, accept);
|
|
61607
|
-
this.checkUnevaluatedFilters(imports, exposePaths, accept);
|
|
62262
|
+
this.checkUnevaluatedFilters(imports, exposePaths, filterMembers, index, accept);
|
|
61608
62263
|
if (sysmlDiagnosticSettings.unusedImports !== "off") {
|
|
61609
62264
|
this.checkUnusedImports(node, imports, index, sysmlDiagnosticSettings.unusedImports, accept);
|
|
61610
62265
|
}
|
|
@@ -62032,6 +62687,10 @@ ${baseIndent}}`;
|
|
|
62032
62687
|
if (condition && isDefinitelyNonBoolean(condition)) {
|
|
62033
62688
|
accept(severity("KSM008", "error"), "A filter condition must be a Boolean expression.", { node: child, code: "KSM008" });
|
|
62034
62689
|
}
|
|
62690
|
+
const owner = child.$container;
|
|
62691
|
+
if (owner && !isFilterHost(owner)) {
|
|
62692
|
+
accept(severity("KSM012", "error"), DIAGNOSTIC_MESSAGES.KSM012_FILTER_PLACEMENT(kindLabel(owner)), { node: child, code: "KSM012" });
|
|
62693
|
+
}
|
|
62035
62694
|
}
|
|
62036
62695
|
}
|
|
62037
62696
|
// REQ-328 — KSM006: a type-composition `unions`/`intersects`/`differences`
|
|
@@ -62321,7 +62980,8 @@ ${baseIndent}}`;
|
|
|
62321
62980
|
const node = this.resolveUnique(nsName, index);
|
|
62322
62981
|
const ownsNamespace = node !== void 0 && (isPackage(node) || node.$type === "NamespaceDecl" || (node.members?.length ?? 0) > 0);
|
|
62323
62982
|
if (node && !ownsNamespace) {
|
|
62324
|
-
|
|
62983
|
+
const written = imp.segs.some((s) => s.recursive && s.star) ? `${nsName}::*::**` : `${nsName}::**`;
|
|
62984
|
+
accept(severity("RES007", "error"), `Recursive import '${written}' requires '${nsName}' to be a package, namespace, or usage that owns nested members.`, { node: imp, code: "RES007" });
|
|
62325
62985
|
}
|
|
62326
62986
|
}
|
|
62327
62987
|
// REQ-323 — RES008: an `alias … for X` whose target `X` does not resolve.
|
|
@@ -62448,6 +63108,8 @@ ${baseIndent}}`;
|
|
|
62448
63108
|
// REQ-320 — RES004 importing a private element from outside its namespace
|
|
62449
63109
|
checkPrivateImports(imports, index, accept) {
|
|
62450
63110
|
for (const imp of imports) {
|
|
63111
|
+
if (importForm(imp).importAll)
|
|
63112
|
+
continue;
|
|
62451
63113
|
const path10 = importedPath(imp);
|
|
62452
63114
|
if (!path10)
|
|
62453
63115
|
continue;
|
|
@@ -62470,13 +63132,15 @@ ${baseIndent}}`;
|
|
|
62470
63132
|
// reference so the user learns why a `Pkg::*` did not bring it in.
|
|
62471
63133
|
checkPrivateWildcardReferences(node, imports, index, accept) {
|
|
62472
63134
|
const wildcards = [];
|
|
63135
|
+
const importAllPaths = [];
|
|
62473
63136
|
for (const imp of imports) {
|
|
62474
|
-
const
|
|
62475
|
-
if (
|
|
63137
|
+
const form = importForm(imp);
|
|
63138
|
+
if (form.wildcard === "none")
|
|
62476
63139
|
continue;
|
|
62477
63140
|
const path10 = importedPath(imp);
|
|
62478
|
-
if (path10)
|
|
62479
|
-
|
|
63141
|
+
if (!path10)
|
|
63142
|
+
continue;
|
|
63143
|
+
(form.importAll ? importAllPaths : wildcards).push({ path: path10, recursive: form.wildcard === "recursive" });
|
|
62480
63144
|
}
|
|
62481
63145
|
if (wildcards.length === 0)
|
|
62482
63146
|
return;
|
|
@@ -62497,8 +63161,10 @@ ${baseIndent}}`;
|
|
|
62497
63161
|
const ownerQn = ownerPkg ? qualifiedNameOf(ownerPkg) : void 0;
|
|
62498
63162
|
if (!ownerQn)
|
|
62499
63163
|
continue;
|
|
62500
|
-
const
|
|
62501
|
-
if (!
|
|
63164
|
+
const reaches = (w) => w.recursive ? ownerQn === w.path || ownerQn.startsWith(w.path + "::") : ownerQn === w.path;
|
|
63165
|
+
if (!wildcards.some(reaches))
|
|
63166
|
+
continue;
|
|
63167
|
+
if (importAllPaths.some(reaches))
|
|
62502
63168
|
continue;
|
|
62503
63169
|
const refNode = ref.$refNode?.astNode;
|
|
62504
63170
|
if (refNode && isWithinNamespaceOf(refNode, target))
|
|
@@ -62580,9 +63246,10 @@ ${baseIndent}}`;
|
|
|
62580
63246
|
* unevaluated filter to break a build raise it per code through
|
|
62581
63247
|
* `sysml.validation.severities` (REQ-240).
|
|
62582
63248
|
*/
|
|
62583
|
-
checkUnevaluatedFilters(imports, exposePaths, accept) {
|
|
63249
|
+
checkUnevaluatedFilters(imports, exposePaths, filterMembers, index, accept) {
|
|
63250
|
+
const resolveName = (name) => this.resolveUnique(name, index);
|
|
62584
63251
|
const report = (condition, subject) => {
|
|
62585
|
-
const undecidable = undecidableFilterCondition(condition);
|
|
63252
|
+
const undecidable = undecidableFilterCondition(condition, resolveName);
|
|
62586
63253
|
if (!undecidable)
|
|
62587
63254
|
return;
|
|
62588
63255
|
accept(severity("RES018", "info"), DIAGNOSTIC_MESSAGES.RES018_UNEVALUATED_FILTER(subject, undecidable.construct), { node: undecidable.node, code: "RES018" });
|
|
@@ -62592,6 +63259,11 @@ ${baseIndent}}`;
|
|
|
62592
63259
|
report(filter3.condition, "Import");
|
|
62593
63260
|
for (const path10 of exposePaths)
|
|
62594
63261
|
report(path10.condition, "Expose");
|
|
63262
|
+
for (const member of filterMembers) {
|
|
63263
|
+
if (governsImportFilters(member.$container)) {
|
|
63264
|
+
report(member.condition, "Package");
|
|
63265
|
+
}
|
|
63266
|
+
}
|
|
62595
63267
|
}
|
|
62596
63268
|
// REQ-324 — RES009 unused import (configurable, OFF by default)
|
|
62597
63269
|
checkUnusedImports(root3, imports, index, level, accept) {
|
|
@@ -62612,7 +63284,7 @@ ${baseIndent}}`;
|
|
|
62612
63284
|
return;
|
|
62613
63285
|
const visited = /* @__PURE__ */ new Set();
|
|
62614
63286
|
const reachesSelf = (node) => {
|
|
62615
|
-
for (const targetName of
|
|
63287
|
+
for (const targetName of specializationTargets2(node)) {
|
|
62616
63288
|
const target = this.resolve(targetName, index, node);
|
|
62617
63289
|
if (!target)
|
|
62618
63290
|
continue;
|
|
@@ -62999,14 +63671,14 @@ function shortNameOf(node) {
|
|
|
62999
63671
|
function shortNameNodeOf(node) {
|
|
63000
63672
|
return node.shortName;
|
|
63001
63673
|
}
|
|
63002
|
-
function
|
|
63674
|
+
function specializationTargets2(node) {
|
|
63003
63675
|
const out = [];
|
|
63004
63676
|
const rels = [
|
|
63005
63677
|
...node.preRelationships ?? [],
|
|
63006
63678
|
...node.relationships ?? []
|
|
63007
63679
|
];
|
|
63008
63680
|
for (const rel of rels) {
|
|
63009
|
-
if (rel.kind &&
|
|
63681
|
+
if (rel.kind && SPECIALIZATION_KINDS4.has(rel.kind))
|
|
63010
63682
|
out.push(...rel.targets);
|
|
63011
63683
|
}
|
|
63012
63684
|
return out;
|
|
@@ -63357,7 +64029,13 @@ function introducedNames(imp, index, nodeOf) {
|
|
|
63357
64029
|
const protectedNamespaceKeys = protectedNamespaceKeysFor(imp.$container, globalDescs, nodeOf);
|
|
63358
64030
|
return expandImportEntries(imp, globalDescs, {
|
|
63359
64031
|
nodeOf,
|
|
63360
|
-
protectedNamespaceKeys
|
|
64032
|
+
protectedNamespaceKeys,
|
|
64033
|
+
// issue #153 — filters may need a metadata definition's default value or
|
|
64034
|
+
// a specialization chain; both are index lookups, not cross-references.
|
|
64035
|
+
resolveName: (name) => {
|
|
64036
|
+
const description = globalDescs.firstNamed(name);
|
|
64037
|
+
return description ? nodeOf(description) : void 0;
|
|
64038
|
+
}
|
|
63361
64039
|
}).map((entry) => ({
|
|
63362
64040
|
simple: entry.name,
|
|
63363
64041
|
targetQn: entry.targetName,
|
|
@@ -63378,13 +64056,13 @@ function protectedNamespaceKeysFor(context, globalDescs, nodeOf) {
|
|
|
63378
64056
|
const node = nodeOf(desc);
|
|
63379
64057
|
if (!node || !isDeclLike(node))
|
|
63380
64058
|
return;
|
|
63381
|
-
for (const inherited of
|
|
64059
|
+
for (const inherited of specializationTargets2(node))
|
|
63382
64060
|
collect(inherited);
|
|
63383
64061
|
};
|
|
63384
64062
|
let cur = context;
|
|
63385
64063
|
while (cur) {
|
|
63386
64064
|
if (isDeclLike(cur)) {
|
|
63387
|
-
for (const target of
|
|
64065
|
+
for (const target of specializationTargets2(cur))
|
|
63388
64066
|
collect(target);
|
|
63389
64067
|
}
|
|
63390
64068
|
cur = cur.$container;
|
|
@@ -63438,6 +64116,15 @@ function importIsUsed(imp, index, usedFull, usedFirst, nodeOf) {
|
|
|
63438
64116
|
}
|
|
63439
64117
|
return false;
|
|
63440
64118
|
}
|
|
64119
|
+
var FILTER_HOST_TYPES = /* @__PURE__ */ new Set([
|
|
64120
|
+
"ViewDecl",
|
|
64121
|
+
"ViewpointDecl",
|
|
64122
|
+
"RenderingDecl",
|
|
64123
|
+
"Document"
|
|
64124
|
+
]);
|
|
64125
|
+
function isFilterHost(owner) {
|
|
64126
|
+
return isPackage(owner) || FILTER_HOST_TYPES.has(owner.$type);
|
|
64127
|
+
}
|
|
63441
64128
|
function kindLabel(node) {
|
|
63442
64129
|
const m = /^([A-Z][a-z]+)Decl$/.exec(node.$type);
|
|
63443
64130
|
return m ? m[1].toLowerCase() : node.$type;
|
|
@@ -63941,7 +64628,7 @@ function outlineGroupForType(astType) {
|
|
|
63941
64628
|
}
|
|
63942
64629
|
|
|
63943
64630
|
// ../language-server/out/src/services/document-symbol-provider.js
|
|
63944
|
-
var
|
|
64631
|
+
var SPECIALIZATION_KINDS5 = /* @__PURE__ */ new Set([":>", "specializes"]);
|
|
63945
64632
|
var REDEFINITION_KINDS = /* @__PURE__ */ new Set([":>>", "redefines"]);
|
|
63946
64633
|
var INHERITABLE_FEATURE_TYPES = /* @__PURE__ */ new Set([
|
|
63947
64634
|
"ActionDecl",
|
|
@@ -64006,11 +64693,11 @@ function buildLocalSymbolIndex(root3) {
|
|
|
64006
64693
|
}
|
|
64007
64694
|
return symbols;
|
|
64008
64695
|
}
|
|
64009
|
-
function
|
|
64696
|
+
function specializationTargets3(node) {
|
|
64010
64697
|
const n = node;
|
|
64011
64698
|
const out = [];
|
|
64012
64699
|
for (const rel of [...n.preRelationships ?? [], ...n.relationships ?? []]) {
|
|
64013
|
-
if (rel.kind &&
|
|
64700
|
+
if (rel.kind && SPECIALIZATION_KINDS5.has(rel.kind))
|
|
64014
64701
|
out.push(...rel.targets ?? []);
|
|
64015
64702
|
}
|
|
64016
64703
|
return out;
|
|
@@ -64129,7 +64816,7 @@ function inheritedFeatureSymbols(node, inheritedRange, context, seen = /* @__PUR
|
|
|
64129
64816
|
return [];
|
|
64130
64817
|
seen.add(node);
|
|
64131
64818
|
const symbols = [];
|
|
64132
|
-
for (const targetName of
|
|
64819
|
+
for (const targetName of specializationTargets3(node)) {
|
|
64133
64820
|
const target = resolveLocalTarget(targetName, context);
|
|
64134
64821
|
if (!target || seen.has(target))
|
|
64135
64822
|
continue;
|
|
@@ -64734,7 +65421,7 @@ function nearestAncestor(node, types) {
|
|
|
64734
65421
|
}
|
|
64735
65422
|
return void 0;
|
|
64736
65423
|
}
|
|
64737
|
-
function
|
|
65424
|
+
function exprText2(node) {
|
|
64738
65425
|
return node?.$cstNode?.text?.trim().replace(/\s+/gu, " ") ?? "";
|
|
64739
65426
|
}
|
|
64740
65427
|
function conditionTypeLabel(node) {
|
|
@@ -64745,7 +65432,7 @@ function conditionTypeLabel(node) {
|
|
|
64745
65432
|
if (["AndExpr", "OrExpr", "XorExpr", "NotExpr", "CompareExpr", "ClassifyOp"].includes(node.$type)) {
|
|
64746
65433
|
return "Boolean";
|
|
64747
65434
|
}
|
|
64748
|
-
const text =
|
|
65435
|
+
const text = exprText2(node);
|
|
64749
65436
|
return /\b(true|false)\b|[=!<>]=?|(?:\band\b|\bor\b|\bnot\b|\bxor\b)/u.test(text) ? "Boolean" : "Boolean (expected)";
|
|
64750
65437
|
}
|
|
64751
65438
|
function buildConditionalHover(node) {
|
|
@@ -64759,7 +65446,7 @@ function buildConditionalHover(node) {
|
|
|
64759
65446
|
"",
|
|
64760
65447
|
"Canonical form: `if condition ? thenExpression else elseExpression`",
|
|
64761
65448
|
`Then marker: ${usesQuestion ? "canonical `?`" : "non-canonical `then`; use `?`"}`,
|
|
64762
|
-
`Condition: \`${
|
|
65449
|
+
`Condition: \`${exprText2(n.cond)}\``,
|
|
64763
65450
|
`Condition type: ${conditionTypeLabel(n.cond)}`,
|
|
64764
65451
|
"",
|
|
64765
65452
|
sourceFooter(nodeSource(node))
|
|
@@ -66897,7 +67584,15 @@ var SysmlScopeProvider = class extends DefaultScopeProvider {
|
|
|
66897
67584
|
// metadata `.ref` here re-enters the linker (cyclic reference error,
|
|
66898
67585
|
// and the reference is poisoned with a cached failure). Match filters
|
|
66899
67586
|
// by textual name only on this path; the validator resolves refs.
|
|
66900
|
-
resolveReferences: false
|
|
67587
|
+
resolveReferences: false,
|
|
67588
|
+
// issue #153 — the index lookup a filter needs for a metadata
|
|
67589
|
+
// definition's default, a specialization chain or an enumeration
|
|
67590
|
+
// member. It reads the symbol table rather than a cross-reference,
|
|
67591
|
+
// so it is safe on this path where `.ref` is not.
|
|
67592
|
+
resolveName: (name) => {
|
|
67593
|
+
const description = globalDescs.firstNamed(name);
|
|
67594
|
+
return description ? this.nodeOf(description) : void 0;
|
|
67595
|
+
}
|
|
66901
67596
|
};
|
|
66902
67597
|
const result = [];
|
|
66903
67598
|
for (const imp of this.visibleImportsFrom(contextNode)) {
|
|
@@ -66957,7 +67652,7 @@ var SysmlScopeProvider = class extends DefaultScopeProvider {
|
|
|
66957
67652
|
const visitedTargets = /* @__PURE__ */ new Set();
|
|
66958
67653
|
let cur = contextNode;
|
|
66959
67654
|
while (cur) {
|
|
66960
|
-
for (const target of
|
|
67655
|
+
for (const target of specializationTargets4(cur)) {
|
|
66961
67656
|
this.collectProtectedNamespace(target, globalDescs, keys3, nodes, visitedTargets);
|
|
66962
67657
|
}
|
|
66963
67658
|
cur = cur.$container;
|
|
@@ -66979,7 +67674,7 @@ var SysmlScopeProvider = class extends DefaultScopeProvider {
|
|
|
66979
67674
|
keys3.add(key);
|
|
66980
67675
|
nodes.push(node);
|
|
66981
67676
|
}
|
|
66982
|
-
for (const inherited of
|
|
67677
|
+
for (const inherited of specializationTargets4(node)) {
|
|
66983
67678
|
this.collectProtectedNamespace(inherited, globalDescs, keys3, nodes, visitedTargets);
|
|
66984
67679
|
}
|
|
66985
67680
|
}
|
|
@@ -66998,16 +67693,7 @@ var SysmlScopeProvider = class extends DefaultScopeProvider {
|
|
|
66998
67693
|
// every reference and re-expanded the whole standard library each time
|
|
66999
67694
|
// (measured on a 1 500-line model: 226 misses over 349 references, 16 s).
|
|
67000
67695
|
importContextKey(contextNode, protectedNamespaces) {
|
|
67001
|
-
const
|
|
67002
|
-
let cur = contextNode;
|
|
67003
|
-
while (cur) {
|
|
67004
|
-
for (const member of namespaceMembers(cur)) {
|
|
67005
|
-
if (isImport(member))
|
|
67006
|
-
parts.push(importSignature(member));
|
|
67007
|
-
}
|
|
67008
|
-
cur = cur.$container;
|
|
67009
|
-
}
|
|
67010
|
-
const imports = parts.length > 0 ? parts.join(" ") : "root";
|
|
67696
|
+
const imports = importContextSignature(contextNode);
|
|
67011
67697
|
return protectedNamespaces.key ? `${imports} ${protectedNamespaces.key}` : imports;
|
|
67012
67698
|
}
|
|
67013
67699
|
nodeOf(desc) {
|
|
@@ -67023,6 +67709,23 @@ var SysmlScopeProvider = class extends DefaultScopeProvider {
|
|
|
67023
67709
|
function ownsProtectedImport(node) {
|
|
67024
67710
|
return namespaceMembers(node).some((member) => isImport(member) && importVisibility(member) === "protected");
|
|
67025
67711
|
}
|
|
67712
|
+
function importContextSignature(contextNode) {
|
|
67713
|
+
const parts = [];
|
|
67714
|
+
let cur = contextNode;
|
|
67715
|
+
while (cur) {
|
|
67716
|
+
for (const member of namespaceMembers(cur)) {
|
|
67717
|
+
if (isImport(member))
|
|
67718
|
+
parts.push(importSignature(member));
|
|
67719
|
+
else if (member.$type === "FilterMember")
|
|
67720
|
+
parts.push(filterSignature(member));
|
|
67721
|
+
}
|
|
67722
|
+
cur = cur.$container;
|
|
67723
|
+
}
|
|
67724
|
+
return parts.length > 0 ? parts.join(" ") : "root";
|
|
67725
|
+
}
|
|
67726
|
+
function filterSignature(member) {
|
|
67727
|
+
return `filter ${member.$cstNode?.text?.replace(/\s+/gu, " ").trim() ?? "?"}`;
|
|
67728
|
+
}
|
|
67026
67729
|
function importSignature(imp) {
|
|
67027
67730
|
const text = imp.$cstNode?.text;
|
|
67028
67731
|
if (text)
|
|
@@ -67030,12 +67733,12 @@ function importSignature(imp) {
|
|
|
67030
67733
|
const segments = imp.segs.map((seg) => `${seg.name ?? ""}${seg.star ? "*" : ""}${seg.recursive ? "**" : ""}`);
|
|
67031
67734
|
return `${importVisibility(imp)} ${imp.head}::${segments.join("::")}${imp.alias ? ` as ${imp.alias}` : ""}`;
|
|
67032
67735
|
}
|
|
67033
|
-
var
|
|
67034
|
-
function
|
|
67736
|
+
var SPECIALIZATION_KINDS6 = /* @__PURE__ */ new Set([":>", ":>>", "specializes", "subsets", "redefines"]);
|
|
67737
|
+
function specializationTargets4(node) {
|
|
67035
67738
|
const n = node;
|
|
67036
67739
|
const out = [];
|
|
67037
67740
|
for (const rel of [...n.preRelationships ?? [], ...n.relationships ?? []]) {
|
|
67038
|
-
if (rel.kind &&
|
|
67741
|
+
if (rel.kind && SPECIALIZATION_KINDS6.has(rel.kind))
|
|
67039
67742
|
out.push(...rel.targets ?? []);
|
|
67040
67743
|
}
|
|
67041
67744
|
return out;
|
|
@@ -67114,7 +67817,10 @@ var SysmlScopeComputation = class extends DefaultScopeComputation {
|
|
|
67114
67817
|
const description = {
|
|
67115
67818
|
...entry.description,
|
|
67116
67819
|
name: `${ownerAlias}::${entry.name}`,
|
|
67117
|
-
isDerivedAlias: true
|
|
67820
|
+
isDerivedAlias: true,
|
|
67821
|
+
// issue #152 — a membership seen through a re-export,
|
|
67822
|
+
// not one this namespace owns.
|
|
67823
|
+
derivedKind: "reexport"
|
|
67118
67824
|
};
|
|
67119
67825
|
const key = exportAliasKey(description);
|
|
67120
67826
|
if (seen.has(key))
|
|
@@ -67135,7 +67841,7 @@ var SysmlScopeComputation = class extends DefaultScopeComputation {
|
|
|
67135
67841
|
// linker can resolve the qualified spelling without a full type evaluator.
|
|
67136
67842
|
addInheritedQualifiedAliases(root3, exports2) {
|
|
67137
67843
|
const seen = new Set(exports2.map(exportAliasKey));
|
|
67138
|
-
const nodes = Array.from(ast_utils_exports.streamAllContents(root3)).filter((node) =>
|
|
67844
|
+
const nodes = Array.from(ast_utils_exports.streamAllContents(root3)).filter((node) => specializationTargets5(node).length > 0);
|
|
67139
67845
|
if (nodes.length === 0)
|
|
67140
67846
|
return;
|
|
67141
67847
|
const ownerAliases = aliasesByNode(exports2);
|
|
@@ -67143,7 +67849,7 @@ var SysmlScopeComputation = class extends DefaultScopeComputation {
|
|
|
67143
67849
|
const sourceDescriptions = new GlobalDescriptionIndex(exports2);
|
|
67144
67850
|
const additions = [];
|
|
67145
67851
|
for (const node of nodes) {
|
|
67146
|
-
const targets =
|
|
67852
|
+
const targets = specializationTargets5(node);
|
|
67147
67853
|
const aliases = ownerAliases.get(node) ?? [];
|
|
67148
67854
|
if (aliases.length === 0)
|
|
67149
67855
|
continue;
|
|
@@ -67156,7 +67862,9 @@ var SysmlScopeComputation = class extends DefaultScopeComputation {
|
|
|
67156
67862
|
const description = {
|
|
67157
67863
|
...inherited,
|
|
67158
67864
|
name: `${ownerAlias}::${suffix}`,
|
|
67159
|
-
isDerivedAlias: true
|
|
67865
|
+
isDerivedAlias: true,
|
|
67866
|
+
// issue #152 — an implicit inherited membership.
|
|
67867
|
+
derivedKind: "inherited"
|
|
67160
67868
|
};
|
|
67161
67869
|
const key = exportAliasKey(description);
|
|
67162
67870
|
if (seen.has(key))
|
|
@@ -67240,7 +67948,7 @@ var SysmlScopeComputation = class extends DefaultScopeComputation {
|
|
|
67240
67948
|
...base,
|
|
67241
67949
|
...visibility ? { visibility } : {},
|
|
67242
67950
|
...visibility === "private" ? { isPrivate: true } : {},
|
|
67243
|
-
...alias.derived ? { isDerivedAlias: true } : {},
|
|
67951
|
+
...alias.derived ? { isDerivedAlias: true, derivedKind: "relative" } : {},
|
|
67244
67952
|
// REQ-242 — issue #103 — mirrors what the precomputed library index
|
|
67245
67953
|
// records, so consumers read def-ness the same way for workspace and
|
|
67246
67954
|
// library symbols.
|
|
@@ -67289,39 +67997,26 @@ function directImportEntries(imp, descriptions) {
|
|
|
67289
67997
|
const path10 = importedPath(imp);
|
|
67290
67998
|
if (!path10)
|
|
67291
67999
|
return [];
|
|
67292
|
-
const
|
|
67293
|
-
|
|
68000
|
+
const form = importForm(imp);
|
|
68001
|
+
const options = {
|
|
68002
|
+
resolveReferences: false,
|
|
68003
|
+
resolveName: (name) => descriptions.firstNamed(name)?.node
|
|
68004
|
+
};
|
|
68005
|
+
if (form.wildcard === "none") {
|
|
67294
68006
|
const description = descriptions.firstNamed(path10);
|
|
67295
68007
|
if (!description)
|
|
67296
68008
|
return [];
|
|
67297
|
-
|
|
67298
|
-
|
|
67299
|
-
const entries = [];
|
|
67300
|
-
const seen = /* @__PURE__ */ new Set();
|
|
67301
|
-
for (const description of descriptions.membersOf(path10, wildcard)) {
|
|
67302
|
-
const visibility = description;
|
|
67303
|
-
if (visibility.isPrivate || visibility.visibility === "private")
|
|
67304
|
-
continue;
|
|
67305
|
-
const rest = description.name.slice(path10.length + 2);
|
|
67306
|
-
if (!rest)
|
|
67307
|
-
continue;
|
|
67308
|
-
const name = rest.split("::").pop();
|
|
67309
|
-
if (!name)
|
|
67310
|
-
continue;
|
|
67311
|
-
const key = `${name}|${description.documentUri.toString()}|${description.path}`;
|
|
67312
|
-
if (seen.has(key))
|
|
67313
|
-
continue;
|
|
67314
|
-
seen.add(key);
|
|
67315
|
-
entries.push({ name, description });
|
|
68009
|
+
const name = imp.alias ?? path10.split("::").pop() ?? path10;
|
|
68010
|
+
return applyFilters(imp, [{ name, targetName: description.name, description }], options);
|
|
67316
68011
|
}
|
|
67317
|
-
return
|
|
68012
|
+
return applyFilters(imp, selectMemberships(path10, form, descriptions), options);
|
|
67318
68013
|
}
|
|
67319
|
-
var
|
|
67320
|
-
function
|
|
68014
|
+
var SPECIALIZATION_KINDS7 = /* @__PURE__ */ new Set([":>", ":>>", "specializes", "subsets", "redefines"]);
|
|
68015
|
+
function specializationTargets5(node) {
|
|
67321
68016
|
const value = node;
|
|
67322
68017
|
const targets = [];
|
|
67323
68018
|
for (const relationship of [...value.preRelationships ?? [], ...value.relationships ?? []]) {
|
|
67324
|
-
if (relationship.kind &&
|
|
68019
|
+
if (relationship.kind && SPECIALIZATION_KINDS7.has(relationship.kind)) {
|
|
67325
68020
|
targets.push(...relationship.targets ?? []);
|
|
67326
68021
|
}
|
|
67327
68022
|
}
|
|
@@ -67634,6 +68329,15 @@ var SysmlCodeActionProvider = class {
|
|
|
67634
68329
|
});
|
|
67635
68330
|
}
|
|
67636
68331
|
}
|
|
68332
|
+
if (code === "RES021") {
|
|
68333
|
+
actions.push({
|
|
68334
|
+
title: "Make this root import 'private'",
|
|
68335
|
+
kind: import_vscode_languageserver18.CodeActionKind.QuickFix,
|
|
68336
|
+
isPreferred: true,
|
|
68337
|
+
diagnostics: [diagnostic],
|
|
68338
|
+
edit: { changes: { [uri]: [import_vscode_languageserver18.TextEdit.replace(diagnostic.range, "private")] } }
|
|
68339
|
+
});
|
|
68340
|
+
}
|
|
67637
68341
|
if (code === "RES015" && isImportFixData(diagnostic.data)) {
|
|
67638
68342
|
const importPath = diagnostic.data.importPath;
|
|
67639
68343
|
const pkg = nearestAncestor2(node, isPackage);
|
|
@@ -69164,341 +69868,6 @@ function effectiveNameHint(node) {
|
|
|
69164
69868
|
};
|
|
69165
69869
|
}
|
|
69166
69870
|
|
|
69167
|
-
// ../language-server/out/src/services/requirement-eval.js
|
|
69168
|
-
var UNRESOLVED = { kind: "unresolved" };
|
|
69169
|
-
var INCONCLUSIVE = { kind: "inconclusive" };
|
|
69170
|
-
var REDEFINE_KINDS = /* @__PURE__ */ new Set([":>>", ":>", "redefines", "subsets"]);
|
|
69171
|
-
function declaresFeature(node, name) {
|
|
69172
|
-
if (node.name === name)
|
|
69173
|
-
return true;
|
|
69174
|
-
for (const rel of [...node.preRelationships ?? [], ...node.relationships ?? []]) {
|
|
69175
|
-
if (rel.kind && REDEFINE_KINDS.has(rel.kind) && (rel.targets ?? []).includes(name))
|
|
69176
|
-
return true;
|
|
69177
|
-
}
|
|
69178
|
-
return false;
|
|
69179
|
-
}
|
|
69180
|
-
function evaluateExpr(node, scope) {
|
|
69181
|
-
if (!node)
|
|
69182
|
-
return INCONCLUSIVE;
|
|
69183
|
-
const n = node;
|
|
69184
|
-
switch (n.$type) {
|
|
69185
|
-
case "NumericPrimary":
|
|
69186
|
-
return typeof n.numVal === "number" ? { kind: "number", value: n.numVal } : INCONCLUSIVE;
|
|
69187
|
-
case "LiteralBool":
|
|
69188
|
-
return { kind: "boolean", value: n.value === "true" };
|
|
69189
|
-
case "LiteralStr":
|
|
69190
|
-
return { kind: "string", value: decodeStringLiteral(String(n.value ?? "")) };
|
|
69191
|
-
case "LiteralNull":
|
|
69192
|
-
return INCONCLUSIVE;
|
|
69193
|
-
case "ParenExpr": {
|
|
69194
|
-
const items = n.items ?? [];
|
|
69195
|
-
return items.length === 1 ? evaluateExpr(items[0], scope) : INCONCLUSIVE;
|
|
69196
|
-
}
|
|
69197
|
-
case "UnaryMinusExpr": {
|
|
69198
|
-
const v = evaluateExpr(n.operand, scope);
|
|
69199
|
-
return v.kind === "number" ? { kind: "number", value: -v.value } : passThrough(v);
|
|
69200
|
-
}
|
|
69201
|
-
case "UnaryPlusExpr":
|
|
69202
|
-
return evaluateExpr(n.operand, scope);
|
|
69203
|
-
case "NotExpr": {
|
|
69204
|
-
if (!n.operand)
|
|
69205
|
-
return INCONCLUSIVE;
|
|
69206
|
-
const v = evaluateExpr(n.operand, scope);
|
|
69207
|
-
return v.kind === "boolean" ? { kind: "boolean", value: !v.value } : passThrough(v);
|
|
69208
|
-
}
|
|
69209
|
-
case "PathExpr":
|
|
69210
|
-
return scope(String(n.path).split("."));
|
|
69211
|
-
case "IfExpr": {
|
|
69212
|
-
const cond = evaluateExpr(n.cond, scope);
|
|
69213
|
-
if (cond.kind !== "boolean")
|
|
69214
|
-
return passThrough(cond);
|
|
69215
|
-
return cond.value ? evaluateExpr(n.thenExpr, scope) : evaluateExpr(n.elseExpr, scope);
|
|
69216
|
-
}
|
|
69217
|
-
case "PostfixOp": {
|
|
69218
|
-
if (n.unit && n.unitValue)
|
|
69219
|
-
return evaluateExpr(n.unitValue, scope);
|
|
69220
|
-
if (n.operand)
|
|
69221
|
-
return evaluateExpr(n.operand, scope);
|
|
69222
|
-
return INCONCLUSIVE;
|
|
69223
|
-
}
|
|
69224
|
-
case "BinExpr":
|
|
69225
|
-
return evaluateBin2(n, scope);
|
|
69226
|
-
default:
|
|
69227
|
-
return INCONCLUSIVE;
|
|
69228
|
-
}
|
|
69229
|
-
}
|
|
69230
|
-
function passThrough(v) {
|
|
69231
|
-
return v.kind === "unresolved" ? UNRESOLVED : INCONCLUSIVE;
|
|
69232
|
-
}
|
|
69233
|
-
function decodeStringLiteral(raw) {
|
|
69234
|
-
let body = raw;
|
|
69235
|
-
if (body.length >= 2 && body.startsWith('"') && body.endsWith('"')) {
|
|
69236
|
-
body = body.slice(1, -1);
|
|
69237
|
-
}
|
|
69238
|
-
return body.replace(/\\(.)/gu, (_m, ch) => {
|
|
69239
|
-
switch (ch) {
|
|
69240
|
-
case "n":
|
|
69241
|
-
return "\n";
|
|
69242
|
-
case "t":
|
|
69243
|
-
return " ";
|
|
69244
|
-
case "b":
|
|
69245
|
-
return "\b";
|
|
69246
|
-
case "f":
|
|
69247
|
-
return "\f";
|
|
69248
|
-
default:
|
|
69249
|
-
return ch;
|
|
69250
|
-
}
|
|
69251
|
-
});
|
|
69252
|
-
}
|
|
69253
|
-
function evaluateBin2(node, scope) {
|
|
69254
|
-
const op = String(node.op);
|
|
69255
|
-
const left = evaluateExpr(node.left, scope);
|
|
69256
|
-
if (op === "and" || op === "&") {
|
|
69257
|
-
if (left.kind === "boolean" && !left.value)
|
|
69258
|
-
return { kind: "boolean", value: false };
|
|
69259
|
-
} else if (op === "or" || op === "|") {
|
|
69260
|
-
if (left.kind === "boolean" && left.value)
|
|
69261
|
-
return { kind: "boolean", value: true };
|
|
69262
|
-
} else if (op === "implies") {
|
|
69263
|
-
if (left.kind === "boolean" && !left.value)
|
|
69264
|
-
return { kind: "boolean", value: true };
|
|
69265
|
-
}
|
|
69266
|
-
const right = evaluateExpr(node.right, scope);
|
|
69267
|
-
if (left.kind === "unresolved" || right.kind === "unresolved")
|
|
69268
|
-
return UNRESOLVED;
|
|
69269
|
-
if (left.kind === "inconclusive" || right.kind === "inconclusive")
|
|
69270
|
-
return INCONCLUSIVE;
|
|
69271
|
-
switch (op) {
|
|
69272
|
-
case "+":
|
|
69273
|
-
case "-":
|
|
69274
|
-
case "*":
|
|
69275
|
-
case "/":
|
|
69276
|
-
case "%":
|
|
69277
|
-
case "**":
|
|
69278
|
-
case "^":
|
|
69279
|
-
if (left.kind === "number" && right.kind === "number") {
|
|
69280
|
-
return { kind: "number", value: arith(op, left.value, right.value) };
|
|
69281
|
-
}
|
|
69282
|
-
return INCONCLUSIVE;
|
|
69283
|
-
case "<":
|
|
69284
|
-
case ">":
|
|
69285
|
-
case "<=":
|
|
69286
|
-
case ">=":
|
|
69287
|
-
if (left.kind === "number" && right.kind === "number") {
|
|
69288
|
-
return { kind: "boolean", value: compare(op, left.value, right.value) };
|
|
69289
|
-
}
|
|
69290
|
-
return INCONCLUSIVE;
|
|
69291
|
-
case "==":
|
|
69292
|
-
case "!=":
|
|
69293
|
-
case "===":
|
|
69294
|
-
case "!==": {
|
|
69295
|
-
const eq3 = valuesEqual(left, right);
|
|
69296
|
-
if (eq3 === void 0)
|
|
69297
|
-
return INCONCLUSIVE;
|
|
69298
|
-
return { kind: "boolean", value: op.startsWith("!") ? !eq3 : eq3 };
|
|
69299
|
-
}
|
|
69300
|
-
case "and":
|
|
69301
|
-
case "&":
|
|
69302
|
-
return bothBool(left, right, (a2, b) => a2 && b);
|
|
69303
|
-
case "or":
|
|
69304
|
-
case "|":
|
|
69305
|
-
return bothBool(left, right, (a2, b) => a2 || b);
|
|
69306
|
-
case "xor":
|
|
69307
|
-
return bothBool(left, right, (a2, b) => a2 !== b);
|
|
69308
|
-
case "implies":
|
|
69309
|
-
return bothBool(left, right, (a2, b) => !a2 || b);
|
|
69310
|
-
default:
|
|
69311
|
-
return INCONCLUSIVE;
|
|
69312
|
-
}
|
|
69313
|
-
}
|
|
69314
|
-
function arith(op, a2, b) {
|
|
69315
|
-
switch (op) {
|
|
69316
|
-
case "+":
|
|
69317
|
-
return a2 + b;
|
|
69318
|
-
case "-":
|
|
69319
|
-
return a2 - b;
|
|
69320
|
-
case "*":
|
|
69321
|
-
return a2 * b;
|
|
69322
|
-
case "/":
|
|
69323
|
-
return a2 / b;
|
|
69324
|
-
case "%":
|
|
69325
|
-
return a2 % b;
|
|
69326
|
-
case "**":
|
|
69327
|
-
case "^":
|
|
69328
|
-
return a2 ** b;
|
|
69329
|
-
default:
|
|
69330
|
-
return NaN;
|
|
69331
|
-
}
|
|
69332
|
-
}
|
|
69333
|
-
function compare(op, a2, b) {
|
|
69334
|
-
switch (op) {
|
|
69335
|
-
case "<":
|
|
69336
|
-
return a2 < b;
|
|
69337
|
-
case ">":
|
|
69338
|
-
return a2 > b;
|
|
69339
|
-
case "<=":
|
|
69340
|
-
return a2 <= b;
|
|
69341
|
-
case ">=":
|
|
69342
|
-
return a2 >= b;
|
|
69343
|
-
default:
|
|
69344
|
-
return false;
|
|
69345
|
-
}
|
|
69346
|
-
}
|
|
69347
|
-
function valuesEqual(a2, b) {
|
|
69348
|
-
if (a2.kind === "number" && b.kind === "number")
|
|
69349
|
-
return a2.value === b.value;
|
|
69350
|
-
if (a2.kind === "boolean" && b.kind === "boolean")
|
|
69351
|
-
return a2.value === b.value;
|
|
69352
|
-
if (a2.kind === "string" && b.kind === "string")
|
|
69353
|
-
return a2.value === b.value;
|
|
69354
|
-
return void 0;
|
|
69355
|
-
}
|
|
69356
|
-
function bothBool(a2, b, f) {
|
|
69357
|
-
if (a2.kind === "boolean" && b.kind === "boolean")
|
|
69358
|
-
return { kind: "boolean", value: f(a2.value, b.value) };
|
|
69359
|
-
return INCONCLUSIVE;
|
|
69360
|
-
}
|
|
69361
|
-
function memberNamed(node, name, seen = /* @__PURE__ */ new Set()) {
|
|
69362
|
-
if (!node || seen.has(node))
|
|
69363
|
-
return void 0;
|
|
69364
|
-
seen.add(node);
|
|
69365
|
-
for (const member of node.members ?? []) {
|
|
69366
|
-
if (member.value !== void 0 && declaresFeature(member, name))
|
|
69367
|
-
return member;
|
|
69368
|
-
}
|
|
69369
|
-
for (const member of node.members ?? []) {
|
|
69370
|
-
if (declaresFeature(member, name))
|
|
69371
|
-
return member;
|
|
69372
|
-
}
|
|
69373
|
-
const typeRef = node.typing?.type?.ref;
|
|
69374
|
-
return typeRef ? memberNamed(typeRef, name, seen) : void 0;
|
|
69375
|
-
}
|
|
69376
|
-
function resolveFeatureValue(root3, segments) {
|
|
69377
|
-
let cur = root3;
|
|
69378
|
-
for (const seg of segments) {
|
|
69379
|
-
cur = memberNamed(cur, seg);
|
|
69380
|
-
if (!cur)
|
|
69381
|
-
return UNRESOLVED;
|
|
69382
|
-
}
|
|
69383
|
-
if (cur.value)
|
|
69384
|
-
return evaluateExpr(cur.value, () => INCONCLUSIVE);
|
|
69385
|
-
return INCONCLUSIVE;
|
|
69386
|
-
}
|
|
69387
|
-
function subjectScope(subjectName, subjectBinding) {
|
|
69388
|
-
const binding = subjectBinding;
|
|
69389
|
-
return (segments) => {
|
|
69390
|
-
if (!binding)
|
|
69391
|
-
return INCONCLUSIVE;
|
|
69392
|
-
if (subjectName && segments[0] === subjectName) {
|
|
69393
|
-
const rest = segments.slice(1);
|
|
69394
|
-
if (rest.length === 0)
|
|
69395
|
-
return INCONCLUSIVE;
|
|
69396
|
-
return resolveFeatureValue(binding, rest);
|
|
69397
|
-
}
|
|
69398
|
-
return resolveFeatureValue(binding, segments);
|
|
69399
|
-
};
|
|
69400
|
-
}
|
|
69401
|
-
function subjectNameOf(req) {
|
|
69402
|
-
const subject = (req.members ?? []).find((m) => m.$type === "SubjectDecl");
|
|
69403
|
-
return subject?.name;
|
|
69404
|
-
}
|
|
69405
|
-
function gatherConstraints(req) {
|
|
69406
|
-
const out = [];
|
|
69407
|
-
for (const member of req.members ?? []) {
|
|
69408
|
-
if (member.$type === "RequireConstraintStmt" && member.body) {
|
|
69409
|
-
out.push({ kind: "require", body: member.body, text: exprText2(member.body) });
|
|
69410
|
-
} else if (member.$type === "AssumeConstraintStmt" && member.body) {
|
|
69411
|
-
out.push({ kind: "assume", body: member.body, text: exprText2(member.body) });
|
|
69412
|
-
}
|
|
69413
|
-
}
|
|
69414
|
-
return out;
|
|
69415
|
-
}
|
|
69416
|
-
function exprText2(node) {
|
|
69417
|
-
return node.$cstNode?.text?.trim() ?? "";
|
|
69418
|
-
}
|
|
69419
|
-
function evaluateRequirement(req, subjectBinding) {
|
|
69420
|
-
const requirement = req;
|
|
69421
|
-
const subjectName = subjectNameOf(requirement);
|
|
69422
|
-
const scope = subjectScope(subjectName, subjectBinding);
|
|
69423
|
-
const constraints = gatherConstraints(requirement);
|
|
69424
|
-
const details = [];
|
|
69425
|
-
let sawInconclusive = false;
|
|
69426
|
-
let sawUnresolved = false;
|
|
69427
|
-
let failed = false;
|
|
69428
|
-
for (const c of constraints) {
|
|
69429
|
-
const v = evaluateExpr(c.body, scope);
|
|
69430
|
-
let status2;
|
|
69431
|
-
if (v.kind === "unresolved") {
|
|
69432
|
-
status2 = "unresolved";
|
|
69433
|
-
sawUnresolved = true;
|
|
69434
|
-
} else if (v.kind !== "boolean") {
|
|
69435
|
-
status2 = "inconclusive";
|
|
69436
|
-
sawInconclusive = true;
|
|
69437
|
-
} else if (v.value) {
|
|
69438
|
-
status2 = "pass";
|
|
69439
|
-
} else if (c.kind === "require") {
|
|
69440
|
-
status2 = "fail";
|
|
69441
|
-
failed = true;
|
|
69442
|
-
} else {
|
|
69443
|
-
status2 = "inconclusive";
|
|
69444
|
-
sawInconclusive = true;
|
|
69445
|
-
}
|
|
69446
|
-
details.push({ kind: c.kind, status: status2, text: c.text });
|
|
69447
|
-
}
|
|
69448
|
-
let status;
|
|
69449
|
-
if (constraints.length === 0)
|
|
69450
|
-
status = "inconclusive";
|
|
69451
|
-
else if (failed)
|
|
69452
|
-
status = "fail";
|
|
69453
|
-
else if (sawUnresolved)
|
|
69454
|
-
status = "unresolved";
|
|
69455
|
-
else if (sawInconclusive)
|
|
69456
|
-
status = "inconclusive";
|
|
69457
|
-
else
|
|
69458
|
-
status = "pass";
|
|
69459
|
-
return { status, details };
|
|
69460
|
-
}
|
|
69461
|
-
function bindingName(by) {
|
|
69462
|
-
const n = by;
|
|
69463
|
-
if (n?.$type !== "PathExpr")
|
|
69464
|
-
return void 0;
|
|
69465
|
-
return n.path?.split(/::|\./).pop();
|
|
69466
|
-
}
|
|
69467
|
-
function evaluateVerificationCase(caseNode, resolveRequirement, resolvePart) {
|
|
69468
|
-
const node = caseNode;
|
|
69469
|
-
const subject = (node.members ?? []).find((m) => m.$type === "SubjectDecl");
|
|
69470
|
-
const subjectBoundName = bindingName(subject?.value);
|
|
69471
|
-
const subjectBinding = (subjectBoundName ? resolvePart(subjectBoundName) : void 0) ?? subject;
|
|
69472
|
-
const verifies = [];
|
|
69473
|
-
for (const member of node.members ?? []) {
|
|
69474
|
-
if (member.$type !== "VerifyStmt")
|
|
69475
|
-
continue;
|
|
69476
|
-
const targetName = String(member.target ?? "").split(/::|\./).pop();
|
|
69477
|
-
if (!targetName)
|
|
69478
|
-
continue;
|
|
69479
|
-
const req = resolveRequirement(targetName);
|
|
69480
|
-
if (!req) {
|
|
69481
|
-
verifies.push({ requirement: targetName, status: "unresolved" });
|
|
69482
|
-
continue;
|
|
69483
|
-
}
|
|
69484
|
-
const boundName = bindingName(member.by);
|
|
69485
|
-
const binding = (boundName ? resolvePart(boundName) : void 0) ?? subjectBinding;
|
|
69486
|
-
verifies.push({ requirement: targetName, status: evaluateRequirement(req, binding).status });
|
|
69487
|
-
}
|
|
69488
|
-
let status = "inconclusive";
|
|
69489
|
-
if (verifies.length === 0)
|
|
69490
|
-
status = "inconclusive";
|
|
69491
|
-
else if (verifies.some((v) => v.status === "fail"))
|
|
69492
|
-
status = "fail";
|
|
69493
|
-
else if (verifies.some((v) => v.status === "unresolved"))
|
|
69494
|
-
status = "error";
|
|
69495
|
-
else if (verifies.some((v) => v.status === "inconclusive"))
|
|
69496
|
-
status = "inconclusive";
|
|
69497
|
-
else
|
|
69498
|
-
status = "pass";
|
|
69499
|
-
return { status, verifies };
|
|
69500
|
-
}
|
|
69501
|
-
|
|
69502
69871
|
// ../language-server/out/src/services/codelens-provider.js
|
|
69503
69872
|
function walkAst(node, fn) {
|
|
69504
69873
|
fn(node);
|
|
@@ -71476,7 +71845,7 @@ async function runValidation(command) {
|
|
|
71476
71845
|
}
|
|
71477
71846
|
|
|
71478
71847
|
// src/main.ts
|
|
71479
|
-
var VERSION2 = true ? "0.
|
|
71848
|
+
var VERSION2 = true ? "0.18.0" : "dev";
|
|
71480
71849
|
async function main(argv) {
|
|
71481
71850
|
const command = parseArgs(argv);
|
|
71482
71851
|
if (command.kind === "help") {
|