sysml-v2-lsp 0.35.0 → 0.37.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.
@@ -10545,8 +10545,8 @@ var require_main2 = __commonJS({
10545
10545
  }
10546
10546
  uinteger2.is = is;
10547
10547
  })(uinteger || (exports3.uinteger = uinteger = {}));
10548
- var Position;
10549
- (function(Position2) {
10548
+ var Position2;
10549
+ (function(Position3) {
10550
10550
  function create(line, character) {
10551
10551
  if (line === Number.MAX_VALUE) {
10552
10552
  line = uinteger.MAX_VALUE;
@@ -10556,31 +10556,31 @@ var require_main2 = __commonJS({
10556
10556
  }
10557
10557
  return { line, character };
10558
10558
  }
10559
- Position2.create = create;
10559
+ Position3.create = create;
10560
10560
  function is(value) {
10561
10561
  var candidate = value;
10562
10562
  return Is.objectLiteral(candidate) && Is.uinteger(candidate.line) && Is.uinteger(candidate.character);
10563
10563
  }
10564
- Position2.is = is;
10565
- })(Position || (exports3.Position = Position = {}));
10566
- var Range;
10567
- (function(Range2) {
10564
+ Position3.is = is;
10565
+ })(Position2 || (exports3.Position = Position2 = {}));
10566
+ var Range2;
10567
+ (function(Range3) {
10568
10568
  function create(one, two, three, four) {
10569
10569
  if (Is.uinteger(one) && Is.uinteger(two) && Is.uinteger(three) && Is.uinteger(four)) {
10570
- return { start: Position.create(one, two), end: Position.create(three, four) };
10571
- } else if (Position.is(one) && Position.is(two)) {
10570
+ return { start: Position2.create(one, two), end: Position2.create(three, four) };
10571
+ } else if (Position2.is(one) && Position2.is(two)) {
10572
10572
  return { start: one, end: two };
10573
10573
  } else {
10574
10574
  throw new Error("Range#create called with invalid arguments[".concat(one, ", ").concat(two, ", ").concat(three, ", ").concat(four, "]"));
10575
10575
  }
10576
10576
  }
10577
- Range2.create = create;
10577
+ Range3.create = create;
10578
10578
  function is(value) {
10579
10579
  var candidate = value;
10580
- return Is.objectLiteral(candidate) && Position.is(candidate.start) && Position.is(candidate.end);
10580
+ return Is.objectLiteral(candidate) && Position2.is(candidate.start) && Position2.is(candidate.end);
10581
10581
  }
10582
- Range2.is = is;
10583
- })(Range || (exports3.Range = Range = {}));
10582
+ Range3.is = is;
10583
+ })(Range2 || (exports3.Range = Range2 = {}));
10584
10584
  var Location;
10585
10585
  (function(Location2) {
10586
10586
  function create(uri, range) {
@@ -10589,7 +10589,7 @@ var require_main2 = __commonJS({
10589
10589
  Location2.create = create;
10590
10590
  function is(value) {
10591
10591
  var candidate = value;
10592
- return Is.objectLiteral(candidate) && Range.is(candidate.range) && (Is.string(candidate.uri) || Is.undefined(candidate.uri));
10592
+ return Is.objectLiteral(candidate) && Range2.is(candidate.range) && (Is.string(candidate.uri) || Is.undefined(candidate.uri));
10593
10593
  }
10594
10594
  Location2.is = is;
10595
10595
  })(Location || (exports3.Location = Location = {}));
@@ -10601,7 +10601,7 @@ var require_main2 = __commonJS({
10601
10601
  LocationLink2.create = create;
10602
10602
  function is(value) {
10603
10603
  var candidate = value;
10604
- return Is.objectLiteral(candidate) && Range.is(candidate.targetRange) && Is.string(candidate.targetUri) && Range.is(candidate.targetSelectionRange) && (Range.is(candidate.originSelectionRange) || Is.undefined(candidate.originSelectionRange));
10604
+ return Is.objectLiteral(candidate) && Range2.is(candidate.targetRange) && Is.string(candidate.targetUri) && Range2.is(candidate.targetSelectionRange) && (Range2.is(candidate.originSelectionRange) || Is.undefined(candidate.originSelectionRange));
10605
10605
  }
10606
10606
  LocationLink2.is = is;
10607
10607
  })(LocationLink || (exports3.LocationLink = LocationLink = {}));
@@ -10633,7 +10633,7 @@ var require_main2 = __commonJS({
10633
10633
  ColorInformation2.create = create;
10634
10634
  function is(value) {
10635
10635
  var candidate = value;
10636
- return Is.objectLiteral(candidate) && Range.is(candidate.range) && Color.is(candidate.color);
10636
+ return Is.objectLiteral(candidate) && Range2.is(candidate.range) && Color.is(candidate.color);
10637
10637
  }
10638
10638
  ColorInformation2.is = is;
10639
10639
  })(ColorInformation || (exports3.ColorInformation = ColorInformation = {}));
@@ -10744,7 +10744,7 @@ var require_main2 = __commonJS({
10744
10744
  function is(value) {
10745
10745
  var _a3;
10746
10746
  var candidate = value;
10747
- return Is.defined(candidate) && Range.is(candidate.range) && Is.string(candidate.message) && (Is.number(candidate.severity) || Is.undefined(candidate.severity)) && (Is.integer(candidate.code) || Is.string(candidate.code) || Is.undefined(candidate.code)) && (Is.undefined(candidate.codeDescription) || Is.string((_a3 = candidate.codeDescription) === null || _a3 === void 0 ? void 0 : _a3.href)) && (Is.string(candidate.source) || Is.undefined(candidate.source)) && (Is.undefined(candidate.relatedInformation) || Is.typedArray(candidate.relatedInformation, DiagnosticRelatedInformation.is));
10747
+ return Is.defined(candidate) && Range2.is(candidate.range) && Is.string(candidate.message) && (Is.number(candidate.severity) || Is.undefined(candidate.severity)) && (Is.integer(candidate.code) || Is.string(candidate.code) || Is.undefined(candidate.code)) && (Is.undefined(candidate.codeDescription) || Is.string((_a3 = candidate.codeDescription) === null || _a3 === void 0 ? void 0 : _a3.href)) && (Is.string(candidate.source) || Is.undefined(candidate.source)) && (Is.undefined(candidate.relatedInformation) || Is.typedArray(candidate.relatedInformation, DiagnosticRelatedInformation.is));
10748
10748
  }
10749
10749
  Diagnostic3.is = is;
10750
10750
  })(Diagnostic2 || (exports3.Diagnostic = Diagnostic2 = {}));
@@ -10784,7 +10784,7 @@ var require_main2 = __commonJS({
10784
10784
  TextEdit2.del = del;
10785
10785
  function is(value) {
10786
10786
  var candidate = value;
10787
- return Is.objectLiteral(candidate) && Is.string(candidate.newText) && Range.is(candidate.range);
10787
+ return Is.objectLiteral(candidate) && Is.string(candidate.newText) && Range2.is(candidate.range);
10788
10788
  }
10789
10789
  TextEdit2.is = is;
10790
10790
  })(TextEdit || (exports3.TextEdit = TextEdit = {}));
@@ -11328,7 +11328,7 @@ var require_main2 = __commonJS({
11328
11328
  InsertReplaceEdit2.create = create;
11329
11329
  function is(value) {
11330
11330
  var candidate = value;
11331
- return candidate && Is.string(candidate.newText) && Range.is(candidate.insert) && Range.is(candidate.replace);
11331
+ return candidate && Is.string(candidate.newText) && Range2.is(candidate.insert) && Range2.is(candidate.replace);
11332
11332
  }
11333
11333
  InsertReplaceEdit2.is = is;
11334
11334
  })(InsertReplaceEdit || (exports3.InsertReplaceEdit = InsertReplaceEdit = {}));
@@ -11375,7 +11375,7 @@ var require_main2 = __commonJS({
11375
11375
  (function(Hover2) {
11376
11376
  function is(value) {
11377
11377
  var candidate = value;
11378
- return !!candidate && Is.objectLiteral(candidate) && (MarkupContent.is(candidate.contents) || MarkedString.is(candidate.contents) || Is.typedArray(candidate.contents, MarkedString.is)) && (value.range === void 0 || Range.is(value.range));
11378
+ return !!candidate && Is.objectLiteral(candidate) && (MarkupContent.is(candidate.contents) || MarkedString.is(candidate.contents) || Is.typedArray(candidate.contents, MarkedString.is)) && (value.range === void 0 || Range2.is(value.range));
11379
11379
  }
11380
11380
  Hover2.is = is;
11381
11381
  })(Hover || (exports3.Hover = Hover = {}));
@@ -11496,7 +11496,7 @@ var require_main2 = __commonJS({
11496
11496
  DocumentSymbol2.create = create;
11497
11497
  function is(value) {
11498
11498
  var candidate = value;
11499
- return candidate && Is.string(candidate.name) && Is.number(candidate.kind) && Range.is(candidate.range) && Range.is(candidate.selectionRange) && (candidate.detail === void 0 || Is.string(candidate.detail)) && (candidate.deprecated === void 0 || Is.boolean(candidate.deprecated)) && (candidate.children === void 0 || Array.isArray(candidate.children)) && (candidate.tags === void 0 || Array.isArray(candidate.tags));
11499
+ return candidate && Is.string(candidate.name) && Is.number(candidate.kind) && Range2.is(candidate.range) && Range2.is(candidate.selectionRange) && (candidate.detail === void 0 || Is.string(candidate.detail)) && (candidate.deprecated === void 0 || Is.boolean(candidate.deprecated)) && (candidate.children === void 0 || Array.isArray(candidate.children)) && (candidate.tags === void 0 || Array.isArray(candidate.tags));
11500
11500
  }
11501
11501
  DocumentSymbol2.is = is;
11502
11502
  })(DocumentSymbol || (exports3.DocumentSymbol = DocumentSymbol = {}));
@@ -11573,7 +11573,7 @@ var require_main2 = __commonJS({
11573
11573
  CodeLens2.create = create;
11574
11574
  function is(value) {
11575
11575
  var candidate = value;
11576
- return Is.defined(candidate) && Range.is(candidate.range) && (Is.undefined(candidate.command) || Command.is(candidate.command));
11576
+ return Is.defined(candidate) && Range2.is(candidate.range) && (Is.undefined(candidate.command) || Command.is(candidate.command));
11577
11577
  }
11578
11578
  CodeLens2.is = is;
11579
11579
  })(CodeLens || (exports3.CodeLens = CodeLens = {}));
@@ -11597,7 +11597,7 @@ var require_main2 = __commonJS({
11597
11597
  DocumentLink2.create = create;
11598
11598
  function is(value) {
11599
11599
  var candidate = value;
11600
- return Is.defined(candidate) && Range.is(candidate.range) && (Is.undefined(candidate.target) || Is.string(candidate.target));
11600
+ return Is.defined(candidate) && Range2.is(candidate.range) && (Is.undefined(candidate.target) || Is.string(candidate.target));
11601
11601
  }
11602
11602
  DocumentLink2.is = is;
11603
11603
  })(DocumentLink || (exports3.DocumentLink = DocumentLink = {}));
@@ -11609,7 +11609,7 @@ var require_main2 = __commonJS({
11609
11609
  SelectionRange2.create = create;
11610
11610
  function is(value) {
11611
11611
  var candidate = value;
11612
- return Is.objectLiteral(candidate) && Range.is(candidate.range) && (candidate.parent === void 0 || SelectionRange2.is(candidate.parent));
11612
+ return Is.objectLiteral(candidate) && Range2.is(candidate.range) && (candidate.parent === void 0 || SelectionRange2.is(candidate.parent));
11613
11613
  }
11614
11614
  SelectionRange2.is = is;
11615
11615
  })(SelectionRange || (exports3.SelectionRange = SelectionRange = {}));
@@ -11668,7 +11668,7 @@ var require_main2 = __commonJS({
11668
11668
  InlineValueText2.create = create;
11669
11669
  function is(value) {
11670
11670
  var candidate = value;
11671
- return candidate !== void 0 && candidate !== null && Range.is(candidate.range) && Is.string(candidate.text);
11671
+ return candidate !== void 0 && candidate !== null && Range2.is(candidate.range) && Is.string(candidate.text);
11672
11672
  }
11673
11673
  InlineValueText2.is = is;
11674
11674
  })(InlineValueText || (exports3.InlineValueText = InlineValueText = {}));
@@ -11680,7 +11680,7 @@ var require_main2 = __commonJS({
11680
11680
  InlineValueVariableLookup2.create = create;
11681
11681
  function is(value) {
11682
11682
  var candidate = value;
11683
- return candidate !== void 0 && candidate !== null && Range.is(candidate.range) && Is.boolean(candidate.caseSensitiveLookup) && (Is.string(candidate.variableName) || candidate.variableName === void 0);
11683
+ return candidate !== void 0 && candidate !== null && Range2.is(candidate.range) && Is.boolean(candidate.caseSensitiveLookup) && (Is.string(candidate.variableName) || candidate.variableName === void 0);
11684
11684
  }
11685
11685
  InlineValueVariableLookup2.is = is;
11686
11686
  })(InlineValueVariableLookup || (exports3.InlineValueVariableLookup = InlineValueVariableLookup = {}));
@@ -11692,7 +11692,7 @@ var require_main2 = __commonJS({
11692
11692
  InlineValueEvaluatableExpression2.create = create;
11693
11693
  function is(value) {
11694
11694
  var candidate = value;
11695
- return candidate !== void 0 && candidate !== null && Range.is(candidate.range) && (Is.string(candidate.expression) || candidate.expression === void 0);
11695
+ return candidate !== void 0 && candidate !== null && Range2.is(candidate.range) && (Is.string(candidate.expression) || candidate.expression === void 0);
11696
11696
  }
11697
11697
  InlineValueEvaluatableExpression2.is = is;
11698
11698
  })(InlineValueEvaluatableExpression || (exports3.InlineValueEvaluatableExpression = InlineValueEvaluatableExpression = {}));
@@ -11704,7 +11704,7 @@ var require_main2 = __commonJS({
11704
11704
  InlineValueContext2.create = create;
11705
11705
  function is(value) {
11706
11706
  var candidate = value;
11707
- return Is.defined(candidate) && Range.is(value.stoppedLocation);
11707
+ return Is.defined(candidate) && Range2.is(value.stoppedLocation);
11708
11708
  }
11709
11709
  InlineValueContext2.is = is;
11710
11710
  })(InlineValueContext || (exports3.InlineValueContext = InlineValueContext = {}));
@@ -11741,7 +11741,7 @@ var require_main2 = __commonJS({
11741
11741
  InlayHint2.create = create;
11742
11742
  function is(value) {
11743
11743
  var candidate = value;
11744
- return Is.objectLiteral(candidate) && Position.is(candidate.position) && (Is.string(candidate.label) || Is.typedArray(candidate.label, InlayHintLabelPart.is)) && (candidate.kind === void 0 || InlayHintKind.is(candidate.kind)) && candidate.textEdits === void 0 || Is.typedArray(candidate.textEdits, TextEdit.is) && (candidate.tooltip === void 0 || Is.string(candidate.tooltip) || MarkupContent.is(candidate.tooltip)) && (candidate.paddingLeft === void 0 || Is.boolean(candidate.paddingLeft)) && (candidate.paddingRight === void 0 || Is.boolean(candidate.paddingRight));
11744
+ return Is.objectLiteral(candidate) && Position2.is(candidate.position) && (Is.string(candidate.label) || Is.typedArray(candidate.label, InlayHintLabelPart.is)) && (candidate.kind === void 0 || InlayHintKind.is(candidate.kind)) && candidate.textEdits === void 0 || Is.typedArray(candidate.textEdits, TextEdit.is) && (candidate.tooltip === void 0 || Is.string(candidate.tooltip) || MarkupContent.is(candidate.tooltip)) && (candidate.paddingLeft === void 0 || Is.boolean(candidate.paddingLeft)) && (candidate.paddingRight === void 0 || Is.boolean(candidate.paddingRight));
11745
11745
  }
11746
11746
  InlayHint2.is = is;
11747
11747
  })(InlayHint || (exports3.InlayHint = InlayHint = {}));
@@ -11930,7 +11930,7 @@ var require_main2 = __commonJS({
11930
11930
  var lineOffsets = this.getLineOffsets();
11931
11931
  var low = 0, high = lineOffsets.length;
11932
11932
  if (high === 0) {
11933
- return Position.create(0, offset);
11933
+ return Position2.create(0, offset);
11934
11934
  }
11935
11935
  while (low < high) {
11936
11936
  var mid = Math.floor((low + high) / 2);
@@ -11941,7 +11941,7 @@ var require_main2 = __commonJS({
11941
11941
  }
11942
11942
  }
11943
11943
  var line = low - 1;
11944
- return Position.create(line, offset - lineOffsets[line]);
11944
+ return Position2.create(line, offset - lineOffsets[line]);
11945
11945
  };
11946
11946
  FullTextDocument2.prototype.offsetAt = function(position) {
11947
11947
  var lineOffsets = this.getLineOffsets();
@@ -20332,6 +20332,7 @@ __export(util_exports, {
20332
20332
  required: () => required,
20333
20333
  safeExtend: () => safeExtend,
20334
20334
  shallowClone: () => shallowClone,
20335
+ sizeCaps: () => sizeCaps,
20335
20336
  slugify: () => slugify,
20336
20337
  stringifyPrimitive: () => stringifyPrimitive,
20337
20338
  toZod: () => toZod,
@@ -20851,6 +20852,18 @@ function prefixIssues(path, issues) {
20851
20852
  function unwrapMessage(message) {
20852
20853
  return typeof message === "string" ? message : message?.message;
20853
20854
  }
20855
+ function sizeCaps(defChecks) {
20856
+ const caps = [];
20857
+ for (const ch of defChecks ?? []) {
20858
+ const d = ch._zod.def;
20859
+ if (!/_(length|size)$|_equals$/.test(d.check))
20860
+ break;
20861
+ const max = d.maximum ?? d.length ?? d.size;
20862
+ if (max >= 0)
20863
+ caps.push([max, ch]);
20864
+ }
20865
+ return caps;
20866
+ }
20854
20867
  function attachSchema(issues, start, inst) {
20855
20868
  var _a3;
20856
20869
  for (let i = start; i < issues.length; i++) {
@@ -22271,7 +22284,7 @@ ${content.join("\n")}
22271
22284
  var version = {
22272
22285
  major: 4,
22273
22286
  minor: 6,
22274
- patch: 5
22287
+ patch: 6
22275
22288
  };
22276
22289
 
22277
22290
  // node_modules/zod/v4/core/schemas.js
@@ -23027,6 +23040,31 @@ var $ZodDate = /* @__PURE__ */ $constructor("$ZodDate", (inst, def) => {
23027
23040
  return payload;
23028
23041
  };
23029
23042
  });
23043
+ function capSize(inst, size) {
23044
+ const caps = sizeCaps(inst._zod.def.checks);
23045
+ if (!caps.length)
23046
+ return;
23047
+ const cap = Math.min(...caps.map((c) => c[0]));
23048
+ const parse4 = inst._zod.parse;
23049
+ inst._zod.parse = (payload, ctx2) => {
23050
+ const n2 = size(payload.value);
23051
+ if (n2 > cap && !ctx2?.skipChecks && ctx2?.direction !== "backward") {
23052
+ for (const [max, ch] of sizeCaps(inst._zod.def.checks)) {
23053
+ if (n2 > max && ch._zod.def.when(payload)) {
23054
+ const start = payload.issues.length;
23055
+ ch._zod.check(payload);
23056
+ payload.issues[start].continue = false;
23057
+ attachSchema(payload.issues, start, inst);
23058
+ return payload;
23059
+ }
23060
+ }
23061
+ }
23062
+ return parse4(payload, ctx2);
23063
+ };
23064
+ }
23065
+ var arraySize = (input2) => Array.isArray(input2) ? input2.length : -1;
23066
+ var mapSize = (input2) => input2 instanceof Map ? input2.size : -1;
23067
+ var setSize = (input2) => input2 instanceof Set ? input2.size : -1;
23030
23068
  function handleArrayResult(result, final, index2) {
23031
23069
  if (result.issues.length) {
23032
23070
  final.issues.push(...prefixIssues(index2, result.issues));
@@ -23070,6 +23108,7 @@ var $ZodArray = /* @__PURE__ */ $constructor("$ZodArray", (inst, def) => {
23070
23108
  }
23071
23109
  return payload;
23072
23110
  };
23111
+ capSize(inst, arraySize);
23073
23112
  });
23074
23113
  function handlePropertyResult(result, final, key, input2, optin, optout) {
23075
23114
  const isPresent = key in input2;
@@ -24026,6 +24065,7 @@ var $ZodMap = /* @__PURE__ */ $constructor("$ZodMap", (inst, def) => {
24026
24065
  return Promise.all(proms).then(() => payload);
24027
24066
  return payload;
24028
24067
  };
24068
+ capSize(inst, mapSize);
24029
24069
  });
24030
24070
  function handleMapResult(keyResult, valueResult, final, key, input2, inst, ctx2) {
24031
24071
  if (keyResult.issues.length) {
@@ -24092,6 +24132,7 @@ var $ZodSet = /* @__PURE__ */ $constructor("$ZodSet", (inst, def) => {
24092
24132
  return Promise.all(proms).then(() => payload);
24093
24133
  return payload;
24094
24134
  };
24135
+ capSize(inst, setSize);
24095
24136
  });
24096
24137
  function handleSetResult(result, final) {
24097
24138
  if (result.issues.length) {
@@ -33622,9 +33663,15 @@ function generateNullableCheck(doc, ctx2, schema, accessor, buildsValue = true)
33622
33663
  doc.write(`}`);
33623
33664
  return outputVar;
33624
33665
  }
33666
+ function generateSizeGate(doc, schema, size) {
33667
+ for (const [max, check2] of sizeCaps(schema._zod.def.checks)) {
33668
+ doc.write(`if (${size} > ${numericOperand(max, check2._zod.def.check)}) return INVALID;`);
33669
+ }
33670
+ }
33625
33671
  function generateArrayCheck(doc, ctx2, schema, accessor, buildsValue = true) {
33626
33672
  const def = schema._zod.def;
33627
33673
  doc.write(`if (!Array.isArray(${accessor})) return INVALID;`);
33674
+ generateSizeGate(doc, schema, `${accessor}.length`);
33628
33675
  const outputVar = buildsValue ? newVar(ctx2) : null;
33629
33676
  const iVar = newVar(ctx2);
33630
33677
  const elemVar = newVar(ctx2);
@@ -34024,6 +34071,7 @@ function literalPropertyKey(ctx2, key) {
34024
34071
  function generateMapCheck(doc, ctx2, schema, accessor) {
34025
34072
  const def = schema._zod.def;
34026
34073
  doc.write(`if (!(${accessor} instanceof Map)) return INVALID;`);
34074
+ generateSizeGate(doc, schema, `${accessor}.size`);
34027
34075
  const outputVar = newVar(ctx2);
34028
34076
  const kVar = newVar(ctx2);
34029
34077
  const valVar = newVar(ctx2);
@@ -34040,6 +34088,7 @@ function generateMapCheck(doc, ctx2, schema, accessor) {
34040
34088
  function generateSetCheck(doc, ctx2, schema, accessor) {
34041
34089
  const def = schema._zod.def;
34042
34090
  doc.write(`if (!(${accessor} instanceof Set)) return INVALID;`);
34091
+ generateSizeGate(doc, schema, `${accessor}.size`);
34043
34092
  const outputVar = newVar(ctx2);
34044
34093
  const valVar = newVar(ctx2);
34045
34094
  doc.write(`const ${outputVar} = new Set();`);
@@ -158824,18 +158873,71 @@ var SysMLErrorListener = class extends BaseErrorListener {
158824
158873
  }
158825
158874
  };
158826
158875
 
158876
+ // server/src/parser/positionUtils.ts
158877
+ function normalizeUtf16Columns(text, tokens, errors) {
158878
+ if (!/[\uD800-\uDBFF][\uDC00-\uDFFF]/.test(text)) return;
158879
+ const columns = /* @__PURE__ */ new Map();
158880
+ const lines = text.split("\n");
158881
+ for (let line = 0; line < lines.length; line++) {
158882
+ if (!/[\uD800-\uDBFF][\uDC00-\uDFFF]/.test(lines[line])) continue;
158883
+ const offsets = [0];
158884
+ for (const character of lines[line]) offsets.push(offsets[offsets.length - 1] + character.length);
158885
+ columns.set(line, offsets);
158886
+ }
158887
+ for (const token of tokens) {
158888
+ token.column = columns.get(token.line - 1)?.[token.column] ?? token.column;
158889
+ }
158890
+ for (const error62 of errors) {
158891
+ error62.column = columns.get(error62.line)?.[error62.column] ?? error62.column;
158892
+ }
158893
+ }
158894
+ function tokenToPosition(token) {
158895
+ return {
158896
+ line: (token.line ?? 1) - 1,
158897
+ character: token.column ?? 0
158898
+ };
158899
+ }
158900
+ function tokenToRange(token) {
158901
+ const start = tokenToPosition(token);
158902
+ const length = token.text?.length ?? 1;
158903
+ return {
158904
+ start,
158905
+ end: { line: start.line, character: start.character + length }
158906
+ };
158907
+ }
158908
+ function contextToRange(ctx2) {
158909
+ const startToken = ctx2.start;
158910
+ const stopToken = ctx2.stop ?? ctx2.start;
158911
+ if (!startToken) {
158912
+ return { start: { line: 0, character: 0 }, end: { line: 0, character: 0 } };
158913
+ }
158914
+ const start = {
158915
+ line: (startToken.line ?? 1) - 1,
158916
+ character: startToken.column ?? 0
158917
+ };
158918
+ const end = stopToken ? {
158919
+ line: (stopToken.line ?? 1) - 1,
158920
+ character: (stopToken.column ?? 0) + (stopToken.text?.length ?? 1)
158921
+ } : { line: start.line, character: start.character + 1 };
158922
+ return { start, end };
158923
+ }
158924
+
158827
158925
  // server/src/parser/parseDocument.ts
158926
+ function withUtf16Columns(text, result) {
158927
+ normalizeUtf16Columns(text, result.tokenStream.getTokens(), result.errors);
158928
+ return result;
158929
+ }
158828
158930
  function parseDocument(text) {
158829
158931
  const result = parseDocumentCore(text);
158830
158932
  if (result.errors.length > 0 && hasStaleDfaStates()) {
158831
158933
  markDfaNotPreSeeded();
158832
158934
  clearAllDFAStates();
158833
- return parseDocumentLL(text, result.lexer, result.tokenStream);
158935
+ return withUtf16Columns(text, parseDocumentLL(text, result.lexer, result.tokenStream));
158834
158936
  }
158835
158937
  if (isDfaPreSeeded()) {
158836
158938
  markDfaNotPreSeeded();
158837
158939
  }
158838
- return result;
158940
+ return withUtf16Columns(text, result);
158839
158941
  }
158840
158942
  function parseDocumentCore(text) {
158841
158943
  const inputStream = CharStream.fromString(text);
@@ -158924,10 +159026,152 @@ var _batchDefaultStrategy = new DefaultErrorStrategy();
158924
159026
  // server/src/providers/semanticValidator.ts
158925
159027
  var import_node = __toESM(require_node3());
158926
159028
 
159029
+ // server/src/utils/sysmlKeywords.ts
159030
+ var SYSML_KEYWORDS_ARRAY = SysMLv2Lexer.literalNames.filter((n2) => n2 != null).map((n2) => n2.replace(/^'|'$/g, "")).filter((n2) => /^[a-z]+$/.test(n2)).sort();
159031
+ var SYSML_KEYWORDS = new Set(SYSML_KEYWORDS_ARRAY);
159032
+
158927
159033
  // server/src/utils/identUtils.ts
159034
+ function isIdentStart(c) {
159035
+ return c >= 65 && c <= 90 || c >= 97 && c <= 122 || c === 95;
159036
+ }
158928
159037
  function isIdentPart(c) {
158929
159038
  return c >= 65 && c <= 90 || c >= 97 && c <= 122 || c >= 48 && c <= 57 || c === 95;
158930
159039
  }
159040
+ var ESCAPES = {
159041
+ b: "\b",
159042
+ t: " ",
159043
+ n: "\n",
159044
+ f: "\f",
159045
+ r: "\r",
159046
+ "'": "'",
159047
+ '"': '"',
159048
+ "\\": "\\"
159049
+ };
159050
+ function unquoteName(text) {
159051
+ if (!text.startsWith("'") || !text.endsWith("'")) return text;
159052
+ return text.slice(1, -1).replace(/\\([btnfr'"\\])/g, (_, ch) => ESCAPES[ch]);
159053
+ }
159054
+ function quoteName(name) {
159055
+ if (/^[A-Za-z_][A-Za-z_0-9]*$/.test(name) && !SYSML_KEYWORDS.has(name)) return name;
159056
+ const escaped = name.replace(/[\\'\b\t\n\f\r]/g, (ch) => {
159057
+ const entry = Object.entries(ESCAPES).find(([, value]) => value === ch);
159058
+ return `\\${entry[0]}`;
159059
+ });
159060
+ return `'${escaped}'`;
159061
+ }
159062
+ function splitQualifiedName(text) {
159063
+ const parts = [];
159064
+ let start = 0;
159065
+ let quoted = false;
159066
+ for (let i = 0; i < text.length; i++) {
159067
+ if (quoted && text[i] === "\\") {
159068
+ i++;
159069
+ continue;
159070
+ }
159071
+ if (text[i] === "'" && (quoted || i === start)) quoted = !quoted;
159072
+ if (!quoted && text.startsWith("::", i)) {
159073
+ parts.push(unquoteName(text.slice(start, i).trim()));
159074
+ start = i + 2;
159075
+ i++;
159076
+ }
159077
+ }
159078
+ parts.push(unquoteName(text.slice(start).trim()));
159079
+ return parts;
159080
+ }
159081
+ function joinQualifiedName(parts) {
159082
+ return parts.map((part) => /::|['\\\r\n\t\b\f]/.test(part) ? quoteName(part) : part).join("::");
159083
+ }
159084
+ function readNameAt(text, start, allowIncomplete = false) {
159085
+ if (text[start] === "'") {
159086
+ let end2 = start + 1;
159087
+ while (end2 < text.length && text[end2] !== "'") {
159088
+ if (text[end2] === "\r" || text[end2] === "\n") return void 0;
159089
+ if (text[end2] === "\\") {
159090
+ if (!Object.hasOwn(ESCAPES, text[end2 + 1])) return void 0;
159091
+ end2++;
159092
+ }
159093
+ end2++;
159094
+ }
159095
+ if (end2 >= text.length) {
159096
+ return allowIncomplete ? { name: unquoteName(`${text.slice(start)}'`), start, end: text.length } : void 0;
159097
+ }
159098
+ if (end2 === start + 1 && !allowIncomplete) return void 0;
159099
+ return { name: unquoteName(text.slice(start, end2 + 1)), start, end: end2 + 1 };
159100
+ }
159101
+ if (!isIdentStart(text.charCodeAt(start))) return void 0;
159102
+ let end = start + 1;
159103
+ while (end < text.length && isIdentPart(text.charCodeAt(end))) end++;
159104
+ return { name: text.slice(start, end), start, end };
159105
+ }
159106
+ function readQualifiedNameAt(text, start, allowIncomplete = false) {
159107
+ const first = readNameAt(text, start, allowIncomplete);
159108
+ if (!first) return void 0;
159109
+ const segments = [first];
159110
+ let end = first.end;
159111
+ while (end < text.length) {
159112
+ let next = end;
159113
+ while (/\s/.test(text[next] ?? "") && next < text.length) next++;
159114
+ if (!text.startsWith("::", next)) break;
159115
+ next += 2;
159116
+ while (/\s/.test(text[next] ?? "") && next < text.length) next++;
159117
+ const segment = readNameAt(text, next, allowIncomplete);
159118
+ if (!segment) break;
159119
+ segments.push(segment);
159120
+ end = segment.end;
159121
+ }
159122
+ return { name: joinQualifiedName(segments.map((s) => s.name)), start, end, segments };
159123
+ }
159124
+ function* scanQualifiedNames(text, allowIncomplete = false) {
159125
+ let i = 0;
159126
+ while (i < text.length) {
159127
+ if (text.startsWith("//", i)) {
159128
+ const end = text.indexOf("\n", i + 2);
159129
+ i = end < 0 ? text.length : end + 1;
159130
+ } else if (text.startsWith("/*", i)) {
159131
+ const end = text.indexOf("*/", i + 2);
159132
+ i = end < 0 ? text.length : end + 2;
159133
+ } else if (text[i] === '"') {
159134
+ i++;
159135
+ while (i < text.length && text[i] !== '"') i += text[i] === "\\" ? 2 : 1;
159136
+ i++;
159137
+ } else if (/\d/.test(text[i]) || text[i] === "." && /\d/.test(text[i + 1] ?? "")) {
159138
+ const number4 = text.slice(i).match(/^(?:\d+(?:\.\d*)?|\.\d+)(?:[eE][+-]?\d+)?/);
159139
+ i += number4[0].length;
159140
+ } else {
159141
+ const name = readQualifiedNameAt(text, i, allowIncomplete);
159142
+ if (name) {
159143
+ yield name;
159144
+ i = name.end;
159145
+ } else if (text[i] === "'") {
159146
+ i++;
159147
+ while (i < text.length && text[i] !== "'" && text[i] !== "\n") {
159148
+ i += text[i] === "\\" ? 2 : 1;
159149
+ }
159150
+ if (text[i] === "'") i++;
159151
+ } else {
159152
+ i++;
159153
+ }
159154
+ }
159155
+ }
159156
+ }
159157
+ function* scanFeaturePaths(text) {
159158
+ const names = [...scanQualifiedNames(text)];
159159
+ for (let i = 0; i < names.length; i++) {
159160
+ const first = names[i];
159161
+ const parts = [first.name];
159162
+ const qualifiedNames = [first];
159163
+ let end = first.end;
159164
+ while (i + 1 < names.length && /^\s*\.\s*$/.test(text.slice(end, names[i + 1].start))) {
159165
+ parts.push(names[++i].name);
159166
+ qualifiedNames.push(names[i]);
159167
+ end = names[i].end;
159168
+ }
159169
+ yield { name: parts.join("."), start: first.start, end, qualifiedNames, parts: parts.map((part) => {
159170
+ const segments = splitQualifiedName(part);
159171
+ return segments.length === 1 ? segments[0] : part;
159172
+ }) };
159173
+ }
159174
+ }
158931
159175
  function stripComments(text) {
158932
159176
  return text.replace(/\/\*[\s\S]*?\*\//g, (m2) => m2.replace(/[^\n]/g, " ")).replace(/\/\/[^\n]*/g, (m2) => " ".repeat(m2.length));
158933
159177
  }
@@ -158937,10 +159181,12 @@ var index;
158937
159181
  var typeIndex;
158938
159182
  function resolveLibraryType(name) {
158939
159183
  if (!typeIndex) return void 0;
159184
+ const segments = splitQualifiedName(name);
159185
+ name = segments.length === 1 ? segments[0] : joinQualifiedName(segments);
158940
159186
  const exact = typeIndex.get(name);
158941
159187
  if (exact) return exact;
158942
- if (name.includes("::")) {
158943
- const member = name.split("::").pop();
159188
+ if (segments.length > 1) {
159189
+ const member = segments[segments.length - 1];
158944
159190
  return typeIndex.get(member);
158945
159191
  }
158946
159192
  return void 0;
@@ -159135,20 +159381,31 @@ var NamespaceResolver = class {
159135
159381
  * namespace.
159136
159382
  */
159137
159383
  isLocallyVisible(symbol2, name, indexes) {
159138
- return this.resolveQualifiedNameFrom(ownerKeyOf(symbol2, indexes.byId), name, indexes) !== void 0;
159384
+ return this.resolveNameFrom(symbol2, name, indexes) !== void 0;
159385
+ }
159386
+ /**
159387
+ * Resolve a (possibly qualified) name from the namespace containing
159388
+ * `symbol`, respecting namespace membership and visibility.
159389
+ */
159390
+ resolveNameFrom(symbol2, name, indexes) {
159391
+ return this.resolveQualifiedNameFrom(ownerKeyOf(symbol2, indexes.byId), name, indexes);
159392
+ }
159393
+ /** Resolve an editor reference within its enclosing namespace, including the root. */
159394
+ resolveNameIn(namespace, name, indexes) {
159395
+ return this.resolveQualifiedNameFrom(namespace ? namespaceKeyOf(namespace) : "", name, indexes);
159139
159396
  }
159140
159397
  /**
159141
159398
  * Resolve a (possibly qualified) name to its symbol per §7.5.1, searching
159142
159399
  * outward from namespace `start` and its enclosing namespaces (its own resolved
159143
159400
  * members first, then its parent's, ...). Shared by `isLocallyVisible` (an
159144
- * ordinary reference resolving relative to its own enclosing namespace) and
159145
- * import-target resolution (an `import` declaration's target is itself a
159401
+ * ordinary reference resolving relative to its own enclosing namespace),
159402
+ * `resolveNameFrom`, and import-target resolution (an `import` declaration's target is itself a
159146
159403
  * qualifiedName, resolved the same relative way -- not as an absolute/global
159147
159404
  * name -- so a bare `import C;` inside a nested package can pick up a `C`
159148
159405
  * its own enclosing package already imported, per §7.5.1/§7.5.3).
159149
159406
  */
159150
159407
  resolveQualifiedNameFrom(start, name, indexes) {
159151
- const [first, ...rest] = name.split("::");
159408
+ const [first, ...rest] = splitQualifiedName(name);
159152
159409
  let resolved;
159153
159410
  for (const ancestor of this.namespaceAncestorsOf(start, indexes)) {
159154
159411
  const candidates = this.getResolvedMembers(ancestor, indexes).get(first);
@@ -159315,6 +159572,9 @@ var NamespaceResolver = class {
159315
159572
  };
159316
159573
  for (const owned of indexes.byParent.get(namespace) ?? []) {
159317
159574
  addMember(owned.name, { symbol: owned, visibility: owned.visibility ?? "public" });
159575
+ if (owned.shortName) {
159576
+ addMember(owned.shortName, { symbol: owned, visibility: owned.visibility ?? "public" });
159577
+ }
159318
159578
  }
159319
159579
  perIndexesCache.set(namespace, members2);
159320
159580
  const owner = typeof namespace === "string" ? indexes.byQualifiedName.get(namespace) : namespace;
@@ -159350,13 +159610,17 @@ var NamespaceResolver = class {
159350
159610
  switch (imp.kind) {
159351
159611
  case "membership": {
159352
159612
  const target = this.resolveQualifiedNameFrom(importingNamespace, imp.target, indexes);
159353
- if (target) addMember(target.name, { symbol: target, visibility: imp.visibility });
159613
+ if (target) {
159614
+ addMember(target.name, { symbol: target, visibility: imp.visibility });
159615
+ if (target.shortName) addMember(target.shortName, { symbol: target, visibility: imp.visibility });
159616
+ }
159354
159617
  break;
159355
159618
  }
159356
159619
  case "membership-deep": {
159357
159620
  const target = this.resolveQualifiedNameFrom(importingNamespace, imp.target, indexes);
159358
159621
  if (target) {
159359
159622
  addMember(target.name, { symbol: target, visibility: imp.visibility });
159623
+ if (target.shortName) addMember(target.shortName, { symbol: target, visibility: imp.visibility });
159360
159624
  this.importVisibleMembers(namespaceKeyOf(target), imp.visibility, indexes, addMember, true);
159361
159625
  }
159362
159626
  break;
@@ -159412,42 +159676,6 @@ var NamespaceResolver = class {
159412
159676
  }
159413
159677
  };
159414
159678
 
159415
- // server/src/parser/positionUtils.ts
159416
- function tokenToPosition(token) {
159417
- return {
159418
- line: (token.line ?? 1) - 1,
159419
- character: token.column ?? 0
159420
- };
159421
- }
159422
- function tokenToRange(token) {
159423
- const start = tokenToPosition(token);
159424
- const length = token.text?.length ?? 1;
159425
- return {
159426
- start,
159427
- end: { line: start.line, character: start.character + length }
159428
- };
159429
- }
159430
- function contextToRange(ctx2) {
159431
- const startToken = ctx2.start;
159432
- const stopToken = ctx2.stop ?? ctx2.start;
159433
- if (!startToken) {
159434
- return { start: { line: 0, character: 0 }, end: { line: 0, character: 0 } };
159435
- }
159436
- const start = {
159437
- line: (startToken.line ?? 1) - 1,
159438
- character: startToken.column ?? 0
159439
- };
159440
- const end = stopToken ? {
159441
- line: (stopToken.line ?? 1) - 1,
159442
- character: (stopToken.column ?? 0) + (stopToken.text?.length ?? 1)
159443
- } : { line: start.line, character: start.character + 1 };
159444
- return { start, end };
159445
- }
159446
-
159447
- // server/src/utils/sysmlKeywords.ts
159448
- var SYSML_KEYWORDS_ARRAY = SysMLv2Lexer.literalNames.filter((n2) => n2 != null).map((n2) => n2.replace(/^'|'$/g, "")).filter((n2) => /^[a-z]+$/.test(n2)).sort();
159449
- var SYSML_KEYWORDS = new Set(SYSML_KEYWORDS_ARRAY);
159450
-
159451
159679
  // server/src/utils/names.ts
159452
159680
  var BASIC_NAME = /^[A-Za-z_][A-Za-z0-9_]*$/;
159453
159681
  function escapeName(name) {
@@ -160061,7 +160289,7 @@ var RE_SPEC_WITH_SUBSETS = /(?:specializes|subsets|:>|:>>)\s*('[^']+'|[A-Za-z_]\
160061
160289
  var RE_DEFINED_BY = /definedby\s*([A-Za-z_]\w*(?:::\w+)*(?:\s*,\s*[A-Za-z_]\w*(?:::\w+)*)*)/;
160062
160290
  var MAX_RULE_SEARCH_DEPTH = 6;
160063
160291
  var RE_TYPING = /:(?![:>])\s*('[^']+'|[A-Za-z_]\w*(?:::\w+)*)/;
160064
- var RE_QUOTED_NAME = /'([^']+)'/;
160292
+ var RE_QUOTED_NAME = /^\s*(?:\$::)?(?:(?:[A-Za-z_]\w*|'\d+')::)*'(\d+)'/;
160065
160293
  var RE_IDENT_START = /^([A-Za-z_]\w*(?:::\w+)*)/;
160066
160294
  var SymbolTable = class {
160067
160295
  /** All symbols indexed by qualified name */
@@ -160128,7 +160356,12 @@ var SymbolTable = class {
160128
160356
  * Find a symbol by name (simple name, not qualified).
160129
160357
  */
160130
160358
  findByName(name) {
160131
- return this.symbolsByName.get(name) ?? [];
160359
+ const exact = this.symbolsByName.get(name);
160360
+ if (exact) return exact;
160361
+ const segments = splitQualifiedName(name);
160362
+ if (segments.length === 1) return this.symbolsByName.get(segments[0]) ?? [];
160363
+ const qualified = this.getSymbol(joinQualifiedName(segments));
160364
+ return qualified ? [qualified] : [];
160132
160365
  }
160133
160366
  /**
160134
160367
  * Find all symbols in a given URI.
@@ -160635,10 +160868,11 @@ var SymbolTable = class {
160635
160868
  const anonymous = !declaredName;
160636
160869
  const name = declaredName ?? "";
160637
160870
  const shortName = transition || isFlowUsage(kind) && !declaredName ? void 0 : this.extractShortName(ctx2);
160638
- const qualifiedName = anonymous || owner && owner.qualifiedName === void 0 ? void 0 : owner ? `${owner.qualifiedName}::${name}` : name;
160871
+ const qualifiedName = anonymous || owner && owner.qualifiedName === void 0 ? void 0 : owner ? `${owner.qualifiedName}::${joinQualifiedName([name])}` : joinQualifiedName([name]);
160639
160872
  const selectionRange = anonymous ? ctx2.start ? tokenToRange(ctx2.start) : range : this.extractNameRange(ctx2) ?? range;
160640
160873
  const typeNames = isFlowUsage(kind) ? this.extractFlowTypeNames(ctx2) : transition ? this.extractTransitionTypeNames(ctx2) : this.extractTypeNames(ctx2);
160641
160874
  const specializationNames = this.extractSpecializationNames(ctx2);
160875
+ const redefinedFeatureTargets = this.extractRedefinedFeatureTargets(ctx2);
160642
160876
  const typeName = typeNames[0];
160643
160877
  const documentation = this.extractDocumentation(ctx2);
160644
160878
  const visibility = this.extractVisibility(ctx2);
@@ -160669,6 +160903,7 @@ var SymbolTable = class {
160669
160903
  typeName,
160670
160904
  typeNames,
160671
160905
  specializationNames,
160906
+ redefinedFeatureTargets: redefinedFeatureTargets.length > 0 ? redefinedFeatureTargets : void 0,
160672
160907
  documentation,
160673
160908
  visibility,
160674
160909
  source: transition?.source,
@@ -160793,7 +161028,10 @@ var SymbolTable = class {
160793
161028
  }
160794
161029
  /** Remove SysML quoting while retaining qualified and dotted references. */
160795
161030
  cleanTransitionText(text) {
160796
- const cleaned = text.replace(/'([^']+)'/g, "$1").trim();
161031
+ const cleaned = text.replace(
161032
+ /'(?:\\.|[^'\\])*'/g,
161033
+ (name) => joinQualifiedName([unquoteName(name)])
161034
+ ).trim();
160797
161035
  return cleaned || void 0;
160798
161036
  }
160799
161037
  /** Extract explicit first/then successions owned by an action body. */
@@ -160920,15 +161158,28 @@ var SymbolTable = class {
160920
161158
  * such as `#metadata`.
160921
161159
  */
160922
161160
  findOwnHeaderRule(ctx2, ruleIndex) {
161161
+ const matches = [];
161162
+ this.findOwnHeaderRules(ctx2, ruleIndex, matches, true);
161163
+ return matches[0];
161164
+ }
161165
+ findOwnHeaderRules(ctx2, ruleIndex, matches, firstOnly = false) {
160923
161166
  for (let i = 0; i < ctx2.getChildCount(); i++) {
160924
161167
  const child = ctx2.getChild(i);
160925
161168
  if (!(child instanceof ParserRuleContext)) continue;
160926
- if (child.ruleIndex === ruleIndex) return child;
161169
+ if (child.ruleIndex === ruleIndex) {
161170
+ matches.push(child);
161171
+ if (firstOnly) return;
161172
+ continue;
161173
+ }
160927
161174
  if (RULE_INDEX_TO_KIND.has(child.ruleIndex) || BODY_RULE_INDICES.has(child.ruleIndex) || child.ruleIndex === SysMLv2Parser.RULE_valuePart || FLOW_PART_RULE_INDICES.has(child.ruleIndex) || child.ruleIndex === SysMLv2Parser.RULE_ownedCrossMultiplicityMember || this.isPrefixOrExtensionContext(child)) continue;
160928
- const found = this.findOwnHeaderRule(child, ruleIndex);
160929
- if (found) return found;
161175
+ this.findOwnHeaderRules(child, ruleIndex, matches, firstOnly);
161176
+ if (firstOnly && matches.length > 0) return;
160930
161177
  }
160931
- return void 0;
161178
+ }
161179
+ extractRedefinedFeatureTargets(ctx2) {
161180
+ const targets = [];
161181
+ this.findOwnHeaderRules(ctx2, SysMLv2Parser.RULE_ownedRedefinition, targets);
161182
+ return targets.map((target) => target.getText());
160932
161183
  }
160933
161184
  /**
160934
161185
  * A connection, interface or allocation usage's end reference paths, in
@@ -160953,16 +161204,10 @@ var SymbolTable = class {
160953
161204
  }
160954
161205
  /** The name of the feature a reference such as `a.b` or `P::a` ends at (`b`, `a`). */
160955
161206
  lastNameSegment(reference) {
160956
- const segment = reference.getText().split(/::|\./).pop();
160957
- return segment ? this.unquoteName(segment) : void 0;
161207
+ const names = [...scanQualifiedNames(reference.getText())];
161208
+ return names.at(-1)?.segments.at(-1)?.name;
160958
161209
  }
160959
- /**
160960
- * An element's declaration as written, without its body: its tokens up to
160961
- * its body or closing `;`, each exactly as written (a quoted name keeps its
160962
- * spaces), with one space wherever the source has whitespace or a comment
160963
- * between two of them (`connect a.p to b.p`, `connection : Conn`).
160964
- */
160965
- declarationText(ctx2) {
161210
+ declarationTokens(ctx2) {
160966
161211
  const tokens = [];
160967
161212
  const visit2 = (node2) => {
160968
161213
  for (let i = 0; i < node2.getChildCount(); i++) {
@@ -160977,6 +161222,16 @@ var SymbolTable = class {
160977
161222
  return false;
160978
161223
  };
160979
161224
  visit2(ctx2);
161225
+ return tokens;
161226
+ }
161227
+ /**
161228
+ * An element's declaration as written, without its body: its tokens up to
161229
+ * its body or closing `;`, each exactly as written (a quoted name keeps its
161230
+ * spaces), with one space wherever the source has whitespace or a comment
161231
+ * between two of them (`connect a.p to b.p`, `connection : Conn`).
161232
+ */
161233
+ declarationText(ctx2) {
161234
+ const tokens = this.declarationTokens(ctx2);
160980
161235
  let text = "";
160981
161236
  tokens.forEach((token, i) => {
160982
161237
  if (i > 0 && token.start > tokens[i - 1].stop + 1) text += " ";
@@ -161086,6 +161341,16 @@ var SymbolTable = class {
161086
161341
  * Extract the range of just the name token.
161087
161342
  */
161088
161343
  extractNameRange(ctx2) {
161344
+ if (ctx2.ruleIndex === SysMLv2Parser.RULE_identification || ctx2.ruleIndex === SysMLv2Parser.RULE_featureIdentification) {
161345
+ let name;
161346
+ for (let i = 0; i < ctx2.getChildCount(); i++) {
161347
+ const child = ctx2.getChild(i);
161348
+ if (child instanceof ParserRuleContext && child.ruleIndex === SysMLv2Parser.RULE_name) {
161349
+ name = child;
161350
+ }
161351
+ }
161352
+ if (name) return contextToRange(name);
161353
+ }
161089
161354
  for (let i = 0; i < ctx2.getChildCount(); i++) {
161090
161355
  const child = ctx2.getChild(i);
161091
161356
  if (child instanceof TerminalNode && this.isNameTerminal(child)) {
@@ -161117,17 +161382,16 @@ var SymbolTable = class {
161117
161382
  const names = [];
161118
161383
  this.collectTypeNamesFromTree(ctx2, names, 0);
161119
161384
  if (names.length > 0) return names;
161120
- const fullText = ctx2.getText();
161121
- const braceIdx = fullText.indexOf("{");
161122
- let text = braceIdx >= 0 ? fullText.substring(0, braceIdx) : fullText;
161385
+ const { text: declarationText, quotedName } = this.maskedDeclaration(ctx2);
161386
+ let text = declarationText;
161123
161387
  text = text.replace(RE_KEYWORD_TRUNCATE, "");
161124
161388
  const specMatch = text.match(RE_SPEC);
161125
161389
  if (specMatch) {
161126
161390
  const specStr = text.substring(text.indexOf(specMatch[0]) + specMatch[0].indexOf(specMatch[1]));
161127
161391
  for (const part of specStr.split(",")) {
161128
- const qm = part.match(RE_QUOTED_NAME);
161129
- if (qm) {
161130
- names.push(qm[1]);
161392
+ const quoted = quotedName(part);
161393
+ if (quoted !== void 0) {
161394
+ names.push(joinQualifiedName([quoted]));
161131
161395
  continue;
161132
161396
  }
161133
161397
  const m2 = part.trim().match(RE_IDENT_START);
@@ -161148,9 +161412,9 @@ var SymbolTable = class {
161148
161412
  const fullMatchIdx = text.indexOf(typingMatch[0]);
161149
161413
  const afterColon = text.substring(fullMatchIdx + 1).trim();
161150
161414
  for (const part of afterColon.split(",")) {
161151
- const qm = part.match(RE_QUOTED_NAME);
161152
- if (qm) {
161153
- names.push(qm[1]);
161415
+ const quoted = quotedName(part);
161416
+ if (quoted !== void 0) {
161417
+ names.push(joinQualifiedName([quoted]));
161154
161418
  continue;
161155
161419
  }
161156
161420
  const m2 = part.trim().match(RE_IDENT_START);
@@ -161160,6 +161424,30 @@ var SymbolTable = class {
161160
161424
  }
161161
161425
  return names;
161162
161426
  }
161427
+ /**
161428
+ * The declaration tokens before the value or body, with each lexer STRING token
161429
+ * replaced by a numbered placeholder (`'0'`, `'1'`, ...), and
161430
+ * `quotedName`, which turns a placeholder in a part of that text back into
161431
+ * the name, when it ends the qualified name the part starts with. SysML
161432
+ * 2.0 section 7.2.2 permits punctuation in unrestricted names (the STRING
161433
+ * lexer production), so fallback regexes must never see their `:`, `:>`,
161434
+ * `{` or keywords. Documentation is not a name token.
161435
+ */
161436
+ maskedDeclaration(ctx2) {
161437
+ const quoted = [];
161438
+ const valueStart = this.findOwnHeaderRule(ctx2, SysMLv2Parser.RULE_valuePart)?.start?.tokenIndex;
161439
+ const masked = this.declarationTokens(ctx2).filter((token) => valueStart === void 0 || token.tokenIndex < valueStart).map((token) => {
161440
+ const text = token.text ?? "";
161441
+ return token.type === SysMLv2Lexer.STRING ? `'${quoted.push(unquoteName(text)) - 1}'` : text;
161442
+ }).join("");
161443
+ return {
161444
+ text: masked,
161445
+ quotedName: (part) => {
161446
+ const qm = part.match(RE_QUOTED_NAME);
161447
+ return qm ? quoted[Number(qm[1])] : void 0;
161448
+ }
161449
+ };
161450
+ }
161163
161451
  /**
161164
161452
  * Extract only the specialization names (:> / specializes / subsets) from a context.
161165
161453
  * Uses the same tree-walk as extractTypeNames but restricted to
@@ -161170,17 +161458,15 @@ var SymbolTable = class {
161170
161458
  const names = [];
161171
161459
  this.collectNamesFromTree(ctx2, names, 0, TYPE_SPECIALIZATION_RULE_INDICES);
161172
161460
  if (names.length > 0) return names;
161173
- const fullText = ctx2.getText();
161174
- const braceIdx = fullText.indexOf("{");
161175
- let text = braceIdx >= 0 ? fullText.substring(0, braceIdx) : fullText;
161176
- text = text.replace(RE_KEYWORD_TRUNCATE_SPEC, "");
161461
+ const { text: declarationText, quotedName } = this.maskedDeclaration(ctx2);
161462
+ const text = declarationText.replace(RE_KEYWORD_TRUNCATE_SPEC, "");
161177
161463
  const specMatch = text.match(RE_SPEC_WITH_SUBSETS);
161178
161464
  if (specMatch) {
161179
161465
  const specStr = text.substring(text.indexOf(specMatch[0]) + specMatch[0].indexOf(specMatch[1]));
161180
161466
  for (const part of specStr.split(",")) {
161181
- const qm = part.match(RE_QUOTED_NAME);
161182
- if (qm) {
161183
- names.push(qm[1]);
161467
+ const quoted = quotedName(part);
161468
+ if (quoted !== void 0) {
161469
+ names.push(joinQualifiedName([quoted]));
161184
161470
  continue;
161185
161471
  }
161186
161472
  const m2 = part.trim().match(RE_IDENT_START);
@@ -161209,17 +161495,7 @@ var SymbolTable = class {
161209
161495
  if (!(child instanceof ParserRuleContext)) continue;
161210
161496
  const ri = child.ruleIndex;
161211
161497
  if (extractionRules.has(ri)) {
161212
- const childText = child.getText();
161213
- const stripped = childText.replace(/^(specializes|:>>|:>|:|definedby|subsets|redefines|references|conjugates|disjoints)/i, "");
161214
- for (const part of stripped.split(",")) {
161215
- const qm = part.match(/'([^']+)'/);
161216
- if (qm) {
161217
- names.push(qm[1]);
161218
- } else {
161219
- const m2 = part.match(/([A-Za-z_]\w*(?:::\w+)*)/);
161220
- if (m2) names.push(m2[1]);
161221
- }
161222
- }
161498
+ this.collectQualifiedTypeNames(child, names);
161223
161499
  } else if (
161224
161500
  // Recurse into declaration / part / body wrappers that may
161225
161501
  // contain nested typing rules (but NOT into body rules that
@@ -161232,6 +161508,17 @@ var SymbolTable = class {
161232
161508
  }
161233
161509
  }
161234
161510
  }
161511
+ collectQualifiedTypeNames(ctx2, names) {
161512
+ if (ctx2.ruleIndex === SysMLv2Parser.RULE_qualifiedName) {
161513
+ const name = this.extractTextFromSubtree(ctx2);
161514
+ if (name) names.push(name);
161515
+ return;
161516
+ }
161517
+ for (let i = 0; i < ctx2.getChildCount(); i++) {
161518
+ const child = ctx2.getChild(i);
161519
+ if (child instanceof ParserRuleContext) this.collectQualifiedTypeNames(child, names);
161520
+ }
161521
+ }
161235
161522
  /**
161236
161523
  * Extract documentation owned by this element.
161237
161524
  *
@@ -161392,10 +161679,7 @@ var SymbolTable = class {
161392
161679
  * Returns the text unchanged if not quoted.
161393
161680
  */
161394
161681
  unquoteName(text) {
161395
- if (this.isQuotedName(text)) {
161396
- return text.slice(1, -1);
161397
- }
161398
- return text;
161682
+ return unquoteName(text);
161399
161683
  }
161400
161684
  /**
161401
161685
  * Check if a text is a SysML keyword.
@@ -161683,7 +161967,7 @@ var SymbolTable = class {
161683
161967
  const child = ctx2.getChild(i);
161684
161968
  if (child instanceof TerminalNode) {
161685
161969
  const text = child.symbol.text;
161686
- if (text) parts.push(text);
161970
+ if (text) parts.push(child.symbol.type === SysMLv2Lexer.STRING ? joinQualifiedName([unquoteName(text)]) : text);
161687
161971
  } else if (child instanceof ParserRuleContext) {
161688
161972
  this.collectExposeText(child, parts);
161689
161973
  }
@@ -161745,17 +162029,18 @@ var SymbolTable = class {
161745
162029
  * Extract all text content from a subtree (concatenate terminal nodes).
161746
162030
  */
161747
162031
  extractTextFromSubtree(ctx2) {
162032
+ if (ctx2.ruleIndex === SysMLv2Parser.RULE_name) return unquoteName(ctx2.getText());
161748
162033
  const parts = [];
161749
162034
  for (let i = 0; i < ctx2.getChildCount(); i++) {
161750
162035
  const child = ctx2.getChild(i);
161751
162036
  if (child instanceof TerminalNode) {
161752
162037
  const text = child.symbol.text;
161753
162038
  if (text && this.isNameTerminal(child)) {
161754
- parts.push(this.unquoteName(text));
162039
+ parts.push(joinQualifiedName([this.unquoteName(text)]));
161755
162040
  }
161756
162041
  } else if (child instanceof ParserRuleContext) {
161757
162042
  const sub = this.extractTextFromSubtree(child);
161758
- if (sub) parts.push(sub);
162043
+ if (sub) parts.push(child.ruleIndex === SysMLv2Parser.RULE_name ? joinQualifiedName([sub]) : sub);
161759
162044
  }
161760
162045
  }
161761
162046
  return parts.length > 0 ? parts.join("::") : void 0;
@@ -161871,7 +162156,7 @@ function isISQValueType(name) {
161871
162156
  function resolveTypeName(typeName, symbol2, resolver, indexes, libraryNames) {
161872
162157
  const kwMatch = typeName.match(/^([A-Z][A-Za-z_0-9]*?)(redefines|subsets|references|connect|bind|default|via|accept|send|flow|allocate|assign|decide|merge|join|fork)([A-Z])/);
161873
162158
  const strippedTypeName = kwMatch ? kwMatch[1] : typeName;
161874
- const rootSegment = strippedTypeName.split("::")[0];
162159
+ const rootSegment = splitQualifiedName(strippedTypeName)[0];
161875
162160
  const resolved = resolver.isLocallyVisible(symbol2, strippedTypeName, indexes) || STANDARD_LIBRARY_TYPES.has(strippedTypeName) || STANDARD_LIBRARY_TYPES.has(rootSegment) || libraryNames.has(rootSegment) || isISQValueType(strippedTypeName) || resolveLibraryType(strippedTypeName) !== void 0 || resolveLibraryType(rootSegment) !== void 0 || // Names starting with lowercase are feature references (subsettings
161876
162161
  // via :>), not type references — don't flag them as unresolved types.
161877
162162
  strippedTypeName.charCodeAt(0) >= 97 && strippedTypeName.charCodeAt(0) <= 122;
@@ -163359,6 +163644,13 @@ var CONSTRAINT_KEYWORDS = /* @__PURE__ */ new Set([
163359
163644
  "assert",
163360
163645
  "assume"
163361
163646
  ]);
163647
+ var CONNECTOR_KINDS = /* @__PURE__ */ new Set([
163648
+ "connection" /* ConnectionUsage */,
163649
+ "interface" /* InterfaceUsage */,
163650
+ "allocation" /* AllocationUsage */,
163651
+ "flow" /* FlowUsage */,
163652
+ "succession flow" /* SuccessionFlowUsage */
163653
+ ]);
163362
163654
  var SemanticValidator = class _SemanticValidator {
163363
163655
  constructor(documentManager) {
163364
163656
  this.documentManager = documentManager;
@@ -163435,7 +163727,7 @@ var SemanticValidator = class _SemanticValidator {
163435
163727
  diagnostics.push(...this.checkAmbiguousNamespaceName(symbols, allSymbols));
163436
163728
  diagnostics.push(...this.checkUnusedDefinitions(allSymbols, uri));
163437
163729
  diagnostics.push(...this.checkRedefinitionMultiplicity(symbols, indexes, text));
163438
- diagnostics.push(...this.checkPortCompatibility(text, uri, indexes));
163730
+ diagnostics.push(...this.checkPortCompatibility(text, uri, symbols, indexes));
163439
163731
  diagnostics.push(...this.checkConstraintBodyReferences(text, uri, symbols, indexes));
163440
163732
  diagnostics.push(...this.checkCircularSpecialization(symbols, indexes));
163441
163733
  diagnostics.push(...this.checkUnsatisfiedRequirements(symbols, indexes));
@@ -163585,19 +163877,19 @@ var SemanticValidator = class _SemanticValidator {
163585
163877
  );
163586
163878
  const defsInScope = targetUri ? defs.filter((def) => def.uri === targetUri) : defs;
163587
163879
  const referencedTypes = new Set(
163588
- symbols.filter((s) => s.kind !== "package" /* Package */).flatMap((s) => s.typeNames)
163880
+ symbols.filter((s) => s.kind !== "package" /* Package */).flatMap((s) => s.typeNames.flatMap((name) => [name, splitQualifiedName(name).at(-1)]))
163589
163881
  );
163590
163882
  for (const s of symbols) {
163591
163883
  if (s.exposeTargets) {
163592
163884
  for (const target of s.exposeTargets) {
163593
- const simpleName = target.replace(/::\*{1,2}$/, "").split("::").pop();
163885
+ const simpleName = splitQualifiedName(target.replace(/::\*{1,2}$/, "")).pop();
163594
163886
  if (simpleName) referencedTypes.add(simpleName);
163595
163887
  }
163596
163888
  }
163597
163889
  }
163598
163890
  const diagnostics = [];
163599
163891
  for (const def of defsInScope) {
163600
- const isReferenced = referencedTypes.has(def.name);
163892
+ const isReferenced = referencedTypes.has(def.name) || def.shortName !== void 0 && referencedTypes.has(def.shortName);
163601
163893
  const hasBaseType = (def.typeNames?.length ?? 0) > 0;
163602
163894
  if (!isReferenced && !hasBaseType) {
163603
163895
  diagnostics.push({
@@ -163656,7 +163948,7 @@ var SemanticValidator = class _SemanticValidator {
163656
163948
  opts?.text ? [opts.text] : []
163657
163949
  ));
163658
163950
  if (opts?.text && opts.uri) {
163659
- diagnostics.push(...instance.checkPortCompatibility(opts.text, opts.uri, indexes));
163951
+ diagnostics.push(...instance.checkPortCompatibility(opts.text, opts.uri, symbolsInUri, indexes));
163660
163952
  diagnostics.push(...instance.checkConstraintBodyReferences(opts.text, opts.uri, symbolsInUri, indexes));
163661
163953
  }
163662
163954
  return instance.dedupeDiagnostics(diagnostics);
@@ -164019,17 +164311,21 @@ var SemanticValidator = class _SemanticValidator {
164019
164311
  * - The connection is within an interface usage
164020
164312
  * - Both ports are untyped (empty port defs with no features)
164021
164313
  */
164022
- checkPortCompatibility(text, uri, indexes) {
164314
+ checkPortCompatibility(text, uri, symbolsInUri, indexes) {
164023
164315
  if (!text) return [];
164024
164316
  const diagnostics = [];
164025
164317
  const lines = text.split("\n");
164026
- const re = /\bconnect\s+([A-Za-z_][\w.]*)\s+to\s+([A-Za-z_][\w.]*)/g;
164027
- let m2;
164028
- while ((m2 = re.exec(text)) !== null) {
164029
- const left = m2[1].split(".").pop();
164030
- const right = m2[2].split(".").pop();
164031
- const lSym = (indexes.portsByName.get(left) ?? [])[0];
164032
- const rSym = (indexes.portsByName.get(right) ?? [])[0];
164318
+ const paths = [...scanFeaturePaths(text)];
164319
+ for (let i = 0; i + 3 < paths.length; i++) {
164320
+ const [connect, leftEnd, to, rightEnd] = paths.slice(i, i + 4);
164321
+ if (text.slice(connect.start, connect.end) !== "connect" || text.slice(to.start, to.end) !== "to" || !/^\s+$/.test(text.slice(connect.end, leftEnd.start)) || !/^\s+$/.test(text.slice(leftEnd.end, to.start)) || !/^\s+$/.test(text.slice(to.end, rightEnd.start))) continue;
164322
+ const leftPath = [...leftEnd.parts];
164323
+ const rightPath = [...rightEnd.parts];
164324
+ const left = leftPath[leftPath.length - 1];
164325
+ const right = rightPath[rightPath.length - 1];
164326
+ const scope = this.connectorScope(symbolsInUri, this.indexToRange(text, connect.start, 0).start, indexes);
164327
+ const lSym = this.resolveConnectorEnd(leftPath, scope, indexes);
164328
+ const rSym = this.resolveConnectorEnd(rightPath, scope, indexes);
164033
164329
  if (!lSym || !rSym) continue;
164034
164330
  const lType = lSym.typeNames[0] ?? lSym.typeName;
164035
164331
  const rType = rSym.typeNames[0] ?? rSym.typeName;
@@ -164037,10 +164333,10 @@ var SemanticValidator = class _SemanticValidator {
164037
164333
  if (lType === "~" + rType || rType === "~" + lType) continue;
164038
164334
  if (lType.startsWith("~") && lType.slice(1) === rType) continue;
164039
164335
  if (rType.startsWith("~") && rType.slice(1) === lType) continue;
164040
- const matchLine = text.substring(0, m2.index).split("\n").length - 1;
164336
+ const matchLine = text.substring(0, connect.start).split("\n").length - 1;
164041
164337
  let insideInterfaceDef = false;
164042
- for (let i = matchLine; i >= 0 && i >= matchLine - 30; i--) {
164043
- const line = (lines[i] || "").trim();
164338
+ for (let i2 = matchLine; i2 >= 0 && i2 >= matchLine - 30; i2--) {
164339
+ const line = (lines[i2] || "").trim();
164044
164340
  if (/\binterface\s+def\b/.test(line)) {
164045
164341
  insideInterfaceDef = true;
164046
164342
  break;
@@ -164048,7 +164344,7 @@ var SemanticValidator = class _SemanticValidator {
164048
164344
  if (/^\s*package\b/.test(line)) break;
164049
164345
  }
164050
164346
  if (insideInterfaceDef) continue;
164051
- const precedingText = text.substring(Math.max(0, m2.index - 300), m2.index);
164347
+ const precedingText = text.substring(Math.max(0, connect.start - 300), connect.start);
164052
164348
  if (/\binterface\s+\w[\w']*(:\w[\w']*)?\s*$/m.test(precedingText)) continue;
164053
164349
  const lDefSyms = indexes.byName.get(lType) ?? [];
164054
164350
  const rDefSyms = indexes.byName.get(rType) ?? [];
@@ -164067,18 +164363,67 @@ var SemanticValidator = class _SemanticValidator {
164067
164363
  const hasSharedFeature = rChildren.some((c) => lChildNames.has(c.name));
164068
164364
  if (hasSharedFeature) continue;
164069
164365
  }
164070
- const range = this.indexToRange(text, m2.index, m2[0].length);
164366
+ const range = this.indexToRange(text, connect.start, rightEnd.end - connect.start);
164071
164367
  diagnostics.push({
164072
164368
  severity: import_node.DiagnosticSeverity.Warning,
164073
164369
  range,
164074
164370
  message: `Port compatibility issue: '${left}' (${lType}) is connected to '${right}' (${rType})`,
164075
164371
  source: "sysml",
164076
164372
  code: "incompatible-port-types",
164077
- data: { uri }
164373
+ data: { uri, left, right, leftType: lType }
164078
164374
  });
164079
164375
  }
164080
164376
  return diagnostics;
164081
164377
  }
164378
+ /**
164379
+ * The innermost element around `position` that owns a connector declared
164380
+ * there: the connector's own symbol, when it has one, is skipped.
164381
+ */
164382
+ connectorScope(symbols, position, indexes) {
164383
+ const before = (a, b) => a.line < b.line || a.line === b.line && a.character <= b.character;
164384
+ const size = (r) => (r.end.line - r.start.line) * 1e6 + (r.end.character - r.start.character);
164385
+ let scope;
164386
+ for (const s of symbols) {
164387
+ if (!before(s.range.start, position) || !before(position, s.range.end)) continue;
164388
+ if (!scope || size(s.range) < size(scope.range)) scope = s;
164389
+ }
164390
+ while (scope && CONNECTOR_KINDS.has(scope.kind)) scope = ownerOf2(scope, indexes);
164391
+ return scope;
164392
+ }
164393
+ /**
164394
+ * The port that a connector end (`a.p`, `a.p.q`) names, resolved from
164395
+ * `scope` outward: its first segment is a feature of `scope` or of one of
164396
+ * its owners, each next one a feature of the one before. Two parts can each
164397
+ * have a port of the same name, so an end is never matched by its last
164398
+ * segment alone, except when the path does not resolve and the workspace
164399
+ * has only one port of that name.
164400
+ */
164401
+ resolveConnectorEnd(path, scope, indexes) {
164402
+ let feature;
164403
+ for (let namespace = scope; namespace && !feature; namespace = ownerOf2(namespace, indexes)) {
164404
+ feature = this.findFeature(namespace, path[0], indexes);
164405
+ }
164406
+ for (const name of path.slice(1)) {
164407
+ feature = feature && this.findFeature(feature, name, indexes);
164408
+ }
164409
+ if (feature) return feature.kind === "port" /* PortUsage */ ? feature : void 0;
164410
+ const sameName = indexes.portsByName.get(path[path.length - 1]) ?? [];
164411
+ return sameName.length === 1 ? sameName[0] : void 0;
164412
+ }
164413
+ /** The feature `name` of `owner`: its own member, else a member of one of its types or their supertypes. */
164414
+ findFeature(owner, name, indexes) {
164415
+ const own2 = (indexes.byParent.get(namespaceKeyOf(owner)) ?? []).find((s) => s.name === name);
164416
+ if (own2) return own2;
164417
+ for (const typeName of owner.typeNames) {
164418
+ const type = this.namespaceResolver.resolveNameFrom(owner, typeName, indexes);
164419
+ if (!type || !isDefinition(type.kind)) continue;
164420
+ for (const definition of this.getSpecializationHierarchy(type, indexes).flat()) {
164421
+ const member = (indexes.byParent.get(namespaceKeyOf(definition)) ?? []).find((s) => s.name === name);
164422
+ if (member) return member;
164423
+ }
164424
+ }
164425
+ return void 0;
164426
+ }
164082
164427
  /**
164083
164428
  * Resolve the full type hierarchy for a type name by following
164084
164429
  * specialization chains transitively (max depth 10).
@@ -164126,17 +164471,13 @@ var SemanticValidator = class _SemanticValidator {
164126
164471
  }
164127
164472
  const parent = this.findConstraintScopeSymbol(symbolsInUri, indexes, b.startLine);
164128
164473
  if (!parent) continue;
164129
- const parentMembers = indexes.byParent.get(namespaceKeyOf(parent)) ?? [];
164474
+ const parentMembers = this.getConstraintScopeMembers(parent, indexes);
164130
164475
  if (parentMembers.length === 0) continue;
164131
- const ignoredRanges = this.getIgnoredBodyRanges(b.body);
164132
- const idRe = /\b([A-Za-z_][\w]*(?:\.[A-Za-z_][\w]*)*)\b/g;
164133
- let im;
164134
- while ((im = idRe.exec(b.body)) !== null) {
164135
- if (this.isIndexInRanges(im.index, ignoredRanges)) continue;
164136
- const expr = im[1];
164476
+ for (const reference of scanFeaturePaths(b.body)) {
164477
+ const expr = reference.name;
164137
164478
  if (this.isConstraintKeyword(expr)) continue;
164138
164479
  if (/^\d/.test(expr)) continue;
164139
- const path = expr.split(".");
164480
+ const path = [...reference.parts];
164140
164481
  const ok = this.resolvePathFromParent(path, parentMembers, indexes);
164141
164482
  if (ok) continue;
164142
164483
  if (path.length === 1) {
@@ -164145,14 +164486,14 @@ var SemanticValidator = class _SemanticValidator {
164145
164486
  continue;
164146
164487
  }
164147
164488
  }
164148
- const absoluteStart = b.bodyOffset + im.index;
164489
+ const absoluteStart = b.bodyOffset + reference.start;
164149
164490
  diagnostics.push({
164150
164491
  severity: import_node.DiagnosticSeverity.Warning,
164151
- range: this.indexToRange(text, absoluteStart, expr.length),
164492
+ range: this.indexToRange(text, absoluteStart, reference.end - reference.start),
164152
164493
  message: `Unresolved constraint reference '${expr}' in scope '${displayName(parent)}'`,
164153
164494
  source: "sysml",
164154
164495
  code: "unresolved-constraint-reference",
164155
- data: { uri }
164496
+ data: { uri, scopeName: parent.name }
164156
164497
  });
164157
164498
  }
164158
164499
  }
@@ -164185,18 +164526,135 @@ var SemanticValidator = class _SemanticValidator {
164185
164526
  const root = parentMembers.find((s) => s.name === path[0]);
164186
164527
  if (!root) return false;
164187
164528
  if (path.length === 1) return true;
164188
- let typeName = root.typeNames[0] ?? root.typeName;
164529
+ let current = root;
164189
164530
  for (let i = 1; i < path.length; i++) {
164531
+ const typeName = current.typeNames[0] ?? current.typeName;
164190
164532
  if (!typeName) return false;
164191
- const typeDefs = indexes.definitionsByName.get(typeName) ?? [];
164192
- const typeDef = typeDefs[0];
164193
- if (!typeDef) return false;
164194
- const member = (indexes.byParent.get(namespaceKeyOf(typeDef)) ?? []).find((s) => s.name === path[i]);
164533
+ const typeDef = this.namespaceResolver.resolveNameFrom(current, typeName, indexes);
164534
+ if (!typeDef || !isDefinition(typeDef.kind)) return false;
164535
+ const member = this.getConstraintScopeMembers(typeDef, indexes, true).find((s) => s.name === path[i]);
164195
164536
  if (!member) return false;
164196
- typeName = member.typeNames[0] ?? member.typeName;
164537
+ current = member;
164197
164538
  }
164198
164539
  return true;
164199
164540
  }
164541
+ getConstraintScopeMembers(scope, indexes, publicOnly = false) {
164542
+ const hierarchy = [[scope]];
164543
+ const visited = /* @__PURE__ */ new Set([scope]);
164544
+ let frontier = [scope];
164545
+ while (frontier.length > 0) {
164546
+ const next = [];
164547
+ for (const current of frontier) {
164548
+ for (const typeName of current.typeNames) {
164549
+ const supertype = this.namespaceResolver.resolveNameFrom(current, typeName, indexes);
164550
+ if (!supertype || !isDefinition(supertype.kind) || visited.has(supertype)) continue;
164551
+ visited.add(supertype);
164552
+ next.push(supertype);
164553
+ }
164554
+ }
164555
+ if (next.length > 0) hierarchy.push(next);
164556
+ frontier = next;
164557
+ }
164558
+ const membersByLevel = hierarchy.map((level) => level.flatMap((namespace) => indexes.byParent.get(namespaceKeyOf(namespace)) ?? []));
164559
+ const hiddenMembers = /* @__PURE__ */ new Set();
164560
+ for (let level = membersByLevel.length - 1; level >= 0; level--) {
164561
+ for (const redefining of membersByLevel[level]) {
164562
+ for (const target of redefining.redefinedFeatureTargets ?? []) {
164563
+ const owner = ownerOf2(redefining, indexes);
164564
+ if (!owner) continue;
164565
+ for (const candidate of this.resolveInheritedRedefinitionTarget(owner, target, hiddenMembers, indexes)) {
164566
+ hiddenMembers.add(candidate.symbolId);
164567
+ }
164568
+ }
164569
+ if (redefining.kind === "subject" /* SubjectUsage */) {
164570
+ const owner = ownerOf2(redefining, indexes);
164571
+ if (!owner) continue;
164572
+ for (const ancestor of this.getSpecializationHierarchy(owner, indexes).slice(1).flat()) {
164573
+ for (const candidate of indexes.byParent.get(namespaceKeyOf(ancestor)) ?? []) {
164574
+ if (candidate.kind === "subject" /* SubjectUsage */) hiddenMembers.add(candidate.symbolId);
164575
+ }
164576
+ }
164577
+ }
164578
+ }
164579
+ }
164580
+ const membersByName = /* @__PURE__ */ new Map();
164581
+ for (let level = 0; level < membersByLevel.length; level++) {
164582
+ for (const member of membersByLevel[level]) {
164583
+ if (level > 0 && member.visibility === "private") continue;
164584
+ if (publicOnly && member.visibility !== void 0 && member.visibility !== "public") continue;
164585
+ if (hiddenMembers.has(member.symbolId) || membersByName.has(member.name)) continue;
164586
+ membersByName.set(member.name, member);
164587
+ }
164588
+ }
164589
+ return [...membersByName.values()];
164590
+ }
164591
+ resolveInheritedRedefinitionTarget(owner, target, alreadyRedefined, indexes) {
164592
+ if (target.includes(".")) return [];
164593
+ const segments = target.split("::");
164594
+ const targetName = segments.pop()?.replace(/^'|'$/g, "");
164595
+ if (!targetName) return [];
164596
+ const qualifier = segments.join("::").replace(/^'|'$/g, "");
164597
+ const matches = /* @__PURE__ */ new Map();
164598
+ for (const supertype of this.resolveDirectSupertypes(owner, indexes)) {
164599
+ const branch = this.getSpecializationHierarchy(supertype, indexes);
164600
+ const anchors = qualifier ? branch.flat().filter((type) => this.matchesSpecializationQualifier(type, qualifier)) : [supertype];
164601
+ for (const anchor2 of anchors) {
164602
+ let frontier = [anchor2];
164603
+ const visited = new Set(frontier);
164604
+ const candidates = [];
164605
+ while (frontier.length > 0 && candidates.length === 0) {
164606
+ for (const type of frontier) {
164607
+ for (const member of indexes.byParent.get(namespaceKeyOf(type)) ?? []) {
164608
+ if (member.name === targetName && member.visibility !== "private" && !alreadyRedefined.has(member.symbolId)) {
164609
+ candidates.push(member);
164610
+ }
164611
+ }
164612
+ }
164613
+ if (candidates.length > 0) break;
164614
+ const next = /* @__PURE__ */ new Map();
164615
+ for (const type of frontier) {
164616
+ for (const parent of this.resolveDirectSupertypes(type, indexes)) {
164617
+ if (visited.has(parent)) continue;
164618
+ visited.add(parent);
164619
+ next.set(parent.symbolId, parent);
164620
+ }
164621
+ }
164622
+ frontier = [...next.values()];
164623
+ }
164624
+ for (const candidate of candidates) matches.set(candidate.symbolId, candidate);
164625
+ }
164626
+ }
164627
+ return matches.size === 1 ? [...matches.values()] : [];
164628
+ }
164629
+ resolveDirectSupertypes(scope, indexes) {
164630
+ const supertypes = /* @__PURE__ */ new Map();
164631
+ for (const typeName of scope.typeNames) {
164632
+ const supertype = this.namespaceResolver.resolveNameFrom(scope, typeName, indexes);
164633
+ if (supertype && isDefinition(supertype.kind)) supertypes.set(supertype.symbolId, supertype);
164634
+ }
164635
+ return [...supertypes.values()];
164636
+ }
164637
+ getSpecializationHierarchy(scope, indexes) {
164638
+ const levels = [[scope]];
164639
+ const visited = /* @__PURE__ */ new Set([scope]);
164640
+ let frontier = [scope];
164641
+ while (frontier.length > 0) {
164642
+ const next = [];
164643
+ for (const type of frontier) {
164644
+ for (const parent of this.resolveDirectSupertypes(type, indexes)) {
164645
+ if (visited.has(parent)) continue;
164646
+ visited.add(parent);
164647
+ next.push(parent);
164648
+ }
164649
+ }
164650
+ if (next.length > 0) levels.push(next);
164651
+ frontier = next;
164652
+ }
164653
+ return levels;
164654
+ }
164655
+ matchesSpecializationQualifier(type, qualifier) {
164656
+ return type.name === qualifier || type.qualifiedName === qualifier || type.qualifiedName?.endsWith(`::${qualifier}`) === true;
164657
+ }
164200
164658
  findContainingSymbolByLine(symbols, line) {
164201
164659
  return symbols.filter((s) => s.range.start.line <= line && s.range.end.line >= line).sort((a, b) => {
164202
164660
  const ar = (a.range.end.line - a.range.start.line) * 1e3 + (a.range.end.character - a.range.start.character);
@@ -164207,7 +164665,7 @@ var SemanticValidator = class _SemanticValidator {
164207
164665
  findConstraintScopeSymbol(symbolsInUri, indexes, line) {
164208
164666
  let scope = this.findContainingSymbolByLine(symbolsInUri, line);
164209
164667
  while (scope) {
164210
- const members2 = indexes.byParent.get(namespaceKeyOf(scope)) ?? [];
164668
+ const members2 = this.getConstraintScopeMembers(scope, indexes);
164211
164669
  if (members2.length > 0) return scope;
164212
164670
  if (!scope.parentId) return scope;
164213
164671
  scope = ownerOf2(scope, indexes);
@@ -164229,25 +164687,6 @@ var SemanticValidator = class _SemanticValidator {
164229
164687
  isConstraintKeyword(value) {
164230
164688
  return CONSTRAINT_KEYWORDS.has(value);
164231
164689
  }
164232
- getIgnoredBodyRanges(body) {
164233
- const ranges = [];
164234
- const blockRe = /\/\*[\s\S]*?\*\//g;
164235
- let m2;
164236
- while ((m2 = blockRe.exec(body)) !== null) {
164237
- ranges.push({ start: m2.index, end: m2.index + m2[0].length });
164238
- }
164239
- const lineRe = /\/\/[^\n\r]*/g;
164240
- while ((m2 = lineRe.exec(body)) !== null) {
164241
- ranges.push({ start: m2.index, end: m2.index + m2[0].length });
164242
- }
164243
- return ranges;
164244
- }
164245
- isIndexInRanges(index2, ranges) {
164246
- for (const r of ranges) {
164247
- if (index2 >= r.start && index2 < r.end) return true;
164248
- }
164249
- return false;
164250
- }
164251
164690
  hasDocumentationOnlyConstraintBody(body) {
164252
164691
  const trimmed = body.trim();
164253
164692
  if (!trimmed) return false;