sysml-v2-lsp 0.36.0 → 0.38.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.
@@ -118,28 +118,28 @@ var require_messages = __commonJS({
118
118
  Object.defineProperty(exports2, "__esModule", { value: true });
119
119
  exports2.Message = exports2.NotificationType9 = exports2.NotificationType8 = exports2.NotificationType7 = exports2.NotificationType6 = exports2.NotificationType5 = exports2.NotificationType4 = exports2.NotificationType3 = exports2.NotificationType2 = exports2.NotificationType1 = exports2.NotificationType0 = exports2.NotificationType = exports2.RequestType9 = exports2.RequestType8 = exports2.RequestType7 = exports2.RequestType6 = exports2.RequestType5 = exports2.RequestType4 = exports2.RequestType3 = exports2.RequestType2 = exports2.RequestType1 = exports2.RequestType = exports2.RequestType0 = exports2.AbstractMessageSignature = exports2.ParameterStructures = exports2.ResponseError = exports2.ErrorCodes = void 0;
120
120
  var is = require_is2();
121
- var ErrorCodes;
122
- (function(ErrorCodes2) {
123
- ErrorCodes2.ParseError = -32700;
124
- ErrorCodes2.InvalidRequest = -32600;
125
- ErrorCodes2.MethodNotFound = -32601;
126
- ErrorCodes2.InvalidParams = -32602;
127
- ErrorCodes2.InternalError = -32603;
128
- ErrorCodes2.jsonrpcReservedErrorRangeStart = -32099;
129
- ErrorCodes2.serverErrorStart = -32099;
130
- ErrorCodes2.MessageWriteError = -32099;
131
- ErrorCodes2.MessageReadError = -32098;
132
- ErrorCodes2.PendingResponseRejected = -32097;
133
- ErrorCodes2.ConnectionInactive = -32096;
134
- ErrorCodes2.ServerNotInitialized = -32002;
135
- ErrorCodes2.UnknownErrorCode = -32001;
136
- ErrorCodes2.jsonrpcReservedErrorRangeEnd = -32e3;
137
- ErrorCodes2.serverErrorEnd = -32e3;
138
- })(ErrorCodes || (exports2.ErrorCodes = ErrorCodes = {}));
139
- var ResponseError = class _ResponseError extends Error {
121
+ var ErrorCodes3;
122
+ (function(ErrorCodes4) {
123
+ ErrorCodes4.ParseError = -32700;
124
+ ErrorCodes4.InvalidRequest = -32600;
125
+ ErrorCodes4.MethodNotFound = -32601;
126
+ ErrorCodes4.InvalidParams = -32602;
127
+ ErrorCodes4.InternalError = -32603;
128
+ ErrorCodes4.jsonrpcReservedErrorRangeStart = -32099;
129
+ ErrorCodes4.serverErrorStart = -32099;
130
+ ErrorCodes4.MessageWriteError = -32099;
131
+ ErrorCodes4.MessageReadError = -32098;
132
+ ErrorCodes4.PendingResponseRejected = -32097;
133
+ ErrorCodes4.ConnectionInactive = -32096;
134
+ ErrorCodes4.ServerNotInitialized = -32002;
135
+ ErrorCodes4.UnknownErrorCode = -32001;
136
+ ErrorCodes4.jsonrpcReservedErrorRangeEnd = -32e3;
137
+ ErrorCodes4.serverErrorEnd = -32e3;
138
+ })(ErrorCodes3 || (exports2.ErrorCodes = ErrorCodes3 = {}));
139
+ var ResponseError3 = class _ResponseError extends Error {
140
140
  constructor(code, message, data) {
141
141
  super(message);
142
- this.code = is.number(code) ? code : ErrorCodes.UnknownErrorCode;
142
+ this.code = is.number(code) ? code : ErrorCodes3.UnknownErrorCode;
143
143
  this.data = data;
144
144
  Object.setPrototypeOf(this, _ResponseError.prototype);
145
145
  }
@@ -154,7 +154,7 @@ var require_messages = __commonJS({
154
154
  return result;
155
155
  }
156
156
  };
157
- exports2.ResponseError = ResponseError;
157
+ exports2.ResponseError = ResponseError3;
158
158
  var ParameterStructures = class _ParameterStructures {
159
159
  constructor(kind) {
160
160
  this.kind = kind;
@@ -3375,8 +3375,8 @@ var require_main2 = __commonJS({
3375
3375
  }
3376
3376
  uinteger2.is = is;
3377
3377
  })(uinteger || (exports3.uinteger = uinteger = {}));
3378
- var Position3;
3379
- (function(Position4) {
3378
+ var Position4;
3379
+ (function(Position5) {
3380
3380
  function create(line, character) {
3381
3381
  if (line === Number.MAX_VALUE) {
3382
3382
  line = uinteger.MAX_VALUE;
@@ -3386,43 +3386,43 @@ var require_main2 = __commonJS({
3386
3386
  }
3387
3387
  return { line, character };
3388
3388
  }
3389
- Position4.create = create;
3389
+ Position5.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
- Position4.is = is;
3395
- })(Position3 || (exports3.Position = Position3 = {}));
3396
- var Range3;
3397
- (function(Range4) {
3394
+ Position5.is = is;
3395
+ })(Position4 || (exports3.Position = Position4 = {}));
3396
+ var Range6;
3397
+ (function(Range7) {
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: Position3.create(one, two), end: Position3.create(three, four) };
3401
- } else if (Position3.is(one) && Position3.is(two)) {
3400
+ return { start: Position4.create(one, two), end: Position4.create(three, four) };
3401
+ } else if (Position4.is(one) && Position4.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
- Range4.create = create;
3407
+ Range7.create = create;
3408
3408
  function is(value) {
3409
3409
  var candidate = value;
3410
- return Is.objectLiteral(candidate) && Position3.is(candidate.start) && Position3.is(candidate.end);
3410
+ return Is.objectLiteral(candidate) && Position4.is(candidate.start) && Position4.is(candidate.end);
3411
3411
  }
3412
- Range4.is = is;
3413
- })(Range3 || (exports3.Range = Range3 = {}));
3414
- var Location2;
3415
- (function(Location3) {
3412
+ Range7.is = is;
3413
+ })(Range6 || (exports3.Range = Range6 = {}));
3414
+ var Location3;
3415
+ (function(Location4) {
3416
3416
  function create(uri, range) {
3417
3417
  return { uri, range };
3418
3418
  }
3419
- Location3.create = create;
3419
+ Location4.create = create;
3420
3420
  function is(value) {
3421
3421
  var candidate = value;
3422
- return Is.objectLiteral(candidate) && Range3.is(candidate.range) && (Is.string(candidate.uri) || Is.undefined(candidate.uri));
3422
+ return Is.objectLiteral(candidate) && Range6.is(candidate.range) && (Is.string(candidate.uri) || Is.undefined(candidate.uri));
3423
3423
  }
3424
- Location3.is = is;
3425
- })(Location2 || (exports3.Location = Location2 = {}));
3424
+ Location4.is = is;
3425
+ })(Location3 || (exports3.Location = Location3 = {}));
3426
3426
  var LocationLink;
3427
3427
  (function(LocationLink2) {
3428
3428
  function create(targetUri, targetRange, targetSelectionRange, originSelectionRange) {
@@ -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) && Range3.is(candidate.targetRange) && Is.string(candidate.targetUri) && Range3.is(candidate.targetSelectionRange) && (Range3.is(candidate.originSelectionRange) || Is.undefined(candidate.originSelectionRange));
3434
+ return Is.objectLiteral(candidate) && Range6.is(candidate.targetRange) && Is.string(candidate.targetUri) && Range6.is(candidate.targetSelectionRange) && (Range6.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) && Range3.is(candidate.range) && Color.is(candidate.color);
3466
+ return Is.objectLiteral(candidate) && Range6.is(candidate.range) && Color.is(candidate.color);
3467
3467
  }
3468
3468
  ColorInformation2.is = is;
3469
3469
  })(ColorInformation || (exports3.ColorInformation = ColorInformation = {}));
@@ -3479,7 +3479,7 @@ var require_main2 = __commonJS({
3479
3479
  ColorPresentation2.create = create;
3480
3480
  function is(value) {
3481
3481
  var candidate = value;
3482
- return Is.objectLiteral(candidate) && Is.string(candidate.label) && (Is.undefined(candidate.textEdit) || TextEdit4.is(candidate)) && (Is.undefined(candidate.additionalTextEdits) || Is.typedArray(candidate.additionalTextEdits, TextEdit4.is));
3482
+ return Is.objectLiteral(candidate) && Is.string(candidate.label) && (Is.undefined(candidate.textEdit) || TextEdit5.is(candidate)) && (Is.undefined(candidate.additionalTextEdits) || Is.typedArray(candidate.additionalTextEdits, TextEdit5.is));
3483
3483
  }
3484
3484
  ColorPresentation2.is = is;
3485
3485
  })(ColorPresentation || (exports3.ColorPresentation = ColorPresentation = {}));
@@ -3528,7 +3528,7 @@ var require_main2 = __commonJS({
3528
3528
  DiagnosticRelatedInformation2.create = create;
3529
3529
  function is(value) {
3530
3530
  var candidate = value;
3531
- return Is.defined(candidate) && Location2.is(candidate.location) && Is.string(candidate.message);
3531
+ return Is.defined(candidate) && Location3.is(candidate.location) && Is.string(candidate.message);
3532
3532
  }
3533
3533
  DiagnosticRelatedInformation2.is = is;
3534
3534
  })(DiagnosticRelatedInformation || (exports3.DiagnosticRelatedInformation = DiagnosticRelatedInformation = {}));
@@ -3552,8 +3552,8 @@ var require_main2 = __commonJS({
3552
3552
  }
3553
3553
  CodeDescription2.is = is;
3554
3554
  })(CodeDescription || (exports3.CodeDescription = CodeDescription = {}));
3555
- var Diagnostic6;
3556
- (function(Diagnostic7) {
3555
+ var Diagnostic7;
3556
+ (function(Diagnostic8) {
3557
3557
  function create(range, message, severity, code, source, relatedInformation) {
3558
3558
  var result = { range, message };
3559
3559
  if (Is.defined(severity)) {
@@ -3570,14 +3570,14 @@ var require_main2 = __commonJS({
3570
3570
  }
3571
3571
  return result;
3572
3572
  }
3573
- Diagnostic7.create = create;
3573
+ Diagnostic8.create = create;
3574
3574
  function is(value) {
3575
3575
  var _a;
3576
3576
  var candidate = value;
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));
3577
+ return Is.defined(candidate) && Range6.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
- Diagnostic7.is = is;
3580
- })(Diagnostic6 || (exports3.Diagnostic = Diagnostic6 = {}));
3579
+ Diagnostic8.is = is;
3580
+ })(Diagnostic7 || (exports3.Diagnostic = Diagnostic7 = {}));
3581
3581
  var Command;
3582
3582
  (function(Command2) {
3583
3583
  function create(title, command) {
@@ -3598,26 +3598,26 @@ var require_main2 = __commonJS({
3598
3598
  }
3599
3599
  Command2.is = is;
3600
3600
  })(Command || (exports3.Command = Command = {}));
3601
- var TextEdit4;
3602
- (function(TextEdit5) {
3601
+ var TextEdit5;
3602
+ (function(TextEdit6) {
3603
3603
  function replace(range, newText) {
3604
3604
  return { range, newText };
3605
3605
  }
3606
- TextEdit5.replace = replace;
3606
+ TextEdit6.replace = replace;
3607
3607
  function insert(position, newText) {
3608
3608
  return { range: { start: position, end: position }, newText };
3609
3609
  }
3610
- TextEdit5.insert = insert;
3610
+ TextEdit6.insert = insert;
3611
3611
  function del(range) {
3612
3612
  return { range, newText: "" };
3613
3613
  }
3614
- TextEdit5.del = del;
3614
+ TextEdit6.del = del;
3615
3615
  function is(value) {
3616
3616
  var candidate = value;
3617
- return Is.objectLiteral(candidate) && Is.string(candidate.newText) && Range3.is(candidate.range);
3617
+ return Is.objectLiteral(candidate) && Is.string(candidate.newText) && Range6.is(candidate.range);
3618
3618
  }
3619
- TextEdit5.is = is;
3620
- })(TextEdit4 || (exports3.TextEdit = TextEdit4 = {}));
3619
+ TextEdit6.is = is;
3620
+ })(TextEdit5 || (exports3.TextEdit = TextEdit5 = {}));
3621
3621
  var ChangeAnnotation;
3622
3622
  (function(ChangeAnnotation2) {
3623
3623
  function create(label, needsConfirmation, description) {
@@ -3661,7 +3661,7 @@ var require_main2 = __commonJS({
3661
3661
  AnnotatedTextEdit2.del = del;
3662
3662
  function is(value) {
3663
3663
  var candidate = value;
3664
- return TextEdit4.is(candidate) && (ChangeAnnotation.is(candidate.annotationId) || ChangeAnnotationIdentifier.is(candidate.annotationId));
3664
+ return TextEdit5.is(candidate) && (ChangeAnnotation.is(candidate.annotationId) || ChangeAnnotationIdentifier.is(candidate.annotationId));
3665
3665
  }
3666
3666
  AnnotatedTextEdit2.is = is;
3667
3667
  })(AnnotatedTextEdit || (exports3.AnnotatedTextEdit = AnnotatedTextEdit = {}));
@@ -3744,8 +3744,8 @@ var require_main2 = __commonJS({
3744
3744
  }
3745
3745
  DeleteFile2.is = is;
3746
3746
  })(DeleteFile || (exports3.DeleteFile = DeleteFile = {}));
3747
- var WorkspaceEdit3;
3748
- (function(WorkspaceEdit4) {
3747
+ var WorkspaceEdit4;
3748
+ (function(WorkspaceEdit5) {
3749
3749
  function is(value) {
3750
3750
  var candidate = value;
3751
3751
  return candidate && (candidate.changes !== void 0 || candidate.documentChanges !== void 0) && (candidate.documentChanges === void 0 || candidate.documentChanges.every(function(change) {
@@ -3756,8 +3756,8 @@ var require_main2 = __commonJS({
3756
3756
  }
3757
3757
  }));
3758
3758
  }
3759
- WorkspaceEdit4.is = is;
3760
- })(WorkspaceEdit3 || (exports3.WorkspaceEdit = WorkspaceEdit3 = {}));
3759
+ WorkspaceEdit5.is = is;
3760
+ })(WorkspaceEdit4 || (exports3.WorkspaceEdit = WorkspaceEdit4 = {}));
3761
3761
  var TextEditChangeImpl = (
3762
3762
  /** @class */
3763
3763
  (function() {
@@ -3769,7 +3769,7 @@ var require_main2 = __commonJS({
3769
3769
  var edit;
3770
3770
  var id;
3771
3771
  if (annotation === void 0) {
3772
- edit = TextEdit4.insert(position, newText);
3772
+ edit = TextEdit5.insert(position, newText);
3773
3773
  } else if (ChangeAnnotationIdentifier.is(annotation)) {
3774
3774
  id = annotation;
3775
3775
  edit = AnnotatedTextEdit.insert(position, newText, annotation);
@@ -3787,7 +3787,7 @@ var require_main2 = __commonJS({
3787
3787
  var edit;
3788
3788
  var id;
3789
3789
  if (annotation === void 0) {
3790
- edit = TextEdit4.replace(range, newText);
3790
+ edit = TextEdit5.replace(range, newText);
3791
3791
  } else if (ChangeAnnotationIdentifier.is(annotation)) {
3792
3792
  id = annotation;
3793
3793
  edit = AnnotatedTextEdit.replace(range, newText, annotation);
@@ -3805,7 +3805,7 @@ var require_main2 = __commonJS({
3805
3805
  var edit;
3806
3806
  var id;
3807
3807
  if (annotation === void 0) {
3808
- edit = TextEdit4.del(range);
3808
+ edit = TextEdit5.del(range);
3809
3809
  } else if (ChangeAnnotationIdentifier.is(annotation)) {
3810
3810
  id = annotation;
3811
3811
  edit = AnnotatedTextEdit.del(range, annotation);
@@ -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) && Range3.is(candidate.insert) && Range3.is(candidate.replace);
4161
+ return candidate && Is.string(candidate.newText) && Range6.is(candidate.insert) && Range6.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 || Range3.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 || Range6.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) && 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));
4329
+ return candidate && Is.string(candidate.name) && Is.number(candidate.kind) && Range6.is(candidate.range) && Range6.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 = {}));
@@ -4362,7 +4362,7 @@ var require_main2 = __commonJS({
4362
4362
  CodeActionContext2.create = create;
4363
4363
  function is(value) {
4364
4364
  var candidate = value;
4365
- return Is.defined(candidate) && Is.typedArray(candidate.diagnostics, Diagnostic6.is) && (candidate.only === void 0 || Is.typedArray(candidate.only, Is.string)) && (candidate.triggerKind === void 0 || candidate.triggerKind === CodeActionTriggerKind.Invoked || candidate.triggerKind === CodeActionTriggerKind.Automatic);
4365
+ return Is.defined(candidate) && Is.typedArray(candidate.diagnostics, Diagnostic7.is) && (candidate.only === void 0 || Is.typedArray(candidate.only, Is.string)) && (candidate.triggerKind === void 0 || candidate.triggerKind === CodeActionTriggerKind.Invoked || candidate.triggerKind === CodeActionTriggerKind.Automatic);
4366
4366
  }
4367
4367
  CodeActionContext2.is = is;
4368
4368
  })(CodeActionContext || (exports3.CodeActionContext = CodeActionContext = {}));
@@ -4387,7 +4387,7 @@ var require_main2 = __commonJS({
4387
4387
  CodeAction3.create = create;
4388
4388
  function is(value) {
4389
4389
  var candidate = value;
4390
- return candidate && Is.string(candidate.title) && (candidate.diagnostics === void 0 || Is.typedArray(candidate.diagnostics, Diagnostic6.is)) && (candidate.kind === void 0 || Is.string(candidate.kind)) && (candidate.edit !== void 0 || candidate.command !== void 0) && (candidate.command === void 0 || Command.is(candidate.command)) && (candidate.isPreferred === void 0 || Is.boolean(candidate.isPreferred)) && (candidate.edit === void 0 || WorkspaceEdit3.is(candidate.edit));
4390
+ return candidate && Is.string(candidate.title) && (candidate.diagnostics === void 0 || Is.typedArray(candidate.diagnostics, Diagnostic7.is)) && (candidate.kind === void 0 || Is.string(candidate.kind)) && (candidate.edit !== void 0 || candidate.command !== void 0) && (candidate.command === void 0 || Command.is(candidate.command)) && (candidate.isPreferred === void 0 || Is.boolean(candidate.isPreferred)) && (candidate.edit === void 0 || WorkspaceEdit4.is(candidate.edit));
4391
4391
  }
4392
4392
  CodeAction3.is = is;
4393
4393
  })(CodeAction2 || (exports3.CodeAction = CodeAction2 = {}));
@@ -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) && Range3.is(candidate.range) && (Is.undefined(candidate.command) || Command.is(candidate.command));
4406
+ return Is.defined(candidate) && Range6.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) && Range3.is(candidate.range) && (Is.undefined(candidate.target) || Is.string(candidate.target));
4430
+ return Is.defined(candidate) && Range6.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) && Range3.is(candidate.range) && (candidate.parent === void 0 || SelectionRange2.is(candidate.parent));
4442
+ return Is.objectLiteral(candidate) && Range6.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 && Range3.is(candidate.range) && Is.string(candidate.text);
4501
+ return candidate !== void 0 && candidate !== null && Range6.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 && Range3.is(candidate.range) && Is.boolean(candidate.caseSensitiveLookup) && (Is.string(candidate.variableName) || candidate.variableName === void 0);
4513
+ return candidate !== void 0 && candidate !== null && Range6.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 && Range3.is(candidate.range) && (Is.string(candidate.expression) || candidate.expression === void 0);
4525
+ return candidate !== void 0 && candidate !== null && Range6.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) && Range3.is(value.stoppedLocation);
4537
+ return Is.defined(candidate) && Range6.is(value.stoppedLocation);
4538
4538
  }
4539
4539
  InlineValueContext2.is = is;
4540
4540
  })(InlineValueContext || (exports3.InlineValueContext = InlineValueContext = {}));
@@ -4555,7 +4555,7 @@ var require_main2 = __commonJS({
4555
4555
  InlayHintLabelPart2.create = create;
4556
4556
  function is(value) {
4557
4557
  var candidate = value;
4558
- return Is.objectLiteral(candidate) && (candidate.tooltip === void 0 || Is.string(candidate.tooltip) || MarkupContent2.is(candidate.tooltip)) && (candidate.location === void 0 || Location2.is(candidate.location)) && (candidate.command === void 0 || Command.is(candidate.command));
4558
+ return Is.objectLiteral(candidate) && (candidate.tooltip === void 0 || Is.string(candidate.tooltip) || MarkupContent2.is(candidate.tooltip)) && (candidate.location === void 0 || Location3.is(candidate.location)) && (candidate.command === void 0 || Command.is(candidate.command));
4559
4559
  }
4560
4560
  InlayHintLabelPart2.is = is;
4561
4561
  })(InlayHintLabelPart || (exports3.InlayHintLabelPart = InlayHintLabelPart = {}));
@@ -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) && 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));
4574
+ return Is.objectLiteral(candidate) && Position4.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, TextEdit5.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 Position3.create(0, offset);
4763
+ return Position4.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 Position3.create(line, offset - lineOffsets[line]);
4774
+ return Position4.create(line, offset - lineOffsets[line]);
4775
4775
  };
4776
4776
  FullTextDocument3.prototype.offsetAt = function(position) {
4777
4777
  var lineOffsets = this.getLineOffsets();
@@ -8880,7 +8880,7 @@ var require_node3 = __commonJS({
8880
8880
  });
8881
8881
 
8882
8882
  // server/src/server.ts
8883
- var import_node12 = __toESM(require_node3());
8883
+ var import_node15 = __toESM(require_node3());
8884
8884
  var fs = __toESM(require("node:fs"));
8885
8885
  var path2 = __toESM(require("node:path"));
8886
8886
  var import_node_url2 = require("node:url");
@@ -121407,18 +121407,71 @@ var SysMLErrorListener = class extends BaseErrorListener {
121407
121407
  }
121408
121408
  };
121409
121409
 
121410
+ // server/src/parser/positionUtils.ts
121411
+ function normalizeUtf16Columns(text, tokens, errors) {
121412
+ if (!/[\uD800-\uDBFF][\uDC00-\uDFFF]/.test(text)) return;
121413
+ const columns = /* @__PURE__ */ new Map();
121414
+ const lines = text.split("\n");
121415
+ for (let line = 0; line < lines.length; line++) {
121416
+ if (!/[\uD800-\uDBFF][\uDC00-\uDFFF]/.test(lines[line])) continue;
121417
+ const offsets = [0];
121418
+ for (const character of lines[line]) offsets.push(offsets[offsets.length - 1] + character.length);
121419
+ columns.set(line, offsets);
121420
+ }
121421
+ for (const token of tokens) {
121422
+ token.column = columns.get(token.line - 1)?.[token.column] ?? token.column;
121423
+ }
121424
+ for (const error of errors) {
121425
+ error.column = columns.get(error.line)?.[error.column] ?? error.column;
121426
+ }
121427
+ }
121428
+ function tokenToPosition(token) {
121429
+ return {
121430
+ line: (token.line ?? 1) - 1,
121431
+ character: token.column ?? 0
121432
+ };
121433
+ }
121434
+ function tokenToRange(token) {
121435
+ const start = tokenToPosition(token);
121436
+ const length = token.text?.length ?? 1;
121437
+ return {
121438
+ start,
121439
+ end: { line: start.line, character: start.character + length }
121440
+ };
121441
+ }
121442
+ function contextToRange(ctx) {
121443
+ const startToken = ctx.start;
121444
+ const stopToken = ctx.stop ?? ctx.start;
121445
+ if (!startToken) {
121446
+ return { start: { line: 0, character: 0 }, end: { line: 0, character: 0 } };
121447
+ }
121448
+ const start = {
121449
+ line: (startToken.line ?? 1) - 1,
121450
+ character: startToken.column ?? 0
121451
+ };
121452
+ const end = stopToken ? {
121453
+ line: (stopToken.line ?? 1) - 1,
121454
+ character: (stopToken.column ?? 0) + (stopToken.text?.length ?? 1)
121455
+ } : { line: start.line, character: start.character + 1 };
121456
+ return { start, end };
121457
+ }
121458
+
121410
121459
  // server/src/parser/parseDocument.ts
121460
+ function withUtf16Columns(text, result) {
121461
+ normalizeUtf16Columns(text, result.tokenStream.getTokens(), result.errors);
121462
+ return result;
121463
+ }
121411
121464
  function parseDocument(text) {
121412
121465
  const result = parseDocumentCore(text);
121413
121466
  if (result.errors.length > 0 && hasStaleDfaStates()) {
121414
121467
  markDfaNotPreSeeded();
121415
121468
  clearAllDFAStates();
121416
- return parseDocumentLL(text, result.lexer, result.tokenStream);
121469
+ return withUtf16Columns(text, parseDocumentLL(text, result.lexer, result.tokenStream));
121417
121470
  }
121418
121471
  if (isDfaPreSeeded()) {
121419
121472
  markDfaNotPreSeeded();
121420
121473
  }
121421
- return result;
121474
+ return withUtf16Columns(text, result);
121422
121475
  }
121423
121476
  function parseDocumentCore(text) {
121424
121477
  const inputStream = CharStream.fromString(text);
@@ -121560,19 +121613,19 @@ function parseDocumentBatch(text) {
121560
121613
  if (errors.length > 0 && hasStaleDfaStates()) {
121561
121614
  markDfaNotPreSeeded();
121562
121615
  clearAllDFAStates();
121563
- return parseDocumentBatchLL(text, lexer, tokenStream, lexMs);
121616
+ return withUtf16Columns(text, parseDocumentBatchLL(text, lexer, tokenStream, lexMs));
121564
121617
  }
121565
121618
  if (isDfaPreSeeded()) {
121566
121619
  markDfaNotPreSeeded();
121567
121620
  }
121568
- return {
121621
+ return withUtf16Columns(text, {
121569
121622
  tree,
121570
121623
  tokenStream,
121571
121624
  parser,
121572
121625
  lexer,
121573
121626
  errors,
121574
121627
  timing: { lexMs, parseMs }
121575
- };
121628
+ });
121576
121629
  }
121577
121630
  function parseDocumentBatchLL(_text, lexer, tokenStream, lexMs) {
121578
121631
  tokenStream.seek(0);
@@ -121598,41 +121651,162 @@ function parseDocumentBatchLL(_text, lexer, tokenStream, lexMs) {
121598
121651
  };
121599
121652
  }
121600
121653
 
121601
- // server/src/parser/positionUtils.ts
121602
- function tokenToPosition(token) {
121603
- return {
121604
- line: (token.line ?? 1) - 1,
121605
- character: token.column ?? 0
121606
- };
121654
+ // server/src/utils/sysmlKeywords.ts
121655
+ var SYSML_KEYWORDS_ARRAY = SysMLv2Lexer.literalNames.filter((n2) => n2 != null).map((n2) => n2.replace(/^'|'$/g, "")).filter((n2) => /^[a-z]+$/.test(n2)).sort();
121656
+ var SYSML_KEYWORDS = new Set(SYSML_KEYWORDS_ARRAY);
121657
+
121658
+ // server/src/utils/identUtils.ts
121659
+ function isIdentStart(c) {
121660
+ return c >= 65 && c <= 90 || c >= 97 && c <= 122 || c === 95;
121607
121661
  }
121608
- function tokenToRange(token) {
121609
- const start = tokenToPosition(token);
121610
- const length = token.text?.length ?? 1;
121611
- return {
121612
- start,
121613
- end: { line: start.line, character: start.character + length }
121614
- };
121662
+ function isIdentPart(c) {
121663
+ return c >= 65 && c <= 90 || c >= 97 && c <= 122 || c >= 48 && c <= 57 || c === 95;
121615
121664
  }
121616
- function contextToRange(ctx) {
121617
- const startToken = ctx.start;
121618
- const stopToken = ctx.stop ?? ctx.start;
121619
- if (!startToken) {
121620
- return { start: { line: 0, character: 0 }, end: { line: 0, character: 0 } };
121665
+ var ESCAPES = {
121666
+ b: "\b",
121667
+ t: " ",
121668
+ n: "\n",
121669
+ f: "\f",
121670
+ r: "\r",
121671
+ "'": "'",
121672
+ '"': '"',
121673
+ "\\": "\\"
121674
+ };
121675
+ function unquoteName(text) {
121676
+ if (!text.startsWith("'") || !text.endsWith("'")) return text;
121677
+ return text.slice(1, -1).replace(/\\([btnfr'"\\])/g, (_, ch) => ESCAPES[ch]);
121678
+ }
121679
+ function quoteName(name) {
121680
+ if (/^[A-Za-z_][A-Za-z_0-9]*$/.test(name) && !SYSML_KEYWORDS.has(name)) return name;
121681
+ const escaped = name.replace(/[\\'\b\t\n\f\r]/g, (ch) => {
121682
+ const entry = Object.entries(ESCAPES).find(([, value]) => value === ch);
121683
+ return `\\${entry[0]}`;
121684
+ });
121685
+ return `'${escaped}'`;
121686
+ }
121687
+ function splitQualifiedName(text) {
121688
+ const parts = [];
121689
+ let start = 0;
121690
+ let quoted = false;
121691
+ for (let i = 0; i < text.length; i++) {
121692
+ if (quoted && text[i] === "\\") {
121693
+ i++;
121694
+ continue;
121695
+ }
121696
+ if (text[i] === "'" && (quoted || i === start)) quoted = !quoted;
121697
+ if (!quoted && text.startsWith("::", i)) {
121698
+ parts.push(unquoteName(text.slice(start, i).trim()));
121699
+ start = i + 2;
121700
+ i++;
121701
+ }
121621
121702
  }
121622
- const start = {
121623
- line: (startToken.line ?? 1) - 1,
121624
- character: startToken.column ?? 0
121625
- };
121626
- const end = stopToken ? {
121627
- line: (stopToken.line ?? 1) - 1,
121628
- character: (stopToken.column ?? 0) + (stopToken.text?.length ?? 1)
121629
- } : { line: start.line, character: start.character + 1 };
121630
- return { start, end };
121703
+ parts.push(unquoteName(text.slice(start).trim()));
121704
+ return parts;
121705
+ }
121706
+ function joinQualifiedName(parts) {
121707
+ return parts.map((part) => /::|['\\\r\n\t\b\f]/.test(part) ? quoteName(part) : part).join("::");
121708
+ }
121709
+ function readNameAt(text, start, allowIncomplete = false) {
121710
+ if (text[start] === "'") {
121711
+ let end2 = start + 1;
121712
+ while (end2 < text.length && text[end2] !== "'") {
121713
+ if (text[end2] === "\r" || text[end2] === "\n") return void 0;
121714
+ if (text[end2] === "\\") {
121715
+ if (!Object.hasOwn(ESCAPES, text[end2 + 1])) return void 0;
121716
+ end2++;
121717
+ }
121718
+ end2++;
121719
+ }
121720
+ if (end2 >= text.length) {
121721
+ return allowIncomplete ? { name: unquoteName(`${text.slice(start)}'`), start, end: text.length } : void 0;
121722
+ }
121723
+ if (end2 === start + 1 && !allowIncomplete) return void 0;
121724
+ return { name: unquoteName(text.slice(start, end2 + 1)), start, end: end2 + 1 };
121725
+ }
121726
+ if (!isIdentStart(text.charCodeAt(start))) return void 0;
121727
+ let end = start + 1;
121728
+ while (end < text.length && isIdentPart(text.charCodeAt(end))) end++;
121729
+ return { name: text.slice(start, end), start, end };
121730
+ }
121731
+ function readQualifiedNameAt(text, start, allowIncomplete = false) {
121732
+ const first = readNameAt(text, start, allowIncomplete);
121733
+ if (!first) return void 0;
121734
+ const segments = [first];
121735
+ let end = first.end;
121736
+ while (end < text.length) {
121737
+ let next = end;
121738
+ while (/\s/.test(text[next] ?? "") && next < text.length) next++;
121739
+ if (!text.startsWith("::", next)) break;
121740
+ next += 2;
121741
+ while (/\s/.test(text[next] ?? "") && next < text.length) next++;
121742
+ const segment = readNameAt(text, next, allowIncomplete);
121743
+ if (!segment) break;
121744
+ segments.push(segment);
121745
+ end = segment.end;
121746
+ }
121747
+ return { name: joinQualifiedName(segments.map((s) => s.name)), start, end, segments };
121748
+ }
121749
+ function* scanQualifiedNames(text, allowIncomplete = false) {
121750
+ let i = 0;
121751
+ while (i < text.length) {
121752
+ if (text.startsWith("//", i)) {
121753
+ const end = text.indexOf("\n", i + 2);
121754
+ i = end < 0 ? text.length : end + 1;
121755
+ } else if (text.startsWith("/*", i)) {
121756
+ const end = text.indexOf("*/", i + 2);
121757
+ i = end < 0 ? text.length : end + 2;
121758
+ } else if (text[i] === '"') {
121759
+ i++;
121760
+ while (i < text.length && text[i] !== '"') i += text[i] === "\\" ? 2 : 1;
121761
+ i++;
121762
+ } else if (/\d/.test(text[i]) || text[i] === "." && /\d/.test(text[i + 1] ?? "")) {
121763
+ const number = text.slice(i).match(/^(?:\d+(?:\.\d*)?|\.\d+)(?:[eE][+-]?\d+)?/);
121764
+ i += number[0].length;
121765
+ } else {
121766
+ const name = readQualifiedNameAt(text, i, allowIncomplete);
121767
+ if (name) {
121768
+ yield name;
121769
+ i = name.end;
121770
+ } else if (text[i] === "'") {
121771
+ i++;
121772
+ while (i < text.length && text[i] !== "'" && text[i] !== "\n") {
121773
+ i += text[i] === "\\" ? 2 : 1;
121774
+ }
121775
+ if (text[i] === "'") i++;
121776
+ } else {
121777
+ i++;
121778
+ }
121779
+ }
121780
+ }
121781
+ }
121782
+ function* scanFeaturePaths(text) {
121783
+ const names = [...scanQualifiedNames(text)];
121784
+ for (let i = 0; i < names.length; i++) {
121785
+ const first = names[i];
121786
+ const parts = [first.name];
121787
+ const qualifiedNames = [first];
121788
+ let end = first.end;
121789
+ while (i + 1 < names.length && /^\s*\.\s*$/.test(text.slice(end, names[i + 1].start))) {
121790
+ parts.push(names[++i].name);
121791
+ qualifiedNames.push(names[i]);
121792
+ end = names[i].end;
121793
+ }
121794
+ yield { name: parts.join("."), start: first.start, end, qualifiedNames, parts: parts.map((part) => {
121795
+ const segments = splitQualifiedName(part);
121796
+ return segments.length === 1 ? segments[0] : part;
121797
+ }) };
121798
+ }
121799
+ }
121800
+ function extractQualifiedNameAt(text, character) {
121801
+ for (const name of scanQualifiedNames(text)) {
121802
+ if (character >= name.start && character <= name.end) return name.name;
121803
+ if (name.start > character) break;
121804
+ }
121805
+ return void 0;
121806
+ }
121807
+ function stripComments(text) {
121808
+ return text.replace(/\/\*[\s\S]*?\*\//g, (m2) => m2.replace(/[^\n]/g, " ")).replace(/\/\/[^\n]*/g, (m2) => " ".repeat(m2.length));
121631
121809
  }
121632
-
121633
- // server/src/utils/sysmlKeywords.ts
121634
- var SYSML_KEYWORDS_ARRAY = SysMLv2Lexer.literalNames.filter((n2) => n2 != null).map((n2) => n2.replace(/^'|'$/g, "")).filter((n2) => /^[a-z]+$/.test(n2)).sort();
121635
- var SYSML_KEYWORDS = new Set(SYSML_KEYWORDS_ARRAY);
121636
121810
 
121637
121811
  // server/src/utils/documentUri.ts
121638
121812
  function canonicalUri(uri) {
@@ -122411,7 +122585,7 @@ var RE_SPEC_WITH_SUBSETS = /(?:specializes|subsets|:>|:>>)\s*('[^']+'|[A-Za-z_]\
122411
122585
  var RE_DEFINED_BY = /definedby\s*([A-Za-z_]\w*(?:::\w+)*(?:\s*,\s*[A-Za-z_]\w*(?:::\w+)*)*)/;
122412
122586
  var MAX_RULE_SEARCH_DEPTH = 6;
122413
122587
  var RE_TYPING = /:(?![:>])\s*('[^']+'|[A-Za-z_]\w*(?:::\w+)*)/;
122414
- var RE_QUOTED_NAME = /'([^']+)'/;
122588
+ var RE_QUOTED_NAME = /^\s*(?:\$::)?(?:(?:[A-Za-z_]\w*|'\d+')::)*'(\d+)'/;
122415
122589
  var RE_IDENT_START = /^([A-Za-z_]\w*(?:::\w+)*)/;
122416
122590
  var SymbolTable = class {
122417
122591
  /** All symbols indexed by qualified name */
@@ -122478,7 +122652,12 @@ var SymbolTable = class {
122478
122652
  * Find a symbol by name (simple name, not qualified).
122479
122653
  */
122480
122654
  findByName(name) {
122481
- return this.symbolsByName.get(name) ?? [];
122655
+ const exact = this.symbolsByName.get(name);
122656
+ if (exact) return exact;
122657
+ const segments = splitQualifiedName(name);
122658
+ if (segments.length === 1) return this.symbolsByName.get(segments[0]) ?? [];
122659
+ const qualified = this.getSymbol(joinQualifiedName(segments));
122660
+ return qualified ? [qualified] : [];
122482
122661
  }
122483
122662
  /**
122484
122663
  * Find all symbols in a given URI.
@@ -122985,7 +123164,7 @@ var SymbolTable = class {
122985
123164
  const anonymous = !declaredName;
122986
123165
  const name = declaredName ?? "";
122987
123166
  const shortName = transition || isFlowUsage(kind) && !declaredName ? void 0 : this.extractShortName(ctx);
122988
- const qualifiedName = anonymous || owner && owner.qualifiedName === void 0 ? void 0 : owner ? `${owner.qualifiedName}::${name}` : name;
123167
+ const qualifiedName = anonymous || owner && owner.qualifiedName === void 0 ? void 0 : owner ? `${owner.qualifiedName}::${joinQualifiedName([name])}` : joinQualifiedName([name]);
122989
123168
  const selectionRange = anonymous ? ctx.start ? tokenToRange(ctx.start) : range : this.extractNameRange(ctx) ?? range;
122990
123169
  const typeNames = isFlowUsage(kind) ? this.extractFlowTypeNames(ctx) : transition ? this.extractTransitionTypeNames(ctx) : this.extractTypeNames(ctx);
122991
123170
  const specializationNames = this.extractSpecializationNames(ctx);
@@ -123145,7 +123324,10 @@ var SymbolTable = class {
123145
123324
  }
123146
123325
  /** Remove SysML quoting while retaining qualified and dotted references. */
123147
123326
  cleanTransitionText(text) {
123148
- const cleaned = text.replace(/'([^']+)'/g, "$1").trim();
123327
+ const cleaned = text.replace(
123328
+ /'(?:\\.|[^'\\])*'/g,
123329
+ (name) => joinQualifiedName([unquoteName(name)])
123330
+ ).trim();
123149
123331
  return cleaned || void 0;
123150
123332
  }
123151
123333
  /** Extract explicit first/then successions owned by an action body. */
@@ -123318,8 +123500,8 @@ var SymbolTable = class {
123318
123500
  }
123319
123501
  /** The name of the feature a reference such as `a.b` or `P::a` ends at (`b`, `a`). */
123320
123502
  lastNameSegment(reference) {
123321
- const segment = reference.getText().split(/::|\./).pop();
123322
- return segment ? this.unquoteName(segment) : void 0;
123503
+ const names = [...scanQualifiedNames(reference.getText())];
123504
+ return names.at(-1)?.segments.at(-1)?.name;
123323
123505
  }
123324
123506
  declarationTokens(ctx) {
123325
123507
  const tokens = [];
@@ -123455,6 +123637,16 @@ var SymbolTable = class {
123455
123637
  * Extract the range of just the name token.
123456
123638
  */
123457
123639
  extractNameRange(ctx) {
123640
+ if (ctx.ruleIndex === SysMLv2Parser.RULE_identification || ctx.ruleIndex === SysMLv2Parser.RULE_featureIdentification) {
123641
+ let name;
123642
+ for (let i = 0; i < ctx.getChildCount(); i++) {
123643
+ const child = ctx.getChild(i);
123644
+ if (child instanceof ParserRuleContext && child.ruleIndex === SysMLv2Parser.RULE_name) {
123645
+ name = child;
123646
+ }
123647
+ }
123648
+ if (name) return contextToRange(name);
123649
+ }
123458
123650
  for (let i = 0; i < ctx.getChildCount(); i++) {
123459
123651
  const child = ctx.getChild(i);
123460
123652
  if (child instanceof TerminalNode && this.isNameTerminal(child)) {
@@ -123495,7 +123687,7 @@ var SymbolTable = class {
123495
123687
  for (const part of specStr.split(",")) {
123496
123688
  const quoted = quotedName(part);
123497
123689
  if (quoted !== void 0) {
123498
- names.push(quoted);
123690
+ names.push(joinQualifiedName([quoted]));
123499
123691
  continue;
123500
123692
  }
123501
123693
  const m2 = part.trim().match(RE_IDENT_START);
@@ -123518,7 +123710,7 @@ var SymbolTable = class {
123518
123710
  for (const part of afterColon.split(",")) {
123519
123711
  const quoted = quotedName(part);
123520
123712
  if (quoted !== void 0) {
123521
- names.push(quoted);
123713
+ names.push(joinQualifiedName([quoted]));
123522
123714
  continue;
123523
123715
  }
123524
123716
  const m2 = part.trim().match(RE_IDENT_START);
@@ -123529,18 +123721,20 @@ var SymbolTable = class {
123529
123721
  return names;
123530
123722
  }
123531
123723
  /**
123532
- * The declaration tokens before the body, with each lexer STRING token
123724
+ * The declaration tokens before the value or body, with each lexer STRING token
123533
123725
  * replaced by a numbered placeholder (`'0'`, `'1'`, ...), and
123534
123726
  * `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.
123727
+ * the name, when it ends the qualified name the part starts with. SysML
123728
+ * 2.0 section 7.2.2 permits punctuation in unrestricted names (the STRING
123729
+ * lexer production), so fallback regexes must never see their `:`, `:>`,
123730
+ * `{` or keywords. Documentation is not a name token.
123538
123731
  */
123539
123732
  maskedDeclaration(ctx) {
123540
123733
  const quoted = [];
123541
- const masked = this.declarationTokens(ctx).map((token) => {
123734
+ const valueStart = this.findOwnHeaderRule(ctx, SysMLv2Parser.RULE_valuePart)?.start?.tokenIndex;
123735
+ const masked = this.declarationTokens(ctx).filter((token) => valueStart === void 0 || token.tokenIndex < valueStart).map((token) => {
123542
123736
  const text = token.text ?? "";
123543
- return token.type === SysMLv2Lexer.STRING ? `'${quoted.push(text.slice(1, -1)) - 1}'` : text;
123737
+ return token.type === SysMLv2Lexer.STRING ? `'${quoted.push(unquoteName(text)) - 1}'` : text;
123544
123738
  }).join("");
123545
123739
  return {
123546
123740
  text: masked,
@@ -123568,7 +123762,7 @@ var SymbolTable = class {
123568
123762
  for (const part of specStr.split(",")) {
123569
123763
  const quoted = quotedName(part);
123570
123764
  if (quoted !== void 0) {
123571
- names.push(quoted);
123765
+ names.push(joinQualifiedName([quoted]));
123572
123766
  continue;
123573
123767
  }
123574
123768
  const m2 = part.trim().match(RE_IDENT_START);
@@ -123597,17 +123791,7 @@ var SymbolTable = class {
123597
123791
  if (!(child instanceof ParserRuleContext)) continue;
123598
123792
  const ri = child.ruleIndex;
123599
123793
  if (extractionRules.has(ri)) {
123600
- const childText = child.getText();
123601
- const stripped = childText.replace(/^(specializes|:>>|:>|:|definedby|subsets|redefines|references|conjugates|disjoints)/i, "");
123602
- for (const part of stripped.split(",")) {
123603
- const qm = part.match(/'([^']+)'/);
123604
- if (qm) {
123605
- names.push(qm[1]);
123606
- } else {
123607
- const m2 = part.match(/([A-Za-z_]\w*(?:::\w+)*)/);
123608
- if (m2) names.push(m2[1]);
123609
- }
123610
- }
123794
+ this.collectQualifiedTypeNames(child, names);
123611
123795
  } else if (
123612
123796
  // Recurse into declaration / part / body wrappers that may
123613
123797
  // contain nested typing rules (but NOT into body rules that
@@ -123620,6 +123804,17 @@ var SymbolTable = class {
123620
123804
  }
123621
123805
  }
123622
123806
  }
123807
+ collectQualifiedTypeNames(ctx, names) {
123808
+ if (ctx.ruleIndex === SysMLv2Parser.RULE_qualifiedName) {
123809
+ const name = this.extractTextFromSubtree(ctx);
123810
+ if (name) names.push(name);
123811
+ return;
123812
+ }
123813
+ for (let i = 0; i < ctx.getChildCount(); i++) {
123814
+ const child = ctx.getChild(i);
123815
+ if (child instanceof ParserRuleContext) this.collectQualifiedTypeNames(child, names);
123816
+ }
123817
+ }
123623
123818
  /**
123624
123819
  * Extract documentation owned by this element.
123625
123820
  *
@@ -123780,10 +123975,7 @@ var SymbolTable = class {
123780
123975
  * Returns the text unchanged if not quoted.
123781
123976
  */
123782
123977
  unquoteName(text) {
123783
- if (this.isQuotedName(text)) {
123784
- return text.slice(1, -1);
123785
- }
123786
- return text;
123978
+ return unquoteName(text);
123787
123979
  }
123788
123980
  /**
123789
123981
  * Check if a text is a SysML keyword.
@@ -124071,7 +124263,7 @@ var SymbolTable = class {
124071
124263
  const child = ctx.getChild(i);
124072
124264
  if (child instanceof TerminalNode) {
124073
124265
  const text = child.symbol.text;
124074
- if (text) parts.push(text);
124266
+ if (text) parts.push(child.symbol.type === SysMLv2Lexer.STRING ? joinQualifiedName([unquoteName(text)]) : text);
124075
124267
  } else if (child instanceof ParserRuleContext) {
124076
124268
  this.collectExposeText(child, parts);
124077
124269
  }
@@ -124133,58 +124325,24 @@ var SymbolTable = class {
124133
124325
  * Extract all text content from a subtree (concatenate terminal nodes).
124134
124326
  */
124135
124327
  extractTextFromSubtree(ctx) {
124328
+ if (ctx.ruleIndex === SysMLv2Parser.RULE_name) return unquoteName(ctx.getText());
124136
124329
  const parts = [];
124137
124330
  for (let i = 0; i < ctx.getChildCount(); i++) {
124138
124331
  const child = ctx.getChild(i);
124139
124332
  if (child instanceof TerminalNode) {
124140
124333
  const text = child.symbol.text;
124141
124334
  if (text && this.isNameTerminal(child)) {
124142
- parts.push(this.unquoteName(text));
124335
+ parts.push(joinQualifiedName([this.unquoteName(text)]));
124143
124336
  }
124144
124337
  } else if (child instanceof ParserRuleContext) {
124145
124338
  const sub = this.extractTextFromSubtree(child);
124146
- if (sub) parts.push(sub);
124339
+ if (sub) parts.push(child.ruleIndex === SysMLv2Parser.RULE_name ? joinQualifiedName([sub]) : sub);
124147
124340
  }
124148
124341
  }
124149
124342
  return parts.length > 0 ? parts.join("::") : void 0;
124150
124343
  }
124151
124344
  };
124152
124345
 
124153
- // server/src/utils/identUtils.ts
124154
- function isIdentStart(c) {
124155
- return c >= 65 && c <= 90 || c >= 97 && c <= 122 || c === 95;
124156
- }
124157
- function isIdentPart(c) {
124158
- return c >= 65 && c <= 90 || c >= 97 && c <= 122 || c >= 48 && c <= 57 || c === 95;
124159
- }
124160
- function extractQualifiedNameAt(lineText, character) {
124161
- const len = lineText.length;
124162
- let i = 0;
124163
- while (i < len) {
124164
- if (!isIdentStart(lineText.charCodeAt(i))) {
124165
- i++;
124166
- continue;
124167
- }
124168
- const wordStart = i;
124169
- while (i < len) {
124170
- while (i < len && isIdentPart(lineText.charCodeAt(i))) i++;
124171
- if (i + 2 <= len && lineText[i] === ":" && lineText[i + 1] === ":" && i + 2 < len && isIdentStart(lineText.charCodeAt(i + 2))) {
124172
- i += 2;
124173
- } else {
124174
- break;
124175
- }
124176
- }
124177
- const wordEnd = i;
124178
- if (character >= wordStart && character <= wordEnd) {
124179
- return lineText.substring(wordStart, wordEnd);
124180
- }
124181
- }
124182
- return void 0;
124183
- }
124184
- function stripComments(text) {
124185
- return text.replace(/\/\*[\s\S]*?\*\//g, (m2) => m2.replace(/[^\n]/g, " ")).replace(/\/\/[^\n]*/g, (m2) => " ".repeat(m2.length));
124186
- }
124187
-
124188
124346
  // server/src/documentManager.ts
124189
124347
  var DocumentManager = class {
124190
124348
  cache = /* @__PURE__ */ new Map();
@@ -124200,6 +124358,13 @@ var DocumentManager = class {
124200
124358
  * indexed yet" apart from "genuinely doesn't exist".
124201
124359
  */
124202
124360
  workspaceScanComplete = true;
124361
+ /**
124362
+ * Last version given to a stand-in text by `withTexts`. Caches keyed by
124363
+ * version assume one text per uri and version, so each stand-in gets a
124364
+ * version outside the LSP integer range (LSP 3.17, base types).
124365
+ * These internal positive versions are never sent to the client.
124366
+ */
124367
+ temporaryVersion = 2 ** 31 - 1;
124203
124368
  /**
124204
124369
  * Parse a document and cache the result.
124205
124370
  * Returns the cached result if the content hasn't changed.
@@ -124403,6 +124568,35 @@ var DocumentManager = class {
124403
124568
  this.wsSymbolTable.removeUri(uri);
124404
124569
  this.wsBuiltVersions.delete(uri);
124405
124570
  }
124571
+ /**
124572
+ * Runs `fn` with each text standing in for the document at its uri (or
124573
+ * added as a new document), all at once, then restores the previous
124574
+ * state. `fn` must be synchronous: no other request can run in between,
124575
+ * so no other request ever sees the temporary texts. Every text is
124576
+ * parsed before anything changes. The stand-ins get versions no real
124577
+ * document has, so caches keyed by version never confuse them with the
124578
+ * real documents.
124579
+ */
124580
+ withTexts(documents2, fn) {
124581
+ if (!Number.isSafeInteger(this.temporaryVersion + documents2.length)) {
124582
+ throw new RangeError("Temporary document version space exhausted.");
124583
+ }
124584
+ const parsed = documents2.map(({ uri, text }) => ({ uri, text, result: parseDocument(text) }));
124585
+ const previous = new Map(parsed.map(({ uri }) => [uri, this.cache.get(uri)]));
124586
+ for (const { uri, text, result } of parsed) {
124587
+ this.cache.set(uri, { version: ++this.temporaryVersion, text, result, needsParse: false });
124588
+ }
124589
+ try {
124590
+ return fn();
124591
+ } finally {
124592
+ for (const [uri, entry] of previous) {
124593
+ if (entry) this.cache.set(uri, entry);
124594
+ else this.cache.delete(uri);
124595
+ this.wsSymbolTable.removeUri(uri);
124596
+ this.wsBuiltVersions.delete(uri);
124597
+ }
124598
+ }
124599
+ }
124406
124600
  /**
124407
124601
  * Get all cached URIs.
124408
124602
  */
@@ -124479,55 +124673,30 @@ function readWord(line, pos) {
124479
124673
  while (pos < line.length && isIdentPart(line.charCodeAt(pos))) pos++;
124480
124674
  return pos > start ? [line.slice(start, pos), pos] : void 0;
124481
124675
  }
124676
+ function readSimpleName(line, pos) {
124677
+ const name = readNameAt(line, skipSpaces(line, pos));
124678
+ return name ? [name.name, name.end] : void 0;
124679
+ }
124482
124680
  function readName(line, pos) {
124483
124681
  pos = skipSpaces(line, pos);
124484
- if (pos < line.length && line[pos] === "'") {
124485
- pos++;
124486
- const start = pos;
124487
- while (pos < line.length && isIdentPart(line.charCodeAt(pos))) pos++;
124488
- const name = line.slice(start, pos);
124489
- if (pos < line.length && line[pos] === "'") pos++;
124490
- return name ? [name, pos] : void 0;
124491
- }
124492
124682
  if (pos < line.length && line[pos] === "<") {
124493
- pos++;
124494
- const start = pos;
124495
- while (pos < line.length && line[pos] !== ">") pos++;
124496
- const shortName = line.slice(start, pos).trim();
124497
- if (pos < line.length && line[pos] === ">") pos++;
124498
- pos = skipSpaces(line, pos);
124499
- if (pos < line.length && line[pos] === "'") {
124500
- pos++;
124501
- while (pos < line.length && line[pos] !== "'") pos++;
124502
- if (pos < line.length) pos++;
124503
- } else if (pos < line.length && isIdentPart(line.charCodeAt(pos))) {
124504
- while (pos < line.length && isIdentPart(line.charCodeAt(pos))) pos++;
124505
- }
124506
- return shortName ? [shortName, pos] : void 0;
124507
- }
124508
- return readWord(line, pos);
124683
+ const short = readSimpleName(line, pos + 1);
124684
+ if (!short) return void 0;
124685
+ pos = skipSpaces(line, short[1]);
124686
+ if (line[pos] !== ">") return void 0;
124687
+ const long = readSimpleName(line, pos + 1);
124688
+ return [short[0], long?.[1] ?? pos + 1];
124689
+ }
124690
+ return readSimpleName(line, pos);
124509
124691
  }
124510
124692
  function readLongName(line, pos) {
124511
124693
  pos = skipSpaces(line, pos);
124512
124694
  if (pos >= line.length || line[pos] !== "<") return void 0;
124513
- while (pos < line.length && line[pos] !== ">") pos++;
124514
- if (pos < line.length) pos++;
124515
- pos = skipSpaces(line, pos);
124516
- if (pos >= line.length) return void 0;
124517
- if (line[pos] === "'") {
124518
- pos++;
124519
- const start = pos;
124520
- while (pos < line.length && line[pos] !== "'") pos++;
124521
- const longName = line.slice(start, pos).trim();
124522
- if (longName && /^[A-Za-z_]\w*$/.test(longName)) return longName;
124523
- return void 0;
124524
- }
124525
- if (isIdentPart(line.charCodeAt(pos))) {
124526
- const start = pos;
124527
- while (pos < line.length && isIdentPart(line.charCodeAt(pos))) pos++;
124528
- return line.slice(start, pos);
124529
- }
124530
- return void 0;
124695
+ const short = readSimpleName(line, pos + 1);
124696
+ if (!short) return void 0;
124697
+ pos = skipSpaces(line, short[1]);
124698
+ if (line[pos] !== ">") return void 0;
124699
+ return readSimpleName(line, pos + 1)?.[0];
124531
124700
  }
124532
124701
  function matchWord(line, pos, keyword) {
124533
124702
  if (!line.startsWith(keyword, pos)) return false;
@@ -124599,7 +124768,7 @@ function extractPackageNameFromHead(head) {
124599
124768
  if (close < 0) continue;
124600
124769
  pos = skipSpaces(line, close + 1);
124601
124770
  }
124602
- const w = readWord(line, pos);
124771
+ const w = readName(line, pos);
124603
124772
  if (w) return w[0];
124604
124773
  }
124605
124774
  return void 0;
@@ -124724,7 +124893,7 @@ function indexLibraryFile(fileUri, content, packages, types) {
124724
124893
  types.set(usageName, { uri: fileUri, line: i });
124725
124894
  }
124726
124895
  if (pkgName) {
124727
- const qualName = `${pkgName}::${usageName}`;
124896
+ const qualName = joinQualifiedName([pkgName, usageName]);
124728
124897
  if (!types.has(qualName)) {
124729
124898
  types.set(qualName, { uri: fileUri, line: i });
124730
124899
  }
@@ -124735,7 +124904,7 @@ function indexLibraryFile(fileUri, content, packages, types) {
124735
124904
  types.set(longName, { uri: fileUri, line: i });
124736
124905
  }
124737
124906
  if (pkgName) {
124738
- const qualLong = `${pkgName}::${longName}`;
124907
+ const qualLong = joinQualifiedName([pkgName, longName]);
124739
124908
  if (!types.has(qualLong)) {
124740
124909
  types.set(qualLong, { uri: fileUri, line: i });
124741
124910
  }
@@ -124767,15 +124936,17 @@ function initLibraryIndex(serverDir, customPath) {
124767
124936
  }
124768
124937
  function resolveLibraryPackage(name) {
124769
124938
  if (!index) return void 0;
124770
- const pkg = name.split("::")[0];
124939
+ const pkg = splitQualifiedName(name)[0];
124771
124940
  return index.get(pkg);
124772
124941
  }
124773
124942
  function resolveLibraryType(name) {
124774
124943
  if (!typeIndex) return void 0;
124944
+ const segments = splitQualifiedName(name);
124945
+ name = segments.length === 1 ? segments[0] : joinQualifiedName(segments);
124775
124946
  const exact = typeIndex.get(name);
124776
124947
  if (exact) return exact;
124777
- if (name.includes("::")) {
124778
- const member = name.split("::").pop();
124948
+ if (segments.length > 1) {
124949
+ const member = segments[segments.length - 1];
124779
124950
  return typeIndex.get(member);
124780
124951
  }
124781
124952
  return void 0;
@@ -125423,6 +125594,10 @@ var NamespaceResolver = class {
125423
125594
  resolveNameFrom(symbol, name, indexes) {
125424
125595
  return this.resolveQualifiedNameFrom(ownerKeyOf(symbol, indexes.byId), name, indexes);
125425
125596
  }
125597
+ /** Resolve an editor reference within its enclosing namespace, including the root. */
125598
+ resolveNameIn(namespace, name, indexes) {
125599
+ return this.resolveQualifiedNameFrom(namespace ? namespaceKeyOf(namespace) : "", name, indexes);
125600
+ }
125426
125601
  /**
125427
125602
  * Resolve a (possibly qualified) name to its symbol per §7.5.1, searching
125428
125603
  * outward from namespace `start` and its enclosing namespaces (its own resolved
@@ -125434,7 +125609,7 @@ var NamespaceResolver = class {
125434
125609
  * its own enclosing package already imported, per §7.5.1/§7.5.3).
125435
125610
  */
125436
125611
  resolveQualifiedNameFrom(start, name, indexes) {
125437
- const [first, ...rest] = name.split("::");
125612
+ const [first, ...rest] = splitQualifiedName(name);
125438
125613
  let resolved;
125439
125614
  for (const ancestor of this.namespaceAncestorsOf(start, indexes)) {
125440
125615
  const candidates = this.getResolvedMembers(ancestor, indexes).get(first);
@@ -125601,6 +125776,9 @@ var NamespaceResolver = class {
125601
125776
  };
125602
125777
  for (const owned of indexes.byParent.get(namespace) ?? []) {
125603
125778
  addMember(owned.name, { symbol: owned, visibility: owned.visibility ?? "public" });
125779
+ if (owned.shortName) {
125780
+ addMember(owned.shortName, { symbol: owned, visibility: owned.visibility ?? "public" });
125781
+ }
125604
125782
  }
125605
125783
  perIndexesCache.set(namespace, members);
125606
125784
  const owner = typeof namespace === "string" ? indexes.byQualifiedName.get(namespace) : namespace;
@@ -125636,13 +125814,17 @@ var NamespaceResolver = class {
125636
125814
  switch (imp.kind) {
125637
125815
  case "membership": {
125638
125816
  const target = this.resolveQualifiedNameFrom(importingNamespace, imp.target, indexes);
125639
- if (target) addMember(target.name, { symbol: target, visibility: imp.visibility });
125817
+ if (target) {
125818
+ addMember(target.name, { symbol: target, visibility: imp.visibility });
125819
+ if (target.shortName) addMember(target.shortName, { symbol: target, visibility: imp.visibility });
125820
+ }
125640
125821
  break;
125641
125822
  }
125642
125823
  case "membership-deep": {
125643
125824
  const target = this.resolveQualifiedNameFrom(importingNamespace, imp.target, indexes);
125644
125825
  if (target) {
125645
125826
  addMember(target.name, { symbol: target, visibility: imp.visibility });
125827
+ if (target.shortName) addMember(target.shortName, { symbol: target, visibility: imp.visibility });
125646
125828
  this.importVisibleMembers(namespaceKeyOf(target), imp.visibility, indexes, addMember, true);
125647
125829
  }
125648
125830
  break;
@@ -125807,7 +125989,7 @@ function isISQValueType(name) {
125807
125989
  function resolveTypeName(typeName, symbol, resolver, indexes, libraryNames) {
125808
125990
  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])/);
125809
125991
  const strippedTypeName = kwMatch ? kwMatch[1] : typeName;
125810
- const rootSegment = strippedTypeName.split("::")[0];
125992
+ const rootSegment = splitQualifiedName(strippedTypeName)[0];
125811
125993
  const resolved = resolver.isLocallyVisible(symbol, 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
125812
125994
  // via :>), not type references — don't flag them as unresolved types.
125813
125995
  strippedTypeName.charCodeAt(0) >= 97 && strippedTypeName.charCodeAt(0) <= 122;
@@ -127352,11 +127534,11 @@ var CodeActionProvider = class {
127352
127534
  const packageNames = /* @__PURE__ */ new Set();
127353
127535
  for (const s of allSymbols) {
127354
127536
  if (!isDefinition(s.kind)) continue;
127355
- if (s.name !== unresolvedType) continue;
127537
+ if (s.name !== unquoteName(unresolvedType)) continue;
127356
127538
  if (s.uri === uri) continue;
127357
- const pkg = (s.qualifiedName?.split("::")[0] ?? "").trim();
127539
+ const pkg = s.qualifiedName ? splitQualifiedName(s.qualifiedName)[0] : "";
127358
127540
  if (!pkg || pkg === unresolvedType) continue;
127359
- if (pkg) packageNames.add(pkg);
127541
+ packageNames.add(quoteName(pkg));
127360
127542
  }
127361
127543
  for (const pkg of packageNames) {
127362
127544
  if (this.hasImportForPackage(text, pkg)) {
@@ -127465,7 +127647,7 @@ var CodeActionProvider = class {
127465
127647
  const edit = {
127466
127648
  changes: {
127467
127649
  [uri]: [
127468
- import_node2.TextEdit.replace(diagnostic.range, newName)
127650
+ import_node2.TextEdit.replace(diagnostic.range, quoteName(newName))
127469
127651
  ]
127470
127652
  }
127471
127653
  };
@@ -127574,7 +127756,7 @@ ${childIndent}enum value2;`;
127574
127756
  const edit = {
127575
127757
  changes: {
127576
127758
  [uri]: [
127577
- import_node2.TextEdit.replace(diagnostic.range, newName)
127759
+ import_node2.TextEdit.replace(diagnostic.range, quoteName(newName))
127578
127760
  ]
127579
127761
  }
127580
127762
  };
@@ -127635,10 +127817,11 @@ ${childIndent}enum value2;`;
127635
127817
  if (diagnostic.code !== "incompatible-port-types") return void 0;
127636
127818
  const msg = diagnostic.message;
127637
127819
  const m2 = msg.match(/'([^']+)'\s+\(([^)]+)\)\s+is connected to\s+'([^']+)'\s+\(([^)]+)\)/);
127638
- if (!m2) return void 0;
127639
- const left = m2[1];
127640
- const leftType = m2[2];
127641
- const right = m2[3];
127820
+ const data = diagnostic.data;
127821
+ const left = data?.left ?? m2?.[1];
127822
+ const leftType = data?.leftType ?? m2?.[2];
127823
+ const right = data?.right ?? m2?.[3];
127824
+ if (!left || !leftType || !right) return void 0;
127642
127825
  const symbolTable = this.documentManager.getWorkspaceSymbolTable();
127643
127826
  const symbolsInUri = symbolTable.getSymbolsForUri(uri);
127644
127827
  const compatible = symbolsInUri.find(
@@ -127653,8 +127836,10 @@ ${childIndent}enum value2;`;
127653
127836
  if (start.line !== end.line) return void 0;
127654
127837
  const segment = (lines[start.line] ?? "").slice(start.character, end.character);
127655
127838
  if (!segment) return void 0;
127656
- const replaced = segment.replace(new RegExp(`\\b${right}\\b`), compatible.name);
127657
- if (replaced === segment) return void 0;
127839
+ const rightPath = [...scanFeaturePaths(segment)].reverse().find((path3) => path3.parts[path3.parts.length - 1] === right);
127840
+ const rightName = rightPath?.qualifiedNames.at(-1)?.segments.at(-1);
127841
+ if (!rightName) return void 0;
127842
+ const replaced = segment.slice(0, rightName.start) + quoteName(compatible.name) + segment.slice(rightName.end);
127658
127843
  const edit = {
127659
127844
  changes: {
127660
127845
  [uri]: [
@@ -127689,12 +127874,14 @@ ${childIndent}enum value2;`;
127689
127874
  diagnostic.range.end.character
127690
127875
  ) : "";
127691
127876
  const m2 = msg.match(/Unresolved constraint reference\s+'([^']+)'(?:\s+in scope\s+'([^']+)')?/);
127877
+ const data = diagnostic.data;
127692
127878
  const expr = rangeExpr && rangeExpr.includes(".") ? rangeExpr : tokenExpr && tokenExpr.includes(".") ? tokenExpr : m2?.[1] ?? "";
127693
- const scopeName = m2?.[2];
127879
+ const scopeName = data?.scopeName ?? m2?.[2];
127694
127880
  if (!expr) return void 0;
127695
127881
  if (!expr.includes(".")) return void 0;
127696
- const parts = expr.split(".");
127697
- if (parts.length < 2) return void 0;
127882
+ const path3 = [...scanFeaturePaths(expr)].find((path4) => path4.qualifiedNames.length > 1);
127883
+ if (!path3) return void 0;
127884
+ const parts = path3.parts;
127698
127885
  const root = parts[0];
127699
127886
  const unresolvedLeaf = parts[parts.length - 1];
127700
127887
  const symbolTable = this.documentManager.getWorkspaceSymbolTable();
@@ -127706,7 +127893,7 @@ ${childIndent}enum value2;`;
127706
127893
  const rootType = rootUsage ? rootUsage.typeNames[0] ?? rootUsage.typeName : void 0;
127707
127894
  let memberNames = [];
127708
127895
  if (rootType) {
127709
- const typeDef = allSymbols.find((s) => s.name === rootType && s.kind.endsWith(" def"));
127896
+ const typeDef = symbolTable.findByName(rootType).find((s) => isDefinition(s.kind));
127710
127897
  if (typeDef) {
127711
127898
  memberNames = allSymbols.filter((s) => s.parentId === typeDef.symbolId).map((s) => s.name);
127712
127899
  }
@@ -127728,7 +127915,8 @@ ${childIndent}enum value2;`;
127728
127915
  }
127729
127916
  }
127730
127917
  if (!best || best.dist > 4 || best.name === unresolvedLeaf) return void 0;
127731
- const fixedExpr = `${root}.${best.name}`;
127918
+ const leaf = path3.qualifiedNames.at(-1);
127919
+ const fixedExpr = expr.slice(0, leaf.start) + quoteName(best.name) + expr.slice(leaf.end);
127732
127920
  const edit = {
127733
127921
  changes: {
127734
127922
  [uri]: [
@@ -127804,6 +127992,13 @@ ${childIndent}enum value2;`;
127804
127992
  isAttributeTypeContext(text, diagnostic, unresolvedType) {
127805
127993
  const lines = text.split("\n");
127806
127994
  const line = lines[diagnostic.range.start.line] ?? "";
127995
+ const names = [...scanQualifiedNames(line)];
127996
+ const attribute = names.findIndex((name) => line.slice(name.start, name.end) === "attribute");
127997
+ const usage = names[attribute + 1];
127998
+ const type = names[attribute + 2];
127999
+ if (attribute >= 0 && usage && type && type.name === unresolvedType && /^\s*:\s*$/.test(line.slice(usage.end, type.start))) {
128000
+ return true;
128001
+ }
127807
128002
  const beforeRange = line.slice(0, diagnostic.range.start.character);
127808
128003
  const unresolvedInLine = line.slice(diagnostic.range.start.character, diagnostic.range.end.character);
127809
128004
  const escapedType = unresolvedType.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
@@ -127816,18 +128011,19 @@ ${childIndent}enum value2;`;
127816
128011
  return /\battribute\s+[A-Za-z_][A-Za-z0-9_]*\s*:\s*[A-Za-z_][A-Za-z0-9_]*\b/.test(beforeRange + unresolvedInLine);
127817
128012
  }
127818
128013
  buildLocalTypeStub(text, diagnostic, unresolvedType, childIndent) {
128014
+ const sourceName = quoteName(unquoteName(unresolvedType));
127819
128015
  if (this.isAttributeTypeContext(text, diagnostic, unresolvedType)) {
127820
128016
  return {
127821
- title: `Create local 'attribute def ${unresolvedType};'`,
128017
+ title: `Create local 'attribute def ${sourceName};'`,
127822
128018
  stubText: `
127823
- ${childIndent}attribute def ${unresolvedType};
128019
+ ${childIndent}attribute def ${sourceName};
127824
128020
  `
127825
128021
  };
127826
128022
  }
127827
128023
  return {
127828
- title: `Create local 'item def ${unresolvedType};'`,
128024
+ title: `Create local 'item def ${sourceName};'`,
127829
128025
  stubText: `
127830
- ${childIndent}item def ${unresolvedType};
128026
+ ${childIndent}item def ${sourceName};
127831
128027
  `
127832
128028
  };
127833
128029
  }
@@ -127863,13 +128059,12 @@ function extractQuotedString(text, prefixWithQuote) {
127863
128059
  }
127864
128060
  function extractDottedTokenAtRange(line, start, end) {
127865
128061
  if (!line || start < 0 || end < 0 || start > line.length || end > line.length) return "";
127866
- const isTokenChar = (ch) => ch >= "a" && ch <= "z" || ch >= "A" && ch <= "Z" || ch >= "0" && ch <= "9" || ch === "_" || ch === ".";
127867
- let left = Math.max(0, start);
127868
- while (left > 0 && isTokenChar(line[left - 1])) left--;
127869
- let right = Math.min(line.length, end);
127870
- while (right < line.length && isTokenChar(line[right])) right++;
127871
- const token = line.slice(left, right).trim();
127872
- return token.includes(".") ? token : "";
128062
+ for (const path3 of scanFeaturePaths(line)) {
128063
+ if (path3.qualifiedNames.length > 1 && path3.start <= start && path3.end >= end) {
128064
+ return line.slice(path3.start, path3.end);
128065
+ }
128066
+ }
128067
+ return "";
127873
128068
  }
127874
128069
  function extractLikelyMemberNames(text, excludeName) {
127875
128070
  const names = /* @__PURE__ */ new Set();
@@ -127981,6 +128176,7 @@ var CompletionProvider = class {
127981
128176
  seen.add(sym.name);
127982
128177
  defItems.push({
127983
128178
  label: sym.name,
128179
+ insertText: quoteName(sym.name),
127984
128180
  kind: this.mapSymbolKindToCompletionKind(sym.kind),
127985
128181
  detail: `${sym.kind}${sym.qualifiedName !== void 0 && sym.qualifiedName !== sym.name ? ` (${sym.qualifiedName})` : ""}`,
127986
128182
  documentation: sym.documentation,
@@ -128001,6 +128197,7 @@ var CompletionProvider = class {
128001
128197
  seenPorts.add(sym.name);
128002
128198
  items.push({
128003
128199
  label: sym.name,
128200
+ insertText: quoteName(sym.name),
128004
128201
  kind: import_node3.CompletionItemKind.Interface,
128005
128202
  detail: `${sym.kind}${sym.typeNames[0] ? ` : ${sym.typeNames[0]}` : ""}`,
128006
128203
  data: sym.qualifiedName,
@@ -128008,13 +128205,17 @@ var CompletionProvider = class {
128008
128205
  });
128009
128206
  }
128010
128207
  }
128011
- if (context === "type-annotation") {
128012
- return items.filter((i) => this.isTypeOrDefinitionCompletion(i));
128013
- }
128014
- if (context === "connect-endpoint") {
128015
- return items.filter((i) => this.isConnectContextCompletion(i));
128016
- }
128017
- return items;
128208
+ const filtered = context === "type-annotation" ? items.filter((i) => this.isTypeOrDefinitionCompletion(i)) : context === "connect-endpoint" ? items.filter((i) => this.isConnectContextCompletion(i)) : items;
128209
+ const line = this.documentManager.getText(uri)?.split("\n")[params.position.line] ?? "";
128210
+ const segment = [...scanQualifiedNames(line, true)].flatMap((name) => name.segments).find((name) => name.start <= params.position.character && name.end >= params.position.character);
128211
+ if (!segment) return filtered;
128212
+ return filtered.map((item) => item.insertTextFormat === import_node3.InsertTextFormat.Snippet ? item : {
128213
+ ...item,
128214
+ textEdit: {
128215
+ range: import_node3.Range.create(params.position.line, segment.start, params.position.line, segment.end),
128216
+ newText: item.insertText ?? item.label
128217
+ }
128218
+ });
128018
128219
  }
128019
128220
  resolveCompletion(item) {
128020
128221
  return item;
@@ -128087,6 +128288,108 @@ var CompletionProvider = class {
128087
128288
  }
128088
128289
  };
128089
128290
 
128291
+ // server/src/symbols/nameReferences.ts
128292
+ var import_node4 = __toESM(require_node3());
128293
+ var NameReferences = class {
128294
+ constructor(documents2) {
128295
+ this.documents = documents2;
128296
+ this.symbols = documents2.getWorkspaceSymbolTable().getAllSymbols();
128297
+ this.indexes = buildSymbolIndexes(this.symbols);
128298
+ }
128299
+ documents;
128300
+ symbols;
128301
+ indexes;
128302
+ resolver = new NamespaceResolver();
128303
+ at(uri, position) {
128304
+ return this.inDocument(uri, position).find((ref) => ref.range.start.line === position.line && ref.range.start.character <= position.character && ref.range.end.character >= position.character);
128305
+ }
128306
+ to(symbol, includeDeclaration = true) {
128307
+ return this.documents.getUris().flatMap((uri) => this.inDocument(uri, void 0, symbol)).filter((ref) => ref.symbol?.symbolId === symbol.symbolId && (includeDeclaration || !ref.isDeclaration));
128308
+ }
128309
+ inDocument(uri, position, target) {
128310
+ const text = this.documents.getText(uri);
128311
+ const parsed = this.documents.get(uri);
128312
+ if (text === void 0 || !parsed) return [];
128313
+ const doc = TextDocument.create(uri, "sysml", 0, text);
128314
+ const symbols = this.symbols.filter((symbol) => symbol.uri === uri);
128315
+ const braces = parsed.tokenStream.getTokens().filter((token) => token.type === SysMLv2Lexer.LBRACE).map((token) => doc.offsetAt({ line: token.line - 1, character: token.column }));
128316
+ const namespaces = symbols.flatMap((symbol) => {
128317
+ const start = doc.offsetAt(symbol.range.start);
128318
+ const end = doc.offsetAt(symbol.range.end);
128319
+ let lo = 0;
128320
+ let hi = braces.length;
128321
+ while (lo < hi) {
128322
+ const mid = lo + hi >>> 1;
128323
+ if (braces[mid] < start) lo = mid + 1;
128324
+ else hi = mid;
128325
+ }
128326
+ const body = braces[lo];
128327
+ return body === void 0 || body >= end ? [] : [{ symbol, body, end }];
128328
+ }).sort((a, b) => a.end - a.body - (b.end - b.body));
128329
+ const refs = [];
128330
+ const cursor = position ? doc.offsetAt(position) : void 0;
128331
+ for (const path3 of scanFeaturePaths(text)) {
128332
+ if (cursor !== void 0 && (cursor < path3.start || cursor > path3.end)) continue;
128333
+ if (target && !path3.qualifiedNames.some((name) => name.segments.some((segment) => segment.name === target.name || segment.name === target.shortName))) continue;
128334
+ const namespace = namespaces.find((ns) => ns.body < path3.start && path3.end <= ns.end);
128335
+ let receiver;
128336
+ for (let group = 0; group < path3.qualifiedNames.length; group++) {
128337
+ const qualified = path3.qualifiedNames[group];
128338
+ let resolved;
128339
+ for (let index2 = 0; index2 < qualified.segments.length; index2++) {
128340
+ const segment = qualified.segments[index2];
128341
+ const range = import_node4.Range.create(doc.positionAt(segment.start), doc.positionAt(segment.end));
128342
+ let before = segment.start - 1;
128343
+ let after = segment.end;
128344
+ while (before >= 0 && /\s/.test(text[before])) before--;
128345
+ while (after < text.length && /\s/.test(text[after])) after++;
128346
+ const declaration = symbols.find((symbol) => !isAnonymous(symbol) && (symbol.selectionRange.start.line === range.start.line && symbol.selectionRange.start.character === range.start.character && symbol.selectionRange.end.character === range.end.character || symbol.shortName === segment.name && text[before] === "<" && text[after] === ">" && doc.offsetAt(symbol.range.start) <= segment.start && segment.end < doc.offsetAt(symbol.selectionRange.start)));
128347
+ if (declaration) resolved = declaration;
128348
+ else if (index2 > 0) {
128349
+ resolved = resolved ? this.resolver.getResolvedMembers(namespaceKeyOf(resolved), this.indexes).get(segment.name)?.find((entry) => entry.visibility === "public")?.symbol : void 0;
128350
+ } else if (group > 0) {
128351
+ resolved = receiver ? this.resolveFeature(receiver, segment.name) : void 0;
128352
+ } else {
128353
+ resolved = this.resolver.resolveNameIn(
128354
+ namespace?.symbol,
128355
+ joinQualifiedName([segment.name]),
128356
+ this.indexes
128357
+ );
128358
+ }
128359
+ if (cursor !== void 0 && (cursor < segment.start || cursor > segment.end)) continue;
128360
+ if (target && segment.name !== target.name && segment.name !== target.shortName) continue;
128361
+ refs.push({
128362
+ uri,
128363
+ range,
128364
+ name: segment.name,
128365
+ qualifiedName: index2 === qualified.segments.length - 1 ? qualified.name : segment.name,
128366
+ symbol: resolved,
128367
+ isDeclaration: declaration !== void 0
128368
+ });
128369
+ }
128370
+ receiver = resolved;
128371
+ }
128372
+ }
128373
+ return refs;
128374
+ }
128375
+ resolveFeature(receiver, name) {
128376
+ const queue = [receiver];
128377
+ const visited = /* @__PURE__ */ new Set();
128378
+ for (let index2 = 0; index2 < queue.length; index2++) {
128379
+ const owner = queue[index2];
128380
+ if (visited.has(owner)) continue;
128381
+ visited.add(owner);
128382
+ const member = this.resolver.getResolvedMembers(namespaceKeyOf(owner), this.indexes).get(name)?.find((entry) => entry.visibility === "public")?.symbol;
128383
+ if (member) return member;
128384
+ for (const typeName of owner.typeNames) {
128385
+ const type = this.resolver.resolveNameFrom(owner, typeName, this.indexes);
128386
+ if (type && !visited.has(type)) queue.push(type);
128387
+ }
128388
+ }
128389
+ return void 0;
128390
+ }
128391
+ };
128392
+
128090
128393
  // server/src/providers/definitionProvider.ts
128091
128394
  var DefinitionProvider = class {
128092
128395
  constructor(documentManager2) {
@@ -128099,6 +128402,10 @@ var DefinitionProvider = class {
128099
128402
  return null;
128100
128403
  }
128101
128404
  const wsSymbolTable = this.documentManager.getWorkspaceSymbolTable();
128405
+ const reference = new NameReferences(this.documentManager).at(params.textDocument.uri, params.position);
128406
+ if (reference?.symbol && !reference.isDeclaration) {
128407
+ return { uri: reference.symbol.uri, range: reference.symbol.selectionRange };
128408
+ }
128102
128409
  const symbol = symbolTable.findSymbolAtPosition(
128103
128410
  params.textDocument.uri,
128104
128411
  params.position.line,
@@ -128206,7 +128513,7 @@ var DefinitionProvider = class {
128206
128513
  };
128207
128514
 
128208
128515
  // server/src/providers/diagnosticsProvider.ts
128209
- var import_node4 = __toESM(require_node3());
128516
+ var import_node5 = __toESM(require_node3());
128210
128517
  var EXPRESSION_OPERATOR_RE = /(\w\s*[+\-*/^]\s*\w)|(\w\s*\*\*\s*\w)|->|\.(?:\?)|:=|;\s*doc\b|#\w+\s+dependency/;
128211
128518
  var DiagnosticsProvider = class {
128212
128519
  constructor(documentManager2) {
@@ -128258,7 +128565,7 @@ var DiagnosticsProvider = class {
128258
128565
  message = `'${word}' is a reserved SysML keyword and cannot be used as a name. Consider renaming it (e.g., '${suggestion}').`;
128259
128566
  }
128260
128567
  return {
128261
- severity: import_node4.DiagnosticSeverity.Error,
128568
+ severity: import_node5.DiagnosticSeverity.Error,
128262
128569
  range: {
128263
128570
  start: { line: error.line, character: error.column },
128264
128571
  end: { line: error.line, character: error.column + error.length }
@@ -128327,51 +128634,51 @@ var DiagnosticsProvider = class {
128327
128634
  };
128328
128635
 
128329
128636
  // server/src/providers/symbolKindMapping.ts
128330
- var import_node5 = __toESM(require_node3());
128637
+ var import_node6 = __toESM(require_node3());
128331
128638
  function toSysMLSymbolKind(kind) {
128332
128639
  switch (kind) {
128333
128640
  // Structural definitions → Class (they *are* types)
128334
128641
  case "part def" /* PartDef */:
128335
128642
  case "occurrence def" /* OccurrenceDef */:
128336
- return import_node5.SymbolKind.Class;
128643
+ return import_node6.SymbolKind.Class;
128337
128644
  // Structural usages → Field (instances / typed features)
128338
128645
  case "part" /* PartUsage */:
128339
128646
  case "occurrence" /* OccurrenceUsage */:
128340
128647
  case "ref" /* RefUsage */:
128341
- return import_node5.SymbolKind.Field;
128648
+ return import_node6.SymbolKind.Field;
128342
128649
  // Attributes
128343
128650
  case "attribute def" /* AttributeDef */:
128344
128651
  case "attribute" /* AttributeUsage */:
128345
- return import_node5.SymbolKind.Property;
128652
+ return import_node6.SymbolKind.Property;
128346
128653
  // Ports & Interfaces → Interface
128347
128654
  case "port def" /* PortDef */:
128348
128655
  case "port" /* PortUsage */:
128349
128656
  case "interface def" /* InterfaceDef */:
128350
128657
  case "interface" /* InterfaceUsage */:
128351
- return import_node5.SymbolKind.Interface;
128658
+ return import_node6.SymbolKind.Interface;
128352
128659
  // Connections
128353
128660
  case "connection def" /* ConnectionDef */:
128354
128661
  case "connection" /* ConnectionUsage */:
128355
- return import_node5.SymbolKind.Interface;
128662
+ return import_node6.SymbolKind.Interface;
128356
128663
  // Behavioral: actions → Method
128357
128664
  case "action def" /* ActionDef */:
128358
128665
  case "action" /* ActionUsage */:
128359
128666
  case "perform action" /* PerformActionUsage */:
128360
- return import_node5.SymbolKind.Method;
128667
+ return import_node6.SymbolKind.Method;
128361
128668
  // Control-flow nodes (fork/join/merge/decide) → Event
128362
128669
  case "fork" /* ForkNode */:
128363
128670
  case "join" /* JoinNode */:
128364
128671
  case "merge" /* MergeNode */:
128365
128672
  case "decide" /* DecisionNode */:
128366
- return import_node5.SymbolKind.Event;
128673
+ return import_node6.SymbolKind.Event;
128367
128674
  // Behavioral: states → Event (better semantic fit than Enum)
128368
128675
  case "state def" /* StateDef */:
128369
128676
  case "state" /* StateUsage */:
128370
128677
  case "exhibit state" /* ExhibitStateUsage */:
128371
- return import_node5.SymbolKind.Event;
128678
+ return import_node6.SymbolKind.Event;
128372
128679
  // Transitions → Event
128373
128680
  case "transition" /* TransitionUsage */:
128374
- return import_node5.SymbolKind.Event;
128681
+ return import_node6.SymbolKind.Event;
128375
128682
  // Requirements → Object
128376
128683
  case "requirement def" /* RequirementDef */:
128377
128684
  case "requirement" /* RequirementUsage */:
@@ -128380,58 +128687,58 @@ function toSysMLSymbolKind(kind) {
128380
128687
  case "actor" /* ActorUsage */:
128381
128688
  case "subject" /* SubjectUsage */:
128382
128689
  case "stakeholder" /* StakeholderUsage */:
128383
- return import_node5.SymbolKind.Object;
128690
+ return import_node6.SymbolKind.Object;
128384
128691
  // Constraints → Constant (boolean-valued)
128385
128692
  case "constraint def" /* ConstraintDef */:
128386
128693
  case "constraint" /* ConstraintUsage */:
128387
- return import_node5.SymbolKind.Constant;
128694
+ return import_node6.SymbolKind.Constant;
128388
128695
  // Items → Struct (physical things, data)
128389
128696
  case "item def" /* ItemDef */:
128390
128697
  case "item" /* ItemUsage */:
128391
- return import_node5.SymbolKind.Struct;
128698
+ return import_node6.SymbolKind.Struct;
128392
128699
  // Allocations → TypeParameter (cross-concern mapping)
128393
128700
  case "allocation def" /* AllocationDef */:
128394
128701
  case "allocation" /* AllocationUsage */:
128395
- return import_node5.SymbolKind.TypeParameter;
128702
+ return import_node6.SymbolKind.TypeParameter;
128396
128703
  // Enumerations
128397
128704
  case "enum def" /* EnumDef */:
128398
- return import_node5.SymbolKind.Enum;
128705
+ return import_node6.SymbolKind.Enum;
128399
128706
  case "enum" /* EnumUsage */:
128400
- return import_node5.SymbolKind.EnumMember;
128707
+ return import_node6.SymbolKind.EnumMember;
128401
128708
  // Calculations → Function
128402
128709
  case "calc def" /* CalcDef */:
128403
128710
  case "calc" /* CalcUsage */:
128404
128711
  case "analysis case def" /* AnalysisCaseDef */:
128405
128712
  case "verification case def" /* VerificationCaseDef */:
128406
- return import_node5.SymbolKind.Function;
128713
+ return import_node6.SymbolKind.Function;
128407
128714
  // Use cases → Event
128408
128715
  case "use case def" /* UseCaseDef */:
128409
128716
  case "use case" /* UseCaseUsage */:
128410
128717
  case "include use case" /* IncludeUseCaseUsage */:
128411
- return import_node5.SymbolKind.Event;
128718
+ return import_node6.SymbolKind.Event;
128412
128719
  // Views → Namespace
128413
128720
  case "view def" /* ViewDef */:
128414
128721
  case "view" /* ViewUsage */:
128415
128722
  case "viewpoint def" /* ViewpointDef */:
128416
128723
  case "viewpoint" /* ViewpointUsage */:
128417
128724
  case "rendering def" /* RenderingDef */:
128418
- return import_node5.SymbolKind.Namespace;
128725
+ return import_node6.SymbolKind.Namespace;
128419
128726
  // Metadata → TypeParameter
128420
128727
  case "metadata def" /* MetadataDef */:
128421
- return import_node5.SymbolKind.TypeParameter;
128728
+ return import_node6.SymbolKind.TypeParameter;
128422
128729
  // Package
128423
128730
  case "package" /* Package */:
128424
- return import_node5.SymbolKind.Package;
128731
+ return import_node6.SymbolKind.Package;
128425
128732
  // Comments / docs
128426
128733
  case "comment" /* Comment */:
128427
128734
  case "doc" /* Doc */:
128428
- return import_node5.SymbolKind.String;
128735
+ return import_node6.SymbolKind.String;
128429
128736
  // Import / Alias
128430
128737
  case "import" /* Import */:
128431
128738
  case "alias" /* Alias */:
128432
- return import_node5.SymbolKind.Module;
128739
+ return import_node6.SymbolKind.Module;
128433
128740
  default:
128434
- return import_node5.SymbolKind.Variable;
128741
+ return import_node6.SymbolKind.Variable;
128435
128742
  }
128436
128743
  }
128437
128744
 
@@ -128478,7 +128785,7 @@ var DocumentSymbolProvider = class {
128478
128785
  };
128479
128786
 
128480
128787
  // server/src/providers/foldingRangeProvider.ts
128481
- var import_node6 = __toESM(require_node3());
128788
+ var import_node7 = __toESM(require_node3());
128482
128789
  var FoldingRangeProvider = class {
128483
128790
  constructor(documentManager2) {
128484
128791
  this.documentManager = documentManager2;
@@ -128501,7 +128808,7 @@ var FoldingRangeProvider = class {
128501
128808
  ranges.push({
128502
128809
  startLine: commentStart,
128503
128810
  endLine: i,
128504
- kind: import_node6.FoldingRangeKind.Comment
128811
+ kind: import_node7.FoldingRangeKind.Comment
128505
128812
  });
128506
128813
  commentStart = void 0;
128507
128814
  }
@@ -128514,7 +128821,7 @@ var FoldingRangeProvider = class {
128514
128821
  ranges.push({
128515
128822
  startLine,
128516
128823
  endLine: i,
128517
- kind: import_node6.FoldingRangeKind.Region
128824
+ kind: import_node7.FoldingRangeKind.Region
128518
128825
  });
128519
128826
  }
128520
128827
  }
@@ -128525,7 +128832,7 @@ var FoldingRangeProvider = class {
128525
128832
  };
128526
128833
 
128527
128834
  // server/src/providers/formattingProvider.ts
128528
- var import_node7 = __toESM(require_node3());
128835
+ var import_node8 = __toESM(require_node3());
128529
128836
  var FormattingProvider = class {
128530
128837
  constructor(documents2) {
128531
128838
  this.documents = documents2;
@@ -128541,8 +128848,8 @@ var FormattingProvider = class {
128541
128848
  const formatted = this.formatSysML(text, indent);
128542
128849
  if (formatted === text) return [];
128543
128850
  return [
128544
- import_node7.TextEdit.replace(
128545
- import_node7.Range.create(0, 0, doc.lineCount, 0),
128851
+ import_node8.TextEdit.replace(
128852
+ import_node8.Range.create(0, 0, doc.lineCount, 0),
128546
128853
  formatted
128547
128854
  )
128548
128855
  ];
@@ -128556,7 +128863,7 @@ var FormattingProvider = class {
128556
128863
  const rangeText = doc.getText(params.range);
128557
128864
  const formatted = this.formatSysML(rangeText, indent);
128558
128865
  if (formatted === rangeText) return [];
128559
- return [import_node7.TextEdit.replace(params.range, formatted)];
128866
+ return [import_node8.TextEdit.replace(params.range, formatted)];
128560
128867
  }
128561
128868
  formatSysML(text, indent) {
128562
128869
  const lines = text.split("\n");
@@ -128692,7 +128999,7 @@ var FormattingProvider = class {
128692
128999
  };
128693
129000
 
128694
129001
  // server/src/providers/hoverProvider.ts
128695
- var import_node8 = __toESM(require_node3());
129002
+ var import_node9 = __toESM(require_node3());
128696
129003
  var HoverProvider = class {
128697
129004
  constructor(documentManager2) {
128698
129005
  this.documentManager = documentManager2;
@@ -128709,12 +129016,13 @@ var HoverProvider = class {
128709
129016
  return null;
128710
129017
  }
128711
129018
  const text = this.documentManager.getText(params.textDocument.uri);
128712
- const word = text ? this.getWordAtPosition(text, params.position.line, params.position.character) : void 0;
128713
- if (word && word.includes("::")) {
129019
+ const reference = new NameReferences(this.documentManager).at(params.textDocument.uri, params.position);
129020
+ const word = reference?.qualifiedName ?? (text ? this.getWordAtPosition(text, params.position.line, params.position.character) : void 0);
129021
+ if (word && word.includes("::") && !reference?.symbol) {
128714
129022
  const libHover = this.buildLibraryHover(word);
128715
129023
  if (libHover) return libHover;
128716
129024
  }
128717
- const symbol = symbolTable.findSymbolAtPosition(
129025
+ const symbol = reference?.symbol ?? symbolTable.findSymbolAtPosition(
128718
129026
  params.textDocument.uri,
128719
129027
  params.position.line,
128720
129028
  params.position.character
@@ -128766,7 +129074,7 @@ ${symbol.documentation}`);
128766
129074
  if (hoverDiags.length > 0) {
128767
129075
  lines.push("\n---\n**Semantic Feedback**");
128768
129076
  for (const d of hoverDiags.slice(0, 3)) {
128769
- const sev = d.severity === import_node8.DiagnosticSeverity.Error ? "Error" : d.severity === import_node8.DiagnosticSeverity.Warning ? "Warning" : "Hint";
129077
+ const sev = d.severity === import_node9.DiagnosticSeverity.Error ? "Error" : d.severity === import_node9.DiagnosticSeverity.Warning ? "Warning" : "Hint";
128770
129078
  lines.push(`- **${sev}**: ${d.message}`);
128771
129079
  const hint = this.getRepairHint(String(d.code ?? ""));
128772
129080
  if (hint) {
@@ -128775,12 +129083,12 @@ ${symbol.documentation}`);
128775
129083
  }
128776
129084
  }
128777
129085
  const content = {
128778
- kind: import_node8.MarkupKind.Markdown,
129086
+ kind: import_node9.MarkupKind.Markdown,
128779
129087
  value: lines.join("\n")
128780
129088
  };
128781
129089
  return {
128782
129090
  contents: content,
128783
- range: symbol.selectionRange
129091
+ range: reference?.range ?? symbol.selectionRange
128784
129092
  };
128785
129093
  }
128786
129094
  /**
@@ -128807,7 +129115,7 @@ ${info.documentation}`);
128807
129115
  }
128808
129116
  return {
128809
129117
  contents: {
128810
- kind: import_node8.MarkupKind.Markdown,
129118
+ kind: import_node9.MarkupKind.Markdown,
128811
129119
  value: lines.join("\n")
128812
129120
  }
128813
129121
  };
@@ -128847,7 +129155,7 @@ ${info.documentation}`);
128847
129155
  };
128848
129156
 
128849
129157
  // server/src/providers/keywordValidator.ts
128850
- var import_node9 = __toESM(require_node3());
129158
+ var import_node10 = __toESM(require_node3());
128851
129159
 
128852
129160
  // server/src/utils/emptyNames.ts
128853
129161
  var EMPTY_NAME_MESSAGE = "Empty name '': a name in single quotes must contain at least one character";
@@ -129246,7 +129554,7 @@ function validateKeywords(result) {
129246
129554
  const line2 = (token.line ?? 1) - 1;
129247
129555
  const char2 = token.column ?? 0;
129248
129556
  diagnostics.push({
129249
- severity: import_node9.DiagnosticSeverity.Error,
129557
+ severity: import_node10.DiagnosticSeverity.Error,
129250
129558
  range: { start: { line: line2, character: char2 }, end: { line: line2, character: char2 + 2 } },
129251
129559
  message: EMPTY_NAME_MESSAGE,
129252
129560
  source: "sysml",
@@ -129264,7 +129572,7 @@ function validateKeywords(result) {
129264
129572
  const char = token.column ?? 0;
129265
129573
  const message = `Unknown keyword '${text}'. Did you mean '${suggestion}'?`;
129266
129574
  diagnostics.push({
129267
- severity: import_node9.DiagnosticSeverity.Error,
129575
+ severity: import_node10.DiagnosticSeverity.Error,
129268
129576
  range: {
129269
129577
  start: { line, character: char },
129270
129578
  end: { line, character: char + text.length }
@@ -129284,115 +129592,50 @@ var ReferencesProvider = class {
129284
129592
  }
129285
129593
  documentManager;
129286
129594
  provideReferences(params) {
129287
- const result = this.documentManager.get(params.textDocument.uri);
129288
- if (!result) {
129289
- return [];
129290
- }
129291
- const symbolTable = this.documentManager.getWorkspaceSymbolTable();
129292
- const symbol = symbolTable.findSymbolAtPosition(
129293
- params.textDocument.uri,
129294
- params.position.line,
129295
- params.position.character
129296
- );
129297
- if (!symbol || isAnonymous(symbol)) {
129298
- return [];
129299
- }
129300
- const references = symbolTable.findReferences(symbol.name);
129301
- const locations = [];
129302
- for (const ref of references) {
129303
- locations.push({
129304
- uri: ref.uri,
129305
- range: ref.selectionRange
129306
- });
129307
- }
129308
- if (params.context.includeDeclaration) {
129309
- }
129310
- return locations;
129595
+ const references = new NameReferences(this.documentManager);
129596
+ const ref = references.at(params.textDocument.uri, params.position);
129597
+ return ref?.symbol ? references.to(ref.symbol, params.context.includeDeclaration).map(({ uri, range }) => ({ uri, range })) : [];
129311
129598
  }
129312
129599
  };
129313
129600
 
129314
129601
  // server/src/providers/renameProvider.ts
129315
- function findWordOccurrences(line, word) {
129316
- const positions = [];
129317
- let from = 0;
129318
- while (from <= line.length - word.length) {
129319
- const idx = line.indexOf(word, from);
129320
- if (idx < 0) break;
129321
- if ((idx === 0 || !isIdentPart(line.charCodeAt(idx - 1))) && (idx + word.length >= line.length || !isIdentPart(line.charCodeAt(idx + word.length)))) {
129322
- positions.push(idx);
129323
- }
129324
- from = idx + 1;
129325
- }
129326
- return positions;
129327
- }
129602
+ var import_node11 = __toESM(require_node3());
129328
129603
  var RenameProvider = class {
129329
129604
  constructor(documentManager2) {
129330
129605
  this.documentManager = documentManager2;
129331
129606
  }
129332
129607
  documentManager;
129333
- /**
129334
- * Check if the token at position is renameable and return its range.
129335
- */
129336
129608
  prepareRename(params) {
129337
- const symbolTable = this.documentManager.getSymbolTable(params.textDocument.uri);
129338
- if (!symbolTable) return null;
129339
- const symbol = symbolTable.findSymbolAtPosition(
129340
- params.textDocument.uri,
129341
- params.position.line,
129342
- params.position.character
129343
- );
129344
- if (!symbol || isAnonymous(symbol)) return null;
129345
- return symbol.selectionRange;
129609
+ const ref = new NameReferences(this.documentManager).at(params.textDocument.uri, params.position);
129610
+ return ref?.symbol ? ref.range : null;
129346
129611
  }
129347
- /**
129348
- * Perform the rename — update the symbol and all references.
129349
- */
129350
129612
  provideRename(params) {
129351
- const symbolTable = this.documentManager.getSymbolTable(params.textDocument.uri);
129352
- if (!symbolTable) return null;
129353
- const symbol = symbolTable.findSymbolAtPosition(
129354
- params.textDocument.uri,
129355
- params.position.line,
129356
- params.position.character
129357
- );
129358
- if (!symbol || isAnonymous(symbol)) return null;
129359
- const text = this.documentManager.getText(params.textDocument.uri);
129360
- if (!text) return null;
129361
- const edits = [];
129362
- const oldName = symbol.name;
129363
- const newName = params.newName;
129364
- const references = symbolTable.findReferences(oldName);
129365
- for (const ref of references) {
129366
- if (ref.uri === params.textDocument.uri) {
129367
- edits.push({
129368
- range: ref.selectionRange,
129369
- newText: newName
129370
- });
129371
- }
129613
+ const references = new NameReferences(this.documentManager);
129614
+ const ref = references.at(params.textDocument.uri, params.position);
129615
+ if (!ref?.symbol) return null;
129616
+ const invalidControl = [...params.newName].some((ch) => {
129617
+ const code = ch.charCodeAt(0);
129618
+ return code < 32 && !" \n\r".includes(ch) || code === 127;
129619
+ });
129620
+ if (!params.newName || invalidControl) {
129621
+ throw new import_node11.ResponseError(import_node11.ErrorCodes.InvalidParams, "A SysML name must be non-empty and contain printable characters or escaped whitespace.");
129372
129622
  }
129373
- const lines = text.split("\n");
129374
- for (let i = 0; i < lines.length; i++) {
129375
- for (const col of findWordOccurrences(lines[i], oldName)) {
129376
- const range = {
129377
- start: { line: i, character: col },
129378
- end: { line: i, character: col + oldName.length }
129379
- };
129380
- if (!edits.some((e) => e.range.start.line === i && e.range.start.character === col)) {
129381
- edits.push({ range, newText: newName });
129382
- }
129383
- }
129623
+ const parsed = params.newName.startsWith("'") ? readNameAt(params.newName, 0) : void 0;
129624
+ if (params.newName.startsWith("'") && parsed?.end !== params.newName.length) {
129625
+ throw new import_node11.ResponseError(import_node11.ErrorCodes.InvalidParams, "The quoted SysML name is incomplete or contains an invalid escape sequence.");
129384
129626
  }
129385
- if (edits.length === 0) return null;
129386
- return {
129387
- changes: {
129388
- [params.textDocument.uri]: edits
129389
- }
129390
- };
129627
+ const newText = quoteName(parsed?.name ?? params.newName);
129628
+ const changes = {};
129629
+ for (const occurrence of references.to(ref.symbol)) {
129630
+ if (occurrence.name !== ref.name) continue;
129631
+ (changes[occurrence.uri] ??= []).push({ range: occurrence.range, newText });
129632
+ }
129633
+ return Object.keys(changes).length > 0 ? { changes } : null;
129391
129634
  }
129392
129635
  };
129393
129636
 
129394
129637
  // server/src/providers/semanticTokensProvider.ts
129395
- var import_node10 = __toESM(require_node3());
129638
+ var import_node12 = __toESM(require_node3());
129396
129639
  var OPERATOR_TOKENS = /* @__PURE__ */ new Set([
129397
129640
  SysMLv2Lexer.BANG_EQ_EQ,
129398
129641
  // !==
@@ -129533,7 +129776,7 @@ var SemanticTokensProvider = class {
129533
129776
  if (this.tokenCache && this.tokenCache.uri === uri && this.tokenCache.version === version) {
129534
129777
  return this.tokenCache.tokens;
129535
129778
  }
129536
- const builder = new import_node10.SemanticTokensBuilder();
129779
+ const builder = new import_node12.SemanticTokensBuilder();
129537
129780
  const result = this.documentManager.get(uri);
129538
129781
  if (!result) {
129539
129782
  return builder.build();
@@ -129613,7 +129856,7 @@ var SemanticTokensProvider = class {
129613
129856
  };
129614
129857
 
129615
129858
  // server/src/providers/semanticValidator.ts
129616
- var import_node11 = __toESM(require_node3());
129859
+ var import_node13 = __toESM(require_node3());
129617
129860
  var CONSTRAINT_KEYWORDS = /* @__PURE__ */ new Set([
129618
129861
  "and",
129619
129862
  "or",
@@ -129739,7 +129982,7 @@ var SemanticValidator = class _SemanticValidator {
129739
129982
  const { resolved, strippedTypeName: typeName } = resolveTypeName(symbol.typeName, symbol, this.namespaceResolver, indexes, libraryNames);
129740
129983
  if (resolved) return [];
129741
129984
  const isMandatory = symbol.multiplicityRange && symbol.multiplicityRange.lower >= 1;
129742
- const severity = isMandatory ? import_node11.DiagnosticSeverity.Error : import_node11.DiagnosticSeverity.Warning;
129985
+ const severity = isMandatory ? import_node13.DiagnosticSeverity.Error : import_node13.DiagnosticSeverity.Warning;
129743
129986
  let message = `Type '${typeName}' is not defined in the current document or standard library`;
129744
129987
  if (isMandatory) {
129745
129988
  const multStr = symbol.multiplicity ?? "1";
@@ -129765,7 +130008,7 @@ var SemanticValidator = class _SemanticValidator {
129765
130008
  const { lower, upper } = symbol.multiplicityRange;
129766
130009
  if (typeof upper === "number" && lower > upper) {
129767
130010
  return [{
129768
- severity: import_node11.DiagnosticSeverity.Error,
130011
+ severity: import_node13.DiagnosticSeverity.Error,
129769
130012
  range: symbol.selectionRange,
129770
130013
  message: `Invalid multiplicity [${symbol.multiplicity}]: lower bound (${lower}) exceeds upper bound (${upper})`,
129771
130014
  source: "sysml",
@@ -129774,7 +130017,7 @@ var SemanticValidator = class _SemanticValidator {
129774
130017
  }
129775
130018
  if (lower < 0) {
129776
130019
  return [{
129777
- severity: import_node11.DiagnosticSeverity.Error,
130020
+ severity: import_node13.DiagnosticSeverity.Error,
129778
130021
  range: symbol.selectionRange,
129779
130022
  message: `Invalid multiplicity [${symbol.multiplicity}]: lower bound cannot be negative`,
129780
130023
  source: "sysml",
@@ -129798,7 +130041,7 @@ var SemanticValidator = class _SemanticValidator {
129798
130041
  );
129799
130042
  if (!hasEnumValues) {
129800
130043
  return [{
129801
- severity: import_node11.DiagnosticSeverity.Information,
130044
+ severity: import_node13.DiagnosticSeverity.Information,
129802
130045
  range: symbol.selectionRange,
129803
130046
  message: `Enumeration '${displayName(symbol)}' has no enum values defined`,
129804
130047
  source: "sysml",
@@ -129818,7 +130061,7 @@ var SemanticValidator = class _SemanticValidator {
129818
130061
  const ch = symbol.name[0];
129819
130062
  if (ch === ch.toLowerCase() && ch !== ch.toUpperCase()) {
129820
130063
  return [{
129821
- severity: import_node11.DiagnosticSeverity.Hint,
130064
+ severity: import_node13.DiagnosticSeverity.Hint,
129822
130065
  range: symbol.selectionRange,
129823
130066
  message: `Definition '${symbol.name}' should use PascalCase`,
129824
130067
  source: "sysml",
@@ -129830,7 +130073,7 @@ var SemanticValidator = class _SemanticValidator {
129830
130073
  const ch = symbol.name[0];
129831
130074
  if (ch === ch.toUpperCase() && ch !== ch.toLowerCase()) {
129832
130075
  return [{
129833
- severity: import_node11.DiagnosticSeverity.Hint,
130076
+ severity: import_node13.DiagnosticSeverity.Hint,
129834
130077
  range: symbol.selectionRange,
129835
130078
  message: `Usage '${symbol.name}' should use camelCase`,
129836
130079
  source: "sysml",
@@ -129849,7 +130092,7 @@ var SemanticValidator = class _SemanticValidator {
129849
130092
  if (!isDefinition(symbol.kind)) return [];
129850
130093
  if (symbol.documentation) return [];
129851
130094
  return [{
129852
- severity: import_node11.DiagnosticSeverity.Information,
130095
+ severity: import_node13.DiagnosticSeverity.Information,
129853
130096
  range: symbol.selectionRange,
129854
130097
  message: `Definition '${displayName(symbol)}' has no documentation`,
129855
130098
  source: "sysml",
@@ -129868,23 +130111,23 @@ var SemanticValidator = class _SemanticValidator {
129868
130111
  );
129869
130112
  const defsInScope = targetUri ? defs.filter((def) => def.uri === targetUri) : defs;
129870
130113
  const referencedTypes = new Set(
129871
- symbols.filter((s) => s.kind !== "package" /* Package */).flatMap((s) => s.typeNames)
130114
+ symbols.filter((s) => s.kind !== "package" /* Package */).flatMap((s) => s.typeNames.flatMap((name) => [name, splitQualifiedName(name).at(-1)]))
129872
130115
  );
129873
130116
  for (const s of symbols) {
129874
130117
  if (s.exposeTargets) {
129875
130118
  for (const target of s.exposeTargets) {
129876
- const simpleName = target.replace(/::\*{1,2}$/, "").split("::").pop();
130119
+ const simpleName = splitQualifiedName(target.replace(/::\*{1,2}$/, "")).pop();
129877
130120
  if (simpleName) referencedTypes.add(simpleName);
129878
130121
  }
129879
130122
  }
129880
130123
  }
129881
130124
  const diagnostics = [];
129882
130125
  for (const def of defsInScope) {
129883
- const isReferenced = referencedTypes.has(def.name);
130126
+ const isReferenced = referencedTypes.has(def.name) || def.shortName !== void 0 && referencedTypes.has(def.shortName);
129884
130127
  const hasBaseType = (def.typeNames?.length ?? 0) > 0;
129885
130128
  if (!isReferenced && !hasBaseType) {
129886
130129
  diagnostics.push({
129887
- severity: import_node11.DiagnosticSeverity.Warning,
130130
+ severity: import_node13.DiagnosticSeverity.Warning,
129888
130131
  range: def.selectionRange,
129889
130132
  message: `Definition '${def.name}' is not referenced by any usage in the workspace`,
129890
130133
  source: "sysml",
@@ -129959,7 +130202,7 @@ var SemanticValidator = class _SemanticValidator {
129959
130202
  const cycle = this.followSpecializationChain(def.name, def.typeNames, visited, indexes);
129960
130203
  if (cycle) {
129961
130204
  diagnostics.push({
129962
- severity: import_node11.DiagnosticSeverity.Error,
130205
+ severity: import_node13.DiagnosticSeverity.Error,
129963
130206
  range: def.selectionRange,
129964
130207
  message: `Circular specialization: ${cycle.join(" :> ")} :> ${cycle[0]}`,
129965
130208
  source: "sysml",
@@ -130047,7 +130290,7 @@ var SemanticValidator = class _SemanticValidator {
130047
130290
  const isSatisfied = satisfiedNames.has(req.name) || req.qualifiedName !== void 0 && satisfiedNames.has(req.qualifiedName);
130048
130291
  if (!isSatisfied) {
130049
130292
  diagnostics.push({
130050
- severity: import_node11.DiagnosticSeverity.Warning,
130293
+ severity: import_node13.DiagnosticSeverity.Warning,
130051
130294
  range: req.selectionRange,
130052
130295
  message: `Requirement '${req.name}' is not satisfied by any element`,
130053
130296
  source: "sysml",
@@ -130184,7 +130427,7 @@ var SemanticValidator = class _SemanticValidator {
130184
130427
  if (!isVerified) {
130185
130428
  const message = isSatisfied ? `Requirement '${req.name}' is satisfied but has no verification case \u2014 consider adding: verify ${req.name} by <VerificationCase>;` : `Requirement '${req.name}' has no verification case \u2014 consider adding: verify ${req.name} by <VerificationCase>;`;
130186
130429
  diagnostics.push({
130187
- severity: import_node11.DiagnosticSeverity.Warning,
130430
+ severity: import_node13.DiagnosticSeverity.Warning,
130188
130431
  range: req.selectionRange,
130189
130432
  message,
130190
130433
  source: "sysml",
@@ -130244,7 +130487,7 @@ var SemanticValidator = class _SemanticValidator {
130244
130487
  const hasFilter = view.viewFilters && view.viewFilters.length > 0;
130245
130488
  if (!hasExpose && !hasFilter) {
130246
130489
  diagnostics.push({
130247
- severity: import_node11.DiagnosticSeverity.Information,
130490
+ severity: import_node13.DiagnosticSeverity.Information,
130248
130491
  range: view.selectionRange,
130249
130492
  message: `View '${view.name}' has no expose or filter directives \u2014 it will show all elements`,
130250
130493
  source: "sysml",
@@ -130284,7 +130527,7 @@ var SemanticValidator = class _SemanticValidator {
130284
130527
  const upperOk = baseUpper === "*" || curUpper !== "*" && curUpper <= baseUpper;
130285
130528
  if (lowerOk && upperOk) continue;
130286
130529
  diagnostics.push({
130287
- severity: import_node11.DiagnosticSeverity.Error,
130530
+ severity: import_node13.DiagnosticSeverity.Error,
130288
130531
  range: s.selectionRange,
130289
130532
  message: `Redefinition multiplicity [${s.multiplicity ?? "?"}] is incompatible with base '${base.name}' multiplicity [${base.multiplicity ?? "?"}]`,
130290
130533
  source: "sysml",
@@ -130306,14 +130549,15 @@ var SemanticValidator = class _SemanticValidator {
130306
130549
  if (!text) return [];
130307
130550
  const diagnostics = [];
130308
130551
  const lines = text.split("\n");
130309
- const re = /\bconnect\s+([A-Za-z_][\w.]*)\s+to\s+([A-Za-z_][\w.]*)/g;
130310
- let m2;
130311
- while ((m2 = re.exec(text)) !== null) {
130312
- const leftPath = m2[1].split(".");
130313
- const rightPath = m2[2].split(".");
130552
+ const paths = [...scanFeaturePaths(text)];
130553
+ for (let i = 0; i + 3 < paths.length; i++) {
130554
+ const [connect, leftEnd, to, rightEnd] = paths.slice(i, i + 4);
130555
+ 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;
130556
+ const leftPath = [...leftEnd.parts];
130557
+ const rightPath = [...rightEnd.parts];
130314
130558
  const left = leftPath[leftPath.length - 1];
130315
130559
  const right = rightPath[rightPath.length - 1];
130316
- const scope = this.connectorScope(symbolsInUri, this.indexToRange(text, m2.index, 0).start, indexes);
130560
+ const scope = this.connectorScope(symbolsInUri, this.indexToRange(text, connect.start, 0).start, indexes);
130317
130561
  const lSym = this.resolveConnectorEnd(leftPath, scope, indexes);
130318
130562
  const rSym = this.resolveConnectorEnd(rightPath, scope, indexes);
130319
130563
  if (!lSym || !rSym) continue;
@@ -130323,10 +130567,10 @@ var SemanticValidator = class _SemanticValidator {
130323
130567
  if (lType === "~" + rType || rType === "~" + lType) continue;
130324
130568
  if (lType.startsWith("~") && lType.slice(1) === rType) continue;
130325
130569
  if (rType.startsWith("~") && rType.slice(1) === lType) continue;
130326
- const matchLine = text.substring(0, m2.index).split("\n").length - 1;
130570
+ const matchLine = text.substring(0, connect.start).split("\n").length - 1;
130327
130571
  let insideInterfaceDef = false;
130328
- for (let i = matchLine; i >= 0 && i >= matchLine - 30; i--) {
130329
- const line = (lines[i] || "").trim();
130572
+ for (let i2 = matchLine; i2 >= 0 && i2 >= matchLine - 30; i2--) {
130573
+ const line = (lines[i2] || "").trim();
130330
130574
  if (/\binterface\s+def\b/.test(line)) {
130331
130575
  insideInterfaceDef = true;
130332
130576
  break;
@@ -130334,7 +130578,7 @@ var SemanticValidator = class _SemanticValidator {
130334
130578
  if (/^\s*package\b/.test(line)) break;
130335
130579
  }
130336
130580
  if (insideInterfaceDef) continue;
130337
- const precedingText = text.substring(Math.max(0, m2.index - 300), m2.index);
130581
+ const precedingText = text.substring(Math.max(0, connect.start - 300), connect.start);
130338
130582
  if (/\binterface\s+\w[\w']*(:\w[\w']*)?\s*$/m.test(precedingText)) continue;
130339
130583
  const lDefSyms = indexes.byName.get(lType) ?? [];
130340
130584
  const rDefSyms = indexes.byName.get(rType) ?? [];
@@ -130353,14 +130597,14 @@ var SemanticValidator = class _SemanticValidator {
130353
130597
  const hasSharedFeature = rChildren.some((c) => lChildNames.has(c.name));
130354
130598
  if (hasSharedFeature) continue;
130355
130599
  }
130356
- const range = this.indexToRange(text, m2.index, m2[0].length);
130600
+ const range = this.indexToRange(text, connect.start, rightEnd.end - connect.start);
130357
130601
  diagnostics.push({
130358
- severity: import_node11.DiagnosticSeverity.Warning,
130602
+ severity: import_node13.DiagnosticSeverity.Warning,
130359
130603
  range,
130360
130604
  message: `Port compatibility issue: '${left}' (${lType}) is connected to '${right}' (${rType})`,
130361
130605
  source: "sysml",
130362
130606
  code: "incompatible-port-types",
130363
- data: { uri }
130607
+ data: { uri, left, right, leftType: lType }
130364
130608
  });
130365
130609
  }
130366
130610
  return diagnostics;
@@ -130450,7 +130694,7 @@ var SemanticValidator = class _SemanticValidator {
130450
130694
  const startInBody = trimStart >= 0 ? trimStart : 0;
130451
130695
  const trimmedLen = Math.max(1, b.body.trim().length);
130452
130696
  diagnostics.push({
130453
- severity: import_node11.DiagnosticSeverity.Warning,
130697
+ severity: import_node13.DiagnosticSeverity.Warning,
130454
130698
  range: this.indexToRange(text, b.bodyOffset + startInBody, trimmedLen),
130455
130699
  message: "Invalid constraint body: expected expression, found documentation text",
130456
130700
  source: "sysml",
@@ -130463,15 +130707,11 @@ var SemanticValidator = class _SemanticValidator {
130463
130707
  if (!parent) continue;
130464
130708
  const parentMembers = this.getConstraintScopeMembers(parent, indexes);
130465
130709
  if (parentMembers.length === 0) continue;
130466
- const ignoredRanges = this.getIgnoredBodyRanges(b.body);
130467
- const idRe = /\b([A-Za-z_][\w]*(?:\.[A-Za-z_][\w]*)*)\b/g;
130468
- let im;
130469
- while ((im = idRe.exec(b.body)) !== null) {
130470
- if (this.isIndexInRanges(im.index, ignoredRanges)) continue;
130471
- const expr = im[1];
130710
+ for (const reference of scanFeaturePaths(b.body)) {
130711
+ const expr = reference.name;
130472
130712
  if (this.isConstraintKeyword(expr)) continue;
130473
130713
  if (/^\d/.test(expr)) continue;
130474
- const path3 = expr.split(".");
130714
+ const path3 = [...reference.parts];
130475
130715
  const ok = this.resolvePathFromParent(path3, parentMembers, indexes);
130476
130716
  if (ok) continue;
130477
130717
  if (path3.length === 1) {
@@ -130480,14 +130720,14 @@ var SemanticValidator = class _SemanticValidator {
130480
130720
  continue;
130481
130721
  }
130482
130722
  }
130483
- const absoluteStart = b.bodyOffset + im.index;
130723
+ const absoluteStart = b.bodyOffset + reference.start;
130484
130724
  diagnostics.push({
130485
- severity: import_node11.DiagnosticSeverity.Warning,
130486
- range: this.indexToRange(text, absoluteStart, expr.length),
130725
+ severity: import_node13.DiagnosticSeverity.Warning,
130726
+ range: this.indexToRange(text, absoluteStart, reference.end - reference.start),
130487
130727
  message: `Unresolved constraint reference '${expr}' in scope '${displayName(parent)}'`,
130488
130728
  source: "sysml",
130489
130729
  code: "unresolved-constraint-reference",
130490
- data: { uri }
130730
+ data: { uri, scopeName: parent.name }
130491
130731
  });
130492
130732
  }
130493
130733
  }
@@ -130681,25 +130921,6 @@ var SemanticValidator = class _SemanticValidator {
130681
130921
  isConstraintKeyword(value) {
130682
130922
  return CONSTRAINT_KEYWORDS.has(value);
130683
130923
  }
130684
- getIgnoredBodyRanges(body) {
130685
- const ranges = [];
130686
- const blockRe = /\/\*[\s\S]*?\*\//g;
130687
- let m2;
130688
- while ((m2 = blockRe.exec(body)) !== null) {
130689
- ranges.push({ start: m2.index, end: m2.index + m2[0].length });
130690
- }
130691
- const lineRe = /\/\/[^\n\r]*/g;
130692
- while ((m2 = lineRe.exec(body)) !== null) {
130693
- ranges.push({ start: m2.index, end: m2.index + m2[0].length });
130694
- }
130695
- return ranges;
130696
- }
130697
- isIndexInRanges(index2, ranges) {
130698
- for (const r of ranges) {
130699
- if (index2 >= r.start && index2 < r.end) return true;
130700
- }
130701
- return false;
130702
- }
130703
130924
  hasDocumentationOnlyConstraintBody(body) {
130704
130925
  const trimmed = body.trim();
130705
130926
  if (!trimmed) return false;
@@ -130797,7 +131018,7 @@ var SemanticValidator = class _SemanticValidator {
130797
131018
  if (defs.length > 1) {
130798
131019
  for (const def of defs) {
130799
131020
  diagnostics.push({
130800
- severity: import_node11.DiagnosticSeverity.Warning,
131021
+ severity: import_node13.DiagnosticSeverity.Warning,
130801
131022
  range: def.selectionRange,
130802
131023
  message: `Duplicate definition: '${name}' is defined ${defs.length} times in the same scope`,
130803
131024
  source: "sysml",
@@ -130839,7 +131060,7 @@ var SemanticValidator = class _SemanticValidator {
130839
131060
  if (!conflicting) continue;
130840
131061
  const others = otherDeclarations(conflicting, symbol);
130841
131062
  diagnostics.push({
130842
- severity: import_node11.DiagnosticSeverity.Error,
131063
+ severity: import_node13.DiagnosticSeverity.Error,
130843
131064
  range: symbol.selectionRange,
130844
131065
  message: `Ambiguous name '${symbol.name}': also declared as ${describeConflictingDeclarations(others, symbol.uri)}.`,
130845
131066
  source: "sysml",
@@ -130851,6 +131072,115 @@ var SemanticValidator = class _SemanticValidator {
130851
131072
  }
130852
131073
  };
130853
131074
 
131075
+ // server/src/providers/textValidationProvider.ts
131076
+ var import_node14 = __toESM(require_node3());
131077
+ var DEFAULT_TEXT_VALIDATION_SETTINGS = {
131078
+ enabled: false,
131079
+ maxDocuments: 5,
131080
+ maxLines: 200,
131081
+ maxCharacters: 8192,
131082
+ maxTotalCharacters: 16384
131083
+ };
131084
+ function readTextValidationSettings(section) {
131085
+ const raw = typeof section === "object" && section !== null ? section : {};
131086
+ const limit = (value, fallback) => Number.isSafeInteger(value) && value > 0 ? value : fallback;
131087
+ return {
131088
+ enabled: raw.enabled === true,
131089
+ maxDocuments: limit(raw.maxDocuments, DEFAULT_TEXT_VALIDATION_SETTINGS.maxDocuments),
131090
+ maxLines: limit(raw.maxLines, DEFAULT_TEXT_VALIDATION_SETTINGS.maxLines),
131091
+ maxCharacters: limit(raw.maxCharacters, DEFAULT_TEXT_VALIDATION_SETTINGS.maxCharacters),
131092
+ maxTotalCharacters: limit(raw.maxTotalCharacters, DEFAULT_TEXT_VALIDATION_SETTINGS.maxTotalCharacters)
131093
+ };
131094
+ }
131095
+ var TextValidationProvider = class {
131096
+ /**
131097
+ * `isReported` filters diagnostics as the server does before
131098
+ * publishing them (`sysml.validation.disabledCodes`), so a text gets
131099
+ * exactly what it would get as an open document.
131100
+ */
131101
+ constructor(documentManager2, semanticValidator2, isReported2 = () => true) {
131102
+ this.documentManager = documentManager2;
131103
+ this.semanticValidator = semanticValidator2;
131104
+ this.isReported = isReported2;
131105
+ }
131106
+ documentManager;
131107
+ semanticValidator;
131108
+ isReported;
131109
+ settings = { ...DEFAULT_TEXT_VALIDATION_SETTINGS };
131110
+ /** Applies the client's settings to the requests that follow. */
131111
+ configure(settings) {
131112
+ this.settings = { ...settings };
131113
+ }
131114
+ /**
131115
+ * The diagnostics each text would get as an open document, with all
131116
+ * texts in place at the same time. Answers `MethodNotFound` while
131117
+ * disabled, and `InvalidParams` for malformed parameters or parameters
131118
+ * over a limit.
131119
+ */
131120
+ validate(params) {
131121
+ if (!this.settings.enabled) {
131122
+ throw new import_node14.ResponseError(
131123
+ import_node14.ErrorCodes.MethodNotFound,
131124
+ "sysml/validateText is experimental and disabled: set sysml.experimental.validateText.enabled to true."
131125
+ );
131126
+ }
131127
+ const documents2 = this.checkDocuments(params?.documents);
131128
+ const known = documents2.map((document) => ({ uri: this.knownSpelling(document.uri), text: document.text }));
131129
+ const diagnostics = this.documentManager.withTexts(known, () => known.map(({ uri }) => this.diagnose(uri)));
131130
+ return { documents: documents2.map((document, index2) => ({ uri: document.uri, diagnostics: diagnostics[index2] })) };
131131
+ }
131132
+ /** `documents` checked: a non-empty array of `{ uri, text }` within the limits, each naming a different document. */
131133
+ checkDocuments(documents2) {
131134
+ if (!Array.isArray(documents2) || documents2.length === 0) invalid('"documents" must be a non-empty array of { uri, text }.');
131135
+ const { maxDocuments, maxLines, maxCharacters, maxTotalCharacters } = this.settings;
131136
+ if (documents2.length > maxDocuments) {
131137
+ invalid(`${documents2.length} documents, more than the ${maxDocuments} allowed (sysml.experimental.validateText.maxDocuments).`);
131138
+ }
131139
+ const checked = documents2;
131140
+ let totalCharacters = 0;
131141
+ checked.forEach((document, index2) => {
131142
+ if (typeof document?.text !== "string") invalid(`documents[${index2}] needs "text", the SysML text to validate.`);
131143
+ if (document.text.length > maxCharacters) {
131144
+ invalid(`documents[${index2}] has ${document.text.length} characters, more than the ${maxCharacters} allowed (sysml.experimental.validateText.maxCharacters).`);
131145
+ }
131146
+ totalCharacters += document.text.length;
131147
+ if (totalCharacters > maxTotalCharacters) {
131148
+ invalid(`${totalCharacters} total characters, more than the ${maxTotalCharacters} allowed (sysml.experimental.validateText.maxTotalCharacters).`);
131149
+ }
131150
+ const lines = lineCount(document.text);
131151
+ if (lines > maxLines) {
131152
+ invalid(`documents[${index2}] has ${lines} lines, more than the ${maxLines} allowed (sysml.experimental.validateText.maxLines).`);
131153
+ }
131154
+ if (!isUri(document.uri)) invalid(`documents[${index2}] needs "uri", the document the text is the content of.`);
131155
+ const earlier = checked.findIndex((other) => isSameDocumentUri(other.uri, document.uri));
131156
+ if (earlier !== index2) invalid(`documents[${earlier}] and documents[${index2}] name the same document.`);
131157
+ });
131158
+ return checked;
131159
+ }
131160
+ /** The syntax, keyword and semantic diagnostics of the document at `uri`, as published for an open document. */
131161
+ diagnose(uri) {
131162
+ const diagnostics = new DiagnosticsProvider(this.documentManager).getDiagnostics(uri);
131163
+ const parseResult = this.documentManager.get(uri);
131164
+ if (parseResult) diagnostics.push(...validateKeywords(parseResult));
131165
+ diagnostics.push(...this.semanticValidator.validate(uri));
131166
+ return diagnostics.filter(this.isReported);
131167
+ }
131168
+ /** The spelling under which the server knows the document `uri` names, else `uri` itself (see `isSameDocumentUri`). */
131169
+ knownSpelling(uri) {
131170
+ return this.documentManager.getUris().find((known) => isSameDocumentUri(known, uri)) ?? uri;
131171
+ }
131172
+ };
131173
+ function lineCount(text) {
131174
+ const breaks = text.match(/\r\n|\r|\n/g)?.length ?? 0;
131175
+ return text === "" || /[\r\n]$/.test(text) ? breaks : breaks + 1;
131176
+ }
131177
+ function isUri(value) {
131178
+ return typeof value === "string" && value.trim() !== "";
131179
+ }
131180
+ function invalid(message) {
131181
+ throw new import_node14.ResponseError(import_node14.ErrorCodes.InvalidParams, `sysml/validateText: ${message}`);
131182
+ }
131183
+
130854
131184
  // server/src/utils/fileDiscovery.ts
130855
131185
  var fsp = __toESM(require("node:fs/promises"));
130856
131186
  var path = __toESM(require("node:path"));
@@ -130925,7 +131255,7 @@ function toFsPath(uri) {
130925
131255
  return void 0;
130926
131256
  }
130927
131257
  var connection = createServerConnection();
130928
- var documents = new import_node12.TextDocuments(TextDocument);
131258
+ var documents = new import_node15.TextDocuments(TextDocument);
130929
131259
  var serverStartTime = Date.now();
130930
131260
  var documentManager = new DocumentManager();
130931
131261
  var modelProvider = new SysMLModelProvider(documentManager);
@@ -130942,6 +131272,7 @@ var renameProvider = new RenameProvider(documentManager);
130942
131272
  var codeActionProvider = new CodeActionProvider(documentManager);
130943
131273
  var formattingProvider = new FormattingProvider(documents);
130944
131274
  var semanticValidator = new SemanticValidator(documentManager);
131275
+ var textValidationProvider = new TextValidationProvider(documentManager, semanticValidator, isReported);
130945
131276
  hoverProvider.setSemanticValidator(semanticValidator);
130946
131277
  var hasConfigurationCapability = false;
130947
131278
  var hasWorkspaceFolderCapability = false;
@@ -130953,11 +131284,11 @@ function rootsOf(folderUris) {
130953
131284
  var isWorkspaceFile = false;
130954
131285
  var preloadOnOpen = "workspaceOnly";
130955
131286
  var disabledDiagnosticCodes = /* @__PURE__ */ new Set();
131287
+ function isReported(diagnostic) {
131288
+ return diagnostic.code === void 0 || !disabledDiagnosticCodes.has(String(diagnostic.code));
131289
+ }
130956
131290
  function publishDiagnostics(uri, diagnostics) {
130957
- connection.sendDiagnostics({
130958
- uri,
130959
- diagnostics: diagnostics.filter((diagnostic) => diagnostic.code === void 0 || !disabledDiagnosticCodes.has(String(diagnostic.code)))
130960
- });
131291
+ connection.sendDiagnostics({ uri, diagnostics: diagnostics.filter(isReported) });
130961
131292
  }
130962
131293
  var skipDirs = new Set(DEFAULT_SKIP_DIRS);
130963
131294
  var serverReady = false;
@@ -131090,7 +131421,7 @@ connection.onInitialize((params) => {
131090
131421
  };
131091
131422
  const result = {
131092
131423
  capabilities: {
131093
- textDocumentSync: import_node12.TextDocumentSyncKind.Incremental,
131424
+ textDocumentSync: import_node15.TextDocumentSyncKind.Incremental,
131094
131425
  // Completion
131095
131426
  completionProvider: {
131096
131427
  resolveProvider: true,
@@ -131118,7 +131449,7 @@ connection.onInitialize((params) => {
131118
131449
  // Code actions (quick fixes)
131119
131450
  codeActionProvider: {
131120
131451
  codeActionKinds: [
131121
- import_node12.CodeActionKind.QuickFix
131452
+ import_node15.CodeActionKind.QuickFix
131122
131453
  ]
131123
131454
  },
131124
131455
  // Document formatting
@@ -131139,7 +131470,7 @@ connection.onInitialize((params) => {
131139
131470
  connection.onInitialized(async () => {
131140
131471
  if (hasConfigurationCapability) {
131141
131472
  connection.client.register(
131142
- import_node12.DidChangeConfigurationNotification.type,
131473
+ import_node15.DidChangeConfigurationNotification.type,
131143
131474
  void 0
131144
131475
  );
131145
131476
  }
@@ -131200,6 +131531,8 @@ async function pullSettings() {
131200
131531
  const validation = await connection.workspace.getConfiguration("sysml.validation");
131201
131532
  const codes = validation?.disabledCodes;
131202
131533
  disabledDiagnosticCodes = new Set(Array.isArray(codes) ? codes.filter((code) => typeof code === "string") : []);
131534
+ const experimental = await connection.workspace.getConfiguration("sysml.experimental");
131535
+ textValidationProvider.configure(readTextValidationSettings(experimental?.validateText));
131203
131536
  }
131204
131537
  function applySettings(config) {
131205
131538
  if (!config) return;
@@ -131553,6 +131886,10 @@ connection.onRequest("sysml/elementLookup", async (params) => {
131553
131886
  await initialization;
131554
131887
  return elementLookupProvider.elementLookup(params);
131555
131888
  });
131889
+ connection.onRequest("sysml/validateText", async (params) => {
131890
+ await initialization;
131891
+ return textValidationProvider.validate(params);
131892
+ });
131556
131893
  connection.onRequest("sysml/serverStats", () => {
131557
131894
  const mem = typeof process !== "undefined" && typeof process.memoryUsage === "function" ? process.memoryUsage() : { heapUsed: 0, heapTotal: 0, rss: 0, external: 0 };
131558
131895
  const toMB = (bytes) => Math.round(bytes / 1024 / 1024);