sysml-v2-lsp 0.35.0 → 0.36.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.
@@ -3375,8 +3375,8 @@ var require_main2 = __commonJS({
3375
3375
  }
3376
3376
  uinteger2.is = is;
3377
3377
  })(uinteger || (exports3.uinteger = uinteger = {}));
3378
- var Position2;
3379
- (function(Position3) {
3378
+ var Position3;
3379
+ (function(Position4) {
3380
3380
  function create(line, character) {
3381
3381
  if (line === Number.MAX_VALUE) {
3382
3382
  line = uinteger.MAX_VALUE;
@@ -3386,31 +3386,31 @@ var require_main2 = __commonJS({
3386
3386
  }
3387
3387
  return { line, character };
3388
3388
  }
3389
- Position3.create = create;
3389
+ Position4.create = create;
3390
3390
  function is(value) {
3391
3391
  var candidate = value;
3392
3392
  return Is.objectLiteral(candidate) && Is.uinteger(candidate.line) && Is.uinteger(candidate.character);
3393
3393
  }
3394
- Position3.is = is;
3395
- })(Position2 || (exports3.Position = Position2 = {}));
3396
- var Range2;
3397
- (function(Range3) {
3394
+ Position4.is = is;
3395
+ })(Position3 || (exports3.Position = Position3 = {}));
3396
+ var Range3;
3397
+ (function(Range4) {
3398
3398
  function create(one, two, three, four) {
3399
3399
  if (Is.uinteger(one) && Is.uinteger(two) && Is.uinteger(three) && Is.uinteger(four)) {
3400
- return { start: Position2.create(one, two), end: Position2.create(three, four) };
3401
- } else if (Position2.is(one) && Position2.is(two)) {
3400
+ return { start: Position3.create(one, two), end: Position3.create(three, four) };
3401
+ } else if (Position3.is(one) && Position3.is(two)) {
3402
3402
  return { start: one, end: two };
3403
3403
  } else {
3404
3404
  throw new Error("Range#create called with invalid arguments[".concat(one, ", ").concat(two, ", ").concat(three, ", ").concat(four, "]"));
3405
3405
  }
3406
3406
  }
3407
- Range3.create = create;
3407
+ Range4.create = create;
3408
3408
  function is(value) {
3409
3409
  var candidate = value;
3410
- return Is.objectLiteral(candidate) && Position2.is(candidate.start) && Position2.is(candidate.end);
3410
+ return Is.objectLiteral(candidate) && Position3.is(candidate.start) && Position3.is(candidate.end);
3411
3411
  }
3412
- Range3.is = is;
3413
- })(Range2 || (exports3.Range = Range2 = {}));
3412
+ Range4.is = is;
3413
+ })(Range3 || (exports3.Range = Range3 = {}));
3414
3414
  var Location2;
3415
3415
  (function(Location3) {
3416
3416
  function create(uri, range) {
@@ -3419,7 +3419,7 @@ var require_main2 = __commonJS({
3419
3419
  Location3.create = create;
3420
3420
  function is(value) {
3421
3421
  var candidate = value;
3422
- return Is.objectLiteral(candidate) && Range2.is(candidate.range) && (Is.string(candidate.uri) || Is.undefined(candidate.uri));
3422
+ return Is.objectLiteral(candidate) && Range3.is(candidate.range) && (Is.string(candidate.uri) || Is.undefined(candidate.uri));
3423
3423
  }
3424
3424
  Location3.is = is;
3425
3425
  })(Location2 || (exports3.Location = Location2 = {}));
@@ -3431,7 +3431,7 @@ var require_main2 = __commonJS({
3431
3431
  LocationLink2.create = create;
3432
3432
  function is(value) {
3433
3433
  var candidate = value;
3434
- return Is.objectLiteral(candidate) && Range2.is(candidate.targetRange) && Is.string(candidate.targetUri) && Range2.is(candidate.targetSelectionRange) && (Range2.is(candidate.originSelectionRange) || Is.undefined(candidate.originSelectionRange));
3434
+ return Is.objectLiteral(candidate) && Range3.is(candidate.targetRange) && Is.string(candidate.targetUri) && Range3.is(candidate.targetSelectionRange) && (Range3.is(candidate.originSelectionRange) || Is.undefined(candidate.originSelectionRange));
3435
3435
  }
3436
3436
  LocationLink2.is = is;
3437
3437
  })(LocationLink || (exports3.LocationLink = LocationLink = {}));
@@ -3463,7 +3463,7 @@ var require_main2 = __commonJS({
3463
3463
  ColorInformation2.create = create;
3464
3464
  function is(value) {
3465
3465
  var candidate = value;
3466
- return Is.objectLiteral(candidate) && Range2.is(candidate.range) && Color.is(candidate.color);
3466
+ return Is.objectLiteral(candidate) && Range3.is(candidate.range) && Color.is(candidate.color);
3467
3467
  }
3468
3468
  ColorInformation2.is = is;
3469
3469
  })(ColorInformation || (exports3.ColorInformation = ColorInformation = {}));
@@ -3574,7 +3574,7 @@ var require_main2 = __commonJS({
3574
3574
  function is(value) {
3575
3575
  var _a;
3576
3576
  var candidate = value;
3577
- 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((_a = candidate.codeDescription) === null || _a === void 0 ? void 0 : _a.href)) && (Is.string(candidate.source) || Is.undefined(candidate.source)) && (Is.undefined(candidate.relatedInformation) || Is.typedArray(candidate.relatedInformation, DiagnosticRelatedInformation.is));
3577
+ return Is.defined(candidate) && Range3.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((_a = candidate.codeDescription) === null || _a === void 0 ? void 0 : _a.href)) && (Is.string(candidate.source) || Is.undefined(candidate.source)) && (Is.undefined(candidate.relatedInformation) || Is.typedArray(candidate.relatedInformation, DiagnosticRelatedInformation.is));
3578
3578
  }
3579
3579
  Diagnostic7.is = is;
3580
3580
  })(Diagnostic6 || (exports3.Diagnostic = Diagnostic6 = {}));
@@ -3614,7 +3614,7 @@ var require_main2 = __commonJS({
3614
3614
  TextEdit5.del = del;
3615
3615
  function is(value) {
3616
3616
  var candidate = value;
3617
- return Is.objectLiteral(candidate) && Is.string(candidate.newText) && Range2.is(candidate.range);
3617
+ return Is.objectLiteral(candidate) && Is.string(candidate.newText) && Range3.is(candidate.range);
3618
3618
  }
3619
3619
  TextEdit5.is = is;
3620
3620
  })(TextEdit4 || (exports3.TextEdit = TextEdit4 = {}));
@@ -4158,7 +4158,7 @@ var require_main2 = __commonJS({
4158
4158
  InsertReplaceEdit2.create = create;
4159
4159
  function is(value) {
4160
4160
  var candidate = value;
4161
- return candidate && Is.string(candidate.newText) && Range2.is(candidate.insert) && Range2.is(candidate.replace);
4161
+ return candidate && Is.string(candidate.newText) && Range3.is(candidate.insert) && Range3.is(candidate.replace);
4162
4162
  }
4163
4163
  InsertReplaceEdit2.is = is;
4164
4164
  })(InsertReplaceEdit || (exports3.InsertReplaceEdit = InsertReplaceEdit = {}));
@@ -4205,7 +4205,7 @@ var require_main2 = __commonJS({
4205
4205
  (function(Hover4) {
4206
4206
  function is(value) {
4207
4207
  var candidate = value;
4208
- return !!candidate && Is.objectLiteral(candidate) && (MarkupContent2.is(candidate.contents) || MarkedString.is(candidate.contents) || Is.typedArray(candidate.contents, MarkedString.is)) && (value.range === void 0 || Range2.is(value.range));
4208
+ return !!candidate && Is.objectLiteral(candidate) && (MarkupContent2.is(candidate.contents) || MarkedString.is(candidate.contents) || Is.typedArray(candidate.contents, MarkedString.is)) && (value.range === void 0 || Range3.is(value.range));
4209
4209
  }
4210
4210
  Hover4.is = is;
4211
4211
  })(Hover3 || (exports3.Hover = Hover3 = {}));
@@ -4326,7 +4326,7 @@ var require_main2 = __commonJS({
4326
4326
  DocumentSymbol3.create = create;
4327
4327
  function is(value) {
4328
4328
  var candidate = value;
4329
- 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));
4329
+ return candidate && Is.string(candidate.name) && Is.number(candidate.kind) && Range3.is(candidate.range) && Range3.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));
4330
4330
  }
4331
4331
  DocumentSymbol3.is = is;
4332
4332
  })(DocumentSymbol2 || (exports3.DocumentSymbol = DocumentSymbol2 = {}));
@@ -4403,7 +4403,7 @@ var require_main2 = __commonJS({
4403
4403
  CodeLens2.create = create;
4404
4404
  function is(value) {
4405
4405
  var candidate = value;
4406
- return Is.defined(candidate) && Range2.is(candidate.range) && (Is.undefined(candidate.command) || Command.is(candidate.command));
4406
+ return Is.defined(candidate) && Range3.is(candidate.range) && (Is.undefined(candidate.command) || Command.is(candidate.command));
4407
4407
  }
4408
4408
  CodeLens2.is = is;
4409
4409
  })(CodeLens || (exports3.CodeLens = CodeLens = {}));
@@ -4427,7 +4427,7 @@ var require_main2 = __commonJS({
4427
4427
  DocumentLink2.create = create;
4428
4428
  function is(value) {
4429
4429
  var candidate = value;
4430
- return Is.defined(candidate) && Range2.is(candidate.range) && (Is.undefined(candidate.target) || Is.string(candidate.target));
4430
+ return Is.defined(candidate) && Range3.is(candidate.range) && (Is.undefined(candidate.target) || Is.string(candidate.target));
4431
4431
  }
4432
4432
  DocumentLink2.is = is;
4433
4433
  })(DocumentLink || (exports3.DocumentLink = DocumentLink = {}));
@@ -4439,7 +4439,7 @@ var require_main2 = __commonJS({
4439
4439
  SelectionRange2.create = create;
4440
4440
  function is(value) {
4441
4441
  var candidate = value;
4442
- return Is.objectLiteral(candidate) && Range2.is(candidate.range) && (candidate.parent === void 0 || SelectionRange2.is(candidate.parent));
4442
+ return Is.objectLiteral(candidate) && Range3.is(candidate.range) && (candidate.parent === void 0 || SelectionRange2.is(candidate.parent));
4443
4443
  }
4444
4444
  SelectionRange2.is = is;
4445
4445
  })(SelectionRange || (exports3.SelectionRange = SelectionRange = {}));
@@ -4498,7 +4498,7 @@ var require_main2 = __commonJS({
4498
4498
  InlineValueText2.create = create;
4499
4499
  function is(value) {
4500
4500
  var candidate = value;
4501
- return candidate !== void 0 && candidate !== null && Range2.is(candidate.range) && Is.string(candidate.text);
4501
+ return candidate !== void 0 && candidate !== null && Range3.is(candidate.range) && Is.string(candidate.text);
4502
4502
  }
4503
4503
  InlineValueText2.is = is;
4504
4504
  })(InlineValueText || (exports3.InlineValueText = InlineValueText = {}));
@@ -4510,7 +4510,7 @@ var require_main2 = __commonJS({
4510
4510
  InlineValueVariableLookup2.create = create;
4511
4511
  function is(value) {
4512
4512
  var candidate = value;
4513
- return candidate !== void 0 && candidate !== null && Range2.is(candidate.range) && Is.boolean(candidate.caseSensitiveLookup) && (Is.string(candidate.variableName) || candidate.variableName === void 0);
4513
+ return candidate !== void 0 && candidate !== null && Range3.is(candidate.range) && Is.boolean(candidate.caseSensitiveLookup) && (Is.string(candidate.variableName) || candidate.variableName === void 0);
4514
4514
  }
4515
4515
  InlineValueVariableLookup2.is = is;
4516
4516
  })(InlineValueVariableLookup || (exports3.InlineValueVariableLookup = InlineValueVariableLookup = {}));
@@ -4522,7 +4522,7 @@ var require_main2 = __commonJS({
4522
4522
  InlineValueEvaluatableExpression2.create = create;
4523
4523
  function is(value) {
4524
4524
  var candidate = value;
4525
- return candidate !== void 0 && candidate !== null && Range2.is(candidate.range) && (Is.string(candidate.expression) || candidate.expression === void 0);
4525
+ return candidate !== void 0 && candidate !== null && Range3.is(candidate.range) && (Is.string(candidate.expression) || candidate.expression === void 0);
4526
4526
  }
4527
4527
  InlineValueEvaluatableExpression2.is = is;
4528
4528
  })(InlineValueEvaluatableExpression || (exports3.InlineValueEvaluatableExpression = InlineValueEvaluatableExpression = {}));
@@ -4534,7 +4534,7 @@ var require_main2 = __commonJS({
4534
4534
  InlineValueContext2.create = create;
4535
4535
  function is(value) {
4536
4536
  var candidate = value;
4537
- return Is.defined(candidate) && Range2.is(value.stoppedLocation);
4537
+ return Is.defined(candidate) && Range3.is(value.stoppedLocation);
4538
4538
  }
4539
4539
  InlineValueContext2.is = is;
4540
4540
  })(InlineValueContext || (exports3.InlineValueContext = InlineValueContext = {}));
@@ -4571,7 +4571,7 @@ var require_main2 = __commonJS({
4571
4571
  InlayHint2.create = create;
4572
4572
  function is(value) {
4573
4573
  var candidate = value;
4574
- 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, TextEdit4.is) && (candidate.tooltip === void 0 || Is.string(candidate.tooltip) || MarkupContent2.is(candidate.tooltip)) && (candidate.paddingLeft === void 0 || Is.boolean(candidate.paddingLeft)) && (candidate.paddingRight === void 0 || Is.boolean(candidate.paddingRight));
4574
+ return Is.objectLiteral(candidate) && Position3.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, TextEdit4.is) && (candidate.tooltip === void 0 || Is.string(candidate.tooltip) || MarkupContent2.is(candidate.tooltip)) && (candidate.paddingLeft === void 0 || Is.boolean(candidate.paddingLeft)) && (candidate.paddingRight === void 0 || Is.boolean(candidate.paddingRight));
4575
4575
  }
4576
4576
  InlayHint2.is = is;
4577
4577
  })(InlayHint || (exports3.InlayHint = InlayHint = {}));
@@ -4760,7 +4760,7 @@ var require_main2 = __commonJS({
4760
4760
  var lineOffsets = this.getLineOffsets();
4761
4761
  var low = 0, high = lineOffsets.length;
4762
4762
  if (high === 0) {
4763
- return Position2.create(0, offset);
4763
+ return Position3.create(0, offset);
4764
4764
  }
4765
4765
  while (low < high) {
4766
4766
  var mid = Math.floor((low + high) / 2);
@@ -4771,7 +4771,7 @@ var require_main2 = __commonJS({
4771
4771
  }
4772
4772
  }
4773
4773
  var line = low - 1;
4774
- return Position2.create(line, offset - lineOffsets[line]);
4774
+ return Position3.create(line, offset - lineOffsets[line]);
4775
4775
  };
4776
4776
  FullTextDocument3.prototype.offsetAt = function(position) {
4777
4777
  var lineOffsets = this.getLineOffsets();
@@ -122989,6 +122989,7 @@ var SymbolTable = class {
122989
122989
  const selectionRange = anonymous ? ctx.start ? tokenToRange(ctx.start) : range : this.extractNameRange(ctx) ?? range;
122990
122990
  const typeNames = isFlowUsage(kind) ? this.extractFlowTypeNames(ctx) : transition ? this.extractTransitionTypeNames(ctx) : this.extractTypeNames(ctx);
122991
122991
  const specializationNames = this.extractSpecializationNames(ctx);
122992
+ const redefinedFeatureTargets = this.extractRedefinedFeatureTargets(ctx);
122992
122993
  const typeName = typeNames[0];
122993
122994
  const documentation = this.extractDocumentation(ctx);
122994
122995
  const visibility = this.extractVisibility(ctx);
@@ -123019,6 +123020,7 @@ var SymbolTable = class {
123019
123020
  typeName,
123020
123021
  typeNames,
123021
123022
  specializationNames,
123023
+ redefinedFeatureTargets: redefinedFeatureTargets.length > 0 ? redefinedFeatureTargets : void 0,
123022
123024
  documentation,
123023
123025
  visibility,
123024
123026
  source: transition?.source,
@@ -123270,15 +123272,28 @@ var SymbolTable = class {
123270
123272
  * such as `#metadata`.
123271
123273
  */
123272
123274
  findOwnHeaderRule(ctx, ruleIndex) {
123275
+ const matches = [];
123276
+ this.findOwnHeaderRules(ctx, ruleIndex, matches, true);
123277
+ return matches[0];
123278
+ }
123279
+ findOwnHeaderRules(ctx, ruleIndex, matches, firstOnly = false) {
123273
123280
  for (let i = 0; i < ctx.getChildCount(); i++) {
123274
123281
  const child = ctx.getChild(i);
123275
123282
  if (!(child instanceof ParserRuleContext)) continue;
123276
- if (child.ruleIndex === ruleIndex) return child;
123283
+ if (child.ruleIndex === ruleIndex) {
123284
+ matches.push(child);
123285
+ if (firstOnly) return;
123286
+ continue;
123287
+ }
123277
123288
  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;
123278
- const found = this.findOwnHeaderRule(child, ruleIndex);
123279
- if (found) return found;
123289
+ this.findOwnHeaderRules(child, ruleIndex, matches, firstOnly);
123290
+ if (firstOnly && matches.length > 0) return;
123280
123291
  }
123281
- return void 0;
123292
+ }
123293
+ extractRedefinedFeatureTargets(ctx) {
123294
+ const targets = [];
123295
+ this.findOwnHeaderRules(ctx, SysMLv2Parser.RULE_ownedRedefinition, targets);
123296
+ return targets.map((target) => target.getText());
123282
123297
  }
123283
123298
  /**
123284
123299
  * A connection, interface or allocation usage's end reference paths, in
@@ -123306,13 +123321,7 @@ var SymbolTable = class {
123306
123321
  const segment = reference.getText().split(/::|\./).pop();
123307
123322
  return segment ? this.unquoteName(segment) : void 0;
123308
123323
  }
123309
- /**
123310
- * An element's declaration as written, without its body: its tokens up to
123311
- * its body or closing `;`, each exactly as written (a quoted name keeps its
123312
- * spaces), with one space wherever the source has whitespace or a comment
123313
- * between two of them (`connect a.p to b.p`, `connection : Conn`).
123314
- */
123315
- declarationText(ctx) {
123324
+ declarationTokens(ctx) {
123316
123325
  const tokens = [];
123317
123326
  const visit = (node) => {
123318
123327
  for (let i = 0; i < node.getChildCount(); i++) {
@@ -123327,6 +123336,16 @@ var SymbolTable = class {
123327
123336
  return false;
123328
123337
  };
123329
123338
  visit(ctx);
123339
+ return tokens;
123340
+ }
123341
+ /**
123342
+ * An element's declaration as written, without its body: its tokens up to
123343
+ * its body or closing `;`, each exactly as written (a quoted name keeps its
123344
+ * spaces), with one space wherever the source has whitespace or a comment
123345
+ * between two of them (`connect a.p to b.p`, `connection : Conn`).
123346
+ */
123347
+ declarationText(ctx) {
123348
+ const tokens = this.declarationTokens(ctx);
123330
123349
  let text = "";
123331
123350
  tokens.forEach((token, i) => {
123332
123351
  if (i > 0 && token.start > tokens[i - 1].stop + 1) text += " ";
@@ -123467,17 +123486,16 @@ var SymbolTable = class {
123467
123486
  const names = [];
123468
123487
  this.collectTypeNamesFromTree(ctx, names, 0);
123469
123488
  if (names.length > 0) return names;
123470
- const fullText = ctx.getText();
123471
- const braceIdx = fullText.indexOf("{");
123472
- let text = braceIdx >= 0 ? fullText.substring(0, braceIdx) : fullText;
123489
+ const { text: declarationText, quotedName } = this.maskedDeclaration(ctx);
123490
+ let text = declarationText;
123473
123491
  text = text.replace(RE_KEYWORD_TRUNCATE, "");
123474
123492
  const specMatch = text.match(RE_SPEC);
123475
123493
  if (specMatch) {
123476
123494
  const specStr = text.substring(text.indexOf(specMatch[0]) + specMatch[0].indexOf(specMatch[1]));
123477
123495
  for (const part of specStr.split(",")) {
123478
- const qm = part.match(RE_QUOTED_NAME);
123479
- if (qm) {
123480
- names.push(qm[1]);
123496
+ const quoted = quotedName(part);
123497
+ if (quoted !== void 0) {
123498
+ names.push(quoted);
123481
123499
  continue;
123482
123500
  }
123483
123501
  const m2 = part.trim().match(RE_IDENT_START);
@@ -123498,9 +123516,9 @@ var SymbolTable = class {
123498
123516
  const fullMatchIdx = text.indexOf(typingMatch[0]);
123499
123517
  const afterColon = text.substring(fullMatchIdx + 1).trim();
123500
123518
  for (const part of afterColon.split(",")) {
123501
- const qm = part.match(RE_QUOTED_NAME);
123502
- if (qm) {
123503
- names.push(qm[1]);
123519
+ const quoted = quotedName(part);
123520
+ if (quoted !== void 0) {
123521
+ names.push(quoted);
123504
123522
  continue;
123505
123523
  }
123506
123524
  const m2 = part.trim().match(RE_IDENT_START);
@@ -123510,6 +123528,28 @@ var SymbolTable = class {
123510
123528
  }
123511
123529
  return names;
123512
123530
  }
123531
+ /**
123532
+ * The declaration tokens before the body, with each lexer STRING token
123533
+ * replaced by a numbered placeholder (`'0'`, `'1'`, ...), and
123534
+ * `quotedName`, which turns a placeholder in a part of that text back into
123535
+ * the name. SysML 2.0 section 7.2.2 permits punctuation in unrestricted
123536
+ * names (the STRING lexer production), so fallback regexes must never see
123537
+ * their `:`, `:>`, `{` or keywords. Documentation is not a name token.
123538
+ */
123539
+ maskedDeclaration(ctx) {
123540
+ const quoted = [];
123541
+ const masked = this.declarationTokens(ctx).map((token) => {
123542
+ const text = token.text ?? "";
123543
+ return token.type === SysMLv2Lexer.STRING ? `'${quoted.push(text.slice(1, -1)) - 1}'` : text;
123544
+ }).join("");
123545
+ return {
123546
+ text: masked,
123547
+ quotedName: (part) => {
123548
+ const qm = part.match(RE_QUOTED_NAME);
123549
+ return qm ? quoted[Number(qm[1])] : void 0;
123550
+ }
123551
+ };
123552
+ }
123513
123553
  /**
123514
123554
  * Extract only the specialization names (:> / specializes / subsets) from a context.
123515
123555
  * Uses the same tree-walk as extractTypeNames but restricted to
@@ -123520,17 +123560,15 @@ var SymbolTable = class {
123520
123560
  const names = [];
123521
123561
  this.collectNamesFromTree(ctx, names, 0, TYPE_SPECIALIZATION_RULE_INDICES);
123522
123562
  if (names.length > 0) return names;
123523
- const fullText = ctx.getText();
123524
- const braceIdx = fullText.indexOf("{");
123525
- let text = braceIdx >= 0 ? fullText.substring(0, braceIdx) : fullText;
123526
- text = text.replace(RE_KEYWORD_TRUNCATE_SPEC, "");
123563
+ const { text: declarationText, quotedName } = this.maskedDeclaration(ctx);
123564
+ const text = declarationText.replace(RE_KEYWORD_TRUNCATE_SPEC, "");
123527
123565
  const specMatch = text.match(RE_SPEC_WITH_SUBSETS);
123528
123566
  if (specMatch) {
123529
123567
  const specStr = text.substring(text.indexOf(specMatch[0]) + specMatch[0].indexOf(specMatch[1]));
123530
123568
  for (const part of specStr.split(",")) {
123531
- const qm = part.match(RE_QUOTED_NAME);
123532
- if (qm) {
123533
- names.push(qm[1]);
123569
+ const quoted = quotedName(part);
123570
+ if (quoted !== void 0) {
123571
+ names.push(quoted);
123534
123572
  continue;
123535
123573
  }
123536
123574
  const m2 = part.trim().match(RE_IDENT_START);
@@ -125376,14 +125414,21 @@ var NamespaceResolver = class {
125376
125414
  * namespace.
125377
125415
  */
125378
125416
  isLocallyVisible(symbol, name, indexes) {
125379
- return this.resolveQualifiedNameFrom(ownerKeyOf(symbol, indexes.byId), name, indexes) !== void 0;
125417
+ return this.resolveNameFrom(symbol, name, indexes) !== void 0;
125418
+ }
125419
+ /**
125420
+ * Resolve a (possibly qualified) name from the namespace containing
125421
+ * `symbol`, respecting namespace membership and visibility.
125422
+ */
125423
+ resolveNameFrom(symbol, name, indexes) {
125424
+ return this.resolveQualifiedNameFrom(ownerKeyOf(symbol, indexes.byId), name, indexes);
125380
125425
  }
125381
125426
  /**
125382
125427
  * Resolve a (possibly qualified) name to its symbol per §7.5.1, searching
125383
125428
  * outward from namespace `start` and its enclosing namespaces (its own resolved
125384
125429
  * members first, then its parent's, ...). Shared by `isLocallyVisible` (an
125385
- * ordinary reference resolving relative to its own enclosing namespace) and
125386
- * import-target resolution (an `import` declaration's target is itself a
125430
+ * ordinary reference resolving relative to its own enclosing namespace),
125431
+ * `resolveNameFrom`, and import-target resolution (an `import` declaration's target is itself a
125387
125432
  * qualifiedName, resolved the same relative way -- not as an absolute/global
125388
125433
  * name -- so a bare `import C;` inside a nested package can pick up a `C`
125389
125434
  * its own enclosing package already imported, per §7.5.1/§7.5.3).
@@ -129590,6 +129635,13 @@ var CONSTRAINT_KEYWORDS = /* @__PURE__ */ new Set([
129590
129635
  "assert",
129591
129636
  "assume"
129592
129637
  ]);
129638
+ var CONNECTOR_KINDS = /* @__PURE__ */ new Set([
129639
+ "connection" /* ConnectionUsage */,
129640
+ "interface" /* InterfaceUsage */,
129641
+ "allocation" /* AllocationUsage */,
129642
+ "flow" /* FlowUsage */,
129643
+ "succession flow" /* SuccessionFlowUsage */
129644
+ ]);
129593
129645
  var SemanticValidator = class _SemanticValidator {
129594
129646
  constructor(documentManager2) {
129595
129647
  this.documentManager = documentManager2;
@@ -129666,7 +129718,7 @@ var SemanticValidator = class _SemanticValidator {
129666
129718
  diagnostics.push(...this.checkAmbiguousNamespaceName(symbols, allSymbols));
129667
129719
  diagnostics.push(...this.checkUnusedDefinitions(allSymbols, uri));
129668
129720
  diagnostics.push(...this.checkRedefinitionMultiplicity(symbols, indexes, text));
129669
- diagnostics.push(...this.checkPortCompatibility(text, uri, indexes));
129721
+ diagnostics.push(...this.checkPortCompatibility(text, uri, symbols, indexes));
129670
129722
  diagnostics.push(...this.checkConstraintBodyReferences(text, uri, symbols, indexes));
129671
129723
  diagnostics.push(...this.checkCircularSpecialization(symbols, indexes));
129672
129724
  diagnostics.push(...this.checkUnsatisfiedRequirements(symbols, indexes));
@@ -129887,7 +129939,7 @@ var SemanticValidator = class _SemanticValidator {
129887
129939
  opts?.text ? [opts.text] : []
129888
129940
  ));
129889
129941
  if (opts?.text && opts.uri) {
129890
- diagnostics.push(...instance.checkPortCompatibility(opts.text, opts.uri, indexes));
129942
+ diagnostics.push(...instance.checkPortCompatibility(opts.text, opts.uri, symbolsInUri, indexes));
129891
129943
  diagnostics.push(...instance.checkConstraintBodyReferences(opts.text, opts.uri, symbolsInUri, indexes));
129892
129944
  }
129893
129945
  return instance.dedupeDiagnostics(diagnostics);
@@ -130250,17 +130302,20 @@ var SemanticValidator = class _SemanticValidator {
130250
130302
  * - The connection is within an interface usage
130251
130303
  * - Both ports are untyped (empty port defs with no features)
130252
130304
  */
130253
- checkPortCompatibility(text, uri, indexes) {
130305
+ checkPortCompatibility(text, uri, symbolsInUri, indexes) {
130254
130306
  if (!text) return [];
130255
130307
  const diagnostics = [];
130256
130308
  const lines = text.split("\n");
130257
130309
  const re = /\bconnect\s+([A-Za-z_][\w.]*)\s+to\s+([A-Za-z_][\w.]*)/g;
130258
130310
  let m2;
130259
130311
  while ((m2 = re.exec(text)) !== null) {
130260
- const left = m2[1].split(".").pop();
130261
- const right = m2[2].split(".").pop();
130262
- const lSym = (indexes.portsByName.get(left) ?? [])[0];
130263
- const rSym = (indexes.portsByName.get(right) ?? [])[0];
130312
+ const leftPath = m2[1].split(".");
130313
+ const rightPath = m2[2].split(".");
130314
+ const left = leftPath[leftPath.length - 1];
130315
+ const right = rightPath[rightPath.length - 1];
130316
+ const scope = this.connectorScope(symbolsInUri, this.indexToRange(text, m2.index, 0).start, indexes);
130317
+ const lSym = this.resolveConnectorEnd(leftPath, scope, indexes);
130318
+ const rSym = this.resolveConnectorEnd(rightPath, scope, indexes);
130264
130319
  if (!lSym || !rSym) continue;
130265
130320
  const lType = lSym.typeNames[0] ?? lSym.typeName;
130266
130321
  const rType = rSym.typeNames[0] ?? rSym.typeName;
@@ -130310,6 +130365,55 @@ var SemanticValidator = class _SemanticValidator {
130310
130365
  }
130311
130366
  return diagnostics;
130312
130367
  }
130368
+ /**
130369
+ * The innermost element around `position` that owns a connector declared
130370
+ * there: the connector's own symbol, when it has one, is skipped.
130371
+ */
130372
+ connectorScope(symbols, position, indexes) {
130373
+ const before = (a, b) => a.line < b.line || a.line === b.line && a.character <= b.character;
130374
+ const size = (r) => (r.end.line - r.start.line) * 1e6 + (r.end.character - r.start.character);
130375
+ let scope;
130376
+ for (const s of symbols) {
130377
+ if (!before(s.range.start, position) || !before(position, s.range.end)) continue;
130378
+ if (!scope || size(s.range) < size(scope.range)) scope = s;
130379
+ }
130380
+ while (scope && CONNECTOR_KINDS.has(scope.kind)) scope = ownerOf(scope, indexes);
130381
+ return scope;
130382
+ }
130383
+ /**
130384
+ * The port that a connector end (`a.p`, `a.p.q`) names, resolved from
130385
+ * `scope` outward: its first segment is a feature of `scope` or of one of
130386
+ * its owners, each next one a feature of the one before. Two parts can each
130387
+ * have a port of the same name, so an end is never matched by its last
130388
+ * segment alone, except when the path does not resolve and the workspace
130389
+ * has only one port of that name.
130390
+ */
130391
+ resolveConnectorEnd(path3, scope, indexes) {
130392
+ let feature;
130393
+ for (let namespace = scope; namespace && !feature; namespace = ownerOf(namespace, indexes)) {
130394
+ feature = this.findFeature(namespace, path3[0], indexes);
130395
+ }
130396
+ for (const name of path3.slice(1)) {
130397
+ feature = feature && this.findFeature(feature, name, indexes);
130398
+ }
130399
+ if (feature) return feature.kind === "port" /* PortUsage */ ? feature : void 0;
130400
+ const sameName = indexes.portsByName.get(path3[path3.length - 1]) ?? [];
130401
+ return sameName.length === 1 ? sameName[0] : void 0;
130402
+ }
130403
+ /** The feature `name` of `owner`: its own member, else a member of one of its types or their supertypes. */
130404
+ findFeature(owner, name, indexes) {
130405
+ const own = (indexes.byParent.get(namespaceKeyOf(owner)) ?? []).find((s) => s.name === name);
130406
+ if (own) return own;
130407
+ for (const typeName of owner.typeNames) {
130408
+ const type = this.namespaceResolver.resolveNameFrom(owner, typeName, indexes);
130409
+ if (!type || !isDefinition(type.kind)) continue;
130410
+ for (const definition of this.getSpecializationHierarchy(type, indexes).flat()) {
130411
+ const member = (indexes.byParent.get(namespaceKeyOf(definition)) ?? []).find((s) => s.name === name);
130412
+ if (member) return member;
130413
+ }
130414
+ }
130415
+ return void 0;
130416
+ }
130313
130417
  /**
130314
130418
  * Resolve the full type hierarchy for a type name by following
130315
130419
  * specialization chains transitively (max depth 10).
@@ -130357,7 +130461,7 @@ var SemanticValidator = class _SemanticValidator {
130357
130461
  }
130358
130462
  const parent = this.findConstraintScopeSymbol(symbolsInUri, indexes, b.startLine);
130359
130463
  if (!parent) continue;
130360
- const parentMembers = indexes.byParent.get(namespaceKeyOf(parent)) ?? [];
130464
+ const parentMembers = this.getConstraintScopeMembers(parent, indexes);
130361
130465
  if (parentMembers.length === 0) continue;
130362
130466
  const ignoredRanges = this.getIgnoredBodyRanges(b.body);
130363
130467
  const idRe = /\b([A-Za-z_][\w]*(?:\.[A-Za-z_][\w]*)*)\b/g;
@@ -130416,18 +130520,135 @@ var SemanticValidator = class _SemanticValidator {
130416
130520
  const root = parentMembers.find((s) => s.name === path3[0]);
130417
130521
  if (!root) return false;
130418
130522
  if (path3.length === 1) return true;
130419
- let typeName = root.typeNames[0] ?? root.typeName;
130523
+ let current = root;
130420
130524
  for (let i = 1; i < path3.length; i++) {
130525
+ const typeName = current.typeNames[0] ?? current.typeName;
130421
130526
  if (!typeName) return false;
130422
- const typeDefs = indexes.definitionsByName.get(typeName) ?? [];
130423
- const typeDef = typeDefs[0];
130424
- if (!typeDef) return false;
130425
- const member = (indexes.byParent.get(namespaceKeyOf(typeDef)) ?? []).find((s) => s.name === path3[i]);
130527
+ const typeDef = this.namespaceResolver.resolveNameFrom(current, typeName, indexes);
130528
+ if (!typeDef || !isDefinition(typeDef.kind)) return false;
130529
+ const member = this.getConstraintScopeMembers(typeDef, indexes, true).find((s) => s.name === path3[i]);
130426
130530
  if (!member) return false;
130427
- typeName = member.typeNames[0] ?? member.typeName;
130531
+ current = member;
130428
130532
  }
130429
130533
  return true;
130430
130534
  }
130535
+ getConstraintScopeMembers(scope, indexes, publicOnly = false) {
130536
+ const hierarchy = [[scope]];
130537
+ const visited = /* @__PURE__ */ new Set([scope]);
130538
+ let frontier = [scope];
130539
+ while (frontier.length > 0) {
130540
+ const next = [];
130541
+ for (const current of frontier) {
130542
+ for (const typeName of current.typeNames) {
130543
+ const supertype = this.namespaceResolver.resolveNameFrom(current, typeName, indexes);
130544
+ if (!supertype || !isDefinition(supertype.kind) || visited.has(supertype)) continue;
130545
+ visited.add(supertype);
130546
+ next.push(supertype);
130547
+ }
130548
+ }
130549
+ if (next.length > 0) hierarchy.push(next);
130550
+ frontier = next;
130551
+ }
130552
+ const membersByLevel = hierarchy.map((level) => level.flatMap((namespace) => indexes.byParent.get(namespaceKeyOf(namespace)) ?? []));
130553
+ const hiddenMembers = /* @__PURE__ */ new Set();
130554
+ for (let level = membersByLevel.length - 1; level >= 0; level--) {
130555
+ for (const redefining of membersByLevel[level]) {
130556
+ for (const target of redefining.redefinedFeatureTargets ?? []) {
130557
+ const owner = ownerOf(redefining, indexes);
130558
+ if (!owner) continue;
130559
+ for (const candidate of this.resolveInheritedRedefinitionTarget(owner, target, hiddenMembers, indexes)) {
130560
+ hiddenMembers.add(candidate.symbolId);
130561
+ }
130562
+ }
130563
+ if (redefining.kind === "subject" /* SubjectUsage */) {
130564
+ const owner = ownerOf(redefining, indexes);
130565
+ if (!owner) continue;
130566
+ for (const ancestor of this.getSpecializationHierarchy(owner, indexes).slice(1).flat()) {
130567
+ for (const candidate of indexes.byParent.get(namespaceKeyOf(ancestor)) ?? []) {
130568
+ if (candidate.kind === "subject" /* SubjectUsage */) hiddenMembers.add(candidate.symbolId);
130569
+ }
130570
+ }
130571
+ }
130572
+ }
130573
+ }
130574
+ const membersByName = /* @__PURE__ */ new Map();
130575
+ for (let level = 0; level < membersByLevel.length; level++) {
130576
+ for (const member of membersByLevel[level]) {
130577
+ if (level > 0 && member.visibility === "private") continue;
130578
+ if (publicOnly && member.visibility !== void 0 && member.visibility !== "public") continue;
130579
+ if (hiddenMembers.has(member.symbolId) || membersByName.has(member.name)) continue;
130580
+ membersByName.set(member.name, member);
130581
+ }
130582
+ }
130583
+ return [...membersByName.values()];
130584
+ }
130585
+ resolveInheritedRedefinitionTarget(owner, target, alreadyRedefined, indexes) {
130586
+ if (target.includes(".")) return [];
130587
+ const segments = target.split("::");
130588
+ const targetName = segments.pop()?.replace(/^'|'$/g, "");
130589
+ if (!targetName) return [];
130590
+ const qualifier = segments.join("::").replace(/^'|'$/g, "");
130591
+ const matches = /* @__PURE__ */ new Map();
130592
+ for (const supertype of this.resolveDirectSupertypes(owner, indexes)) {
130593
+ const branch = this.getSpecializationHierarchy(supertype, indexes);
130594
+ const anchors = qualifier ? branch.flat().filter((type) => this.matchesSpecializationQualifier(type, qualifier)) : [supertype];
130595
+ for (const anchor of anchors) {
130596
+ let frontier = [anchor];
130597
+ const visited = new Set(frontier);
130598
+ const candidates = [];
130599
+ while (frontier.length > 0 && candidates.length === 0) {
130600
+ for (const type of frontier) {
130601
+ for (const member of indexes.byParent.get(namespaceKeyOf(type)) ?? []) {
130602
+ if (member.name === targetName && member.visibility !== "private" && !alreadyRedefined.has(member.symbolId)) {
130603
+ candidates.push(member);
130604
+ }
130605
+ }
130606
+ }
130607
+ if (candidates.length > 0) break;
130608
+ const next = /* @__PURE__ */ new Map();
130609
+ for (const type of frontier) {
130610
+ for (const parent of this.resolveDirectSupertypes(type, indexes)) {
130611
+ if (visited.has(parent)) continue;
130612
+ visited.add(parent);
130613
+ next.set(parent.symbolId, parent);
130614
+ }
130615
+ }
130616
+ frontier = [...next.values()];
130617
+ }
130618
+ for (const candidate of candidates) matches.set(candidate.symbolId, candidate);
130619
+ }
130620
+ }
130621
+ return matches.size === 1 ? [...matches.values()] : [];
130622
+ }
130623
+ resolveDirectSupertypes(scope, indexes) {
130624
+ const supertypes = /* @__PURE__ */ new Map();
130625
+ for (const typeName of scope.typeNames) {
130626
+ const supertype = this.namespaceResolver.resolveNameFrom(scope, typeName, indexes);
130627
+ if (supertype && isDefinition(supertype.kind)) supertypes.set(supertype.symbolId, supertype);
130628
+ }
130629
+ return [...supertypes.values()];
130630
+ }
130631
+ getSpecializationHierarchy(scope, indexes) {
130632
+ const levels = [[scope]];
130633
+ const visited = /* @__PURE__ */ new Set([scope]);
130634
+ let frontier = [scope];
130635
+ while (frontier.length > 0) {
130636
+ const next = [];
130637
+ for (const type of frontier) {
130638
+ for (const parent of this.resolveDirectSupertypes(type, indexes)) {
130639
+ if (visited.has(parent)) continue;
130640
+ visited.add(parent);
130641
+ next.push(parent);
130642
+ }
130643
+ }
130644
+ if (next.length > 0) levels.push(next);
130645
+ frontier = next;
130646
+ }
130647
+ return levels;
130648
+ }
130649
+ matchesSpecializationQualifier(type, qualifier) {
130650
+ return type.name === qualifier || type.qualifiedName === qualifier || type.qualifiedName?.endsWith(`::${qualifier}`) === true;
130651
+ }
130431
130652
  findContainingSymbolByLine(symbols, line) {
130432
130653
  return symbols.filter((s) => s.range.start.line <= line && s.range.end.line >= line).sort((a, b) => {
130433
130654
  const ar = (a.range.end.line - a.range.start.line) * 1e3 + (a.range.end.character - a.range.start.character);
@@ -130438,7 +130659,7 @@ var SemanticValidator = class _SemanticValidator {
130438
130659
  findConstraintScopeSymbol(symbolsInUri, indexes, line) {
130439
130660
  let scope = this.findContainingSymbolByLine(symbolsInUri, line);
130440
130661
  while (scope) {
130441
- const members = indexes.byParent.get(namespaceKeyOf(scope)) ?? [];
130662
+ const members = this.getConstraintScopeMembers(scope, indexes);
130442
130663
  if (members.length > 0) return scope;
130443
130664
  if (!scope.parentId) return scope;
130444
130665
  scope = ownerOf(scope, indexes);
@@ -131027,7 +131248,8 @@ function logFolderPrefixes(ownProjectIds) {
131027
131248
  if (loggedFolderPrefixes.get(folderUri) === prefix) continue;
131028
131249
  loggedFolderPrefixes.set(folderUri, prefix);
131029
131250
  const source = ownProjectIds.has(folderUri) ? "its projectId" : prefix === getUrlPrefix() ? prefix === DEFAULT_URL_PREFIX ? "the default prefix, no projectId" : "initializationOptions.projectId" : "an enclosing folder's projectId";
131030
- connection.console.info(`Folder ${folderUri}: top-level elements' URLs start with ${prefix} (${source})`);
131251
+ const folderPath = toFsPath(folderUri) ?? folderUri;
131252
+ connection.console.debug(`Folder ${folderPath}: element ID namespace ${prefix} (${source}; ID namespace only, no network access)`);
131031
131253
  }
131032
131254
  for (const folderUri of loggedFolderPrefixes.keys()) {
131033
131255
  if (!workspaceFolderUris.includes(folderUri)) loggedFolderPrefixes.delete(folderUri);