sysml-v2-lsp 0.37.0 → 0.39.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.
@@ -123,30 +123,30 @@
123
123
  Object.defineProperty(exports, "__esModule", { value: true });
124
124
  exports.Message = exports.NotificationType9 = exports.NotificationType8 = exports.NotificationType7 = exports.NotificationType6 = exports.NotificationType5 = exports.NotificationType4 = exports.NotificationType3 = exports.NotificationType2 = exports.NotificationType1 = exports.NotificationType0 = exports.NotificationType = exports.RequestType9 = exports.RequestType8 = exports.RequestType7 = exports.RequestType6 = exports.RequestType5 = exports.RequestType4 = exports.RequestType3 = exports.RequestType2 = exports.RequestType1 = exports.RequestType = exports.RequestType0 = exports.AbstractMessageSignature = exports.ParameterStructures = exports.ResponseError = exports.ErrorCodes = void 0;
125
125
  var is = __importStar(require_is());
126
- var ErrorCodes2;
127
- (function(ErrorCodes3) {
128
- ErrorCodes3.ParseError = -32700;
129
- ErrorCodes3.InvalidRequest = -32600;
130
- ErrorCodes3.MethodNotFound = -32601;
131
- ErrorCodes3.InvalidParams = -32602;
132
- ErrorCodes3.InternalError = -32603;
133
- ErrorCodes3.jsonrpcReservedErrorRangeStart = -32099;
134
- ErrorCodes3.serverErrorStart = -32099;
135
- ErrorCodes3.MessageWriteError = -32099;
136
- ErrorCodes3.MessageReadError = -32098;
137
- ErrorCodes3.PendingResponseRejected = -32097;
138
- ErrorCodes3.ConnectionInactive = -32096;
139
- ErrorCodes3.ServerNotInitialized = -32002;
140
- ErrorCodes3.UnknownErrorCode = -32001;
141
- ErrorCodes3.jsonrpcReservedErrorRangeEnd = -32e3;
142
- ErrorCodes3.serverErrorEnd = -32e3;
143
- })(ErrorCodes2 || (exports.ErrorCodes = ErrorCodes2 = {}));
144
- var ResponseError2 = class _ResponseError extends Error {
126
+ var ErrorCodes3;
127
+ (function(ErrorCodes4) {
128
+ ErrorCodes4.ParseError = -32700;
129
+ ErrorCodes4.InvalidRequest = -32600;
130
+ ErrorCodes4.MethodNotFound = -32601;
131
+ ErrorCodes4.InvalidParams = -32602;
132
+ ErrorCodes4.InternalError = -32603;
133
+ ErrorCodes4.jsonrpcReservedErrorRangeStart = -32099;
134
+ ErrorCodes4.serverErrorStart = -32099;
135
+ ErrorCodes4.MessageWriteError = -32099;
136
+ ErrorCodes4.MessageReadError = -32098;
137
+ ErrorCodes4.PendingResponseRejected = -32097;
138
+ ErrorCodes4.ConnectionInactive = -32096;
139
+ ErrorCodes4.ServerNotInitialized = -32002;
140
+ ErrorCodes4.UnknownErrorCode = -32001;
141
+ ErrorCodes4.jsonrpcReservedErrorRangeEnd = -32e3;
142
+ ErrorCodes4.serverErrorEnd = -32e3;
143
+ })(ErrorCodes3 || (exports.ErrorCodes = ErrorCodes3 = {}));
144
+ var ResponseError3 = class _ResponseError extends Error {
145
145
  code;
146
146
  data;
147
147
  constructor(code, message, data) {
148
148
  super(message);
149
- this.code = is.number(code) ? code : ErrorCodes2.UnknownErrorCode;
149
+ this.code = is.number(code) ? code : ErrorCodes3.UnknownErrorCode;
150
150
  this.data = data;
151
151
  Object.setPrototypeOf(this, _ResponseError.prototype);
152
152
  }
@@ -161,7 +161,7 @@
161
161
  return result;
162
162
  }
163
163
  };
164
- exports.ResponseError = ResponseError2;
164
+ exports.ResponseError = ResponseError3;
165
165
  var ParameterStructures = class _ParameterStructures {
166
166
  kind;
167
167
  /**
@@ -3526,7 +3526,7 @@ ${JSON.stringify(message, null, 4)}`);
3526
3526
  }
3527
3527
  CodeDescription3.is = is;
3528
3528
  })(CodeDescription || (CodeDescription = {}));
3529
- (function(Diagnostic8) {
3529
+ (function(Diagnostic9) {
3530
3530
  function create(range, message, severity, code, source, relatedInformation) {
3531
3531
  const result = { range, message };
3532
3532
  if (Is.defined(severity)) {
@@ -3543,17 +3543,17 @@ ${JSON.stringify(message, null, 4)}`);
3543
3543
  }
3544
3544
  return result;
3545
3545
  }
3546
- Diagnostic8.create = create;
3546
+ Diagnostic9.create = create;
3547
3547
  function is(value) {
3548
3548
  var _a;
3549
3549
  const candidate = value;
3550
3550
  return Is.defined(candidate) && Range.is(candidate.range) && (Is.string(candidate.message) || MarkupContent.is(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));
3551
3551
  }
3552
- Diagnostic8.is = is;
3552
+ Diagnostic9.is = is;
3553
3553
  function is3_17(value) {
3554
3554
  return Is.string(value.message);
3555
3555
  }
3556
- Diagnostic8.is3_17 = is3_17;
3556
+ Diagnostic9.is3_17 = is3_17;
3557
3557
  function getMessageString(diagnostic) {
3558
3558
  if (Is.string(diagnostic.message)) {
3559
3559
  return diagnostic.message;
@@ -3563,7 +3563,7 @@ ${JSON.stringify(message, null, 4)}`);
3563
3563
  throw new Error(`Unknown message type ${typeof diagnostic.message}`);
3564
3564
  }
3565
3565
  }
3566
- Diagnostic8.getMessageString = getMessageString;
3566
+ Diagnostic9.getMessageString = getMessageString;
3567
3567
  })(Diagnostic || (Diagnostic = {}));
3568
3568
  (function(Command3) {
3569
3569
  function create(title, command, ...args) {
@@ -9290,28 +9290,28 @@ ${JSON.stringify(message, null, 4)}`);
9290
9290
  Object.defineProperty(exports, "__esModule", { value: true });
9291
9291
  exports.Message = exports.NotificationType9 = exports.NotificationType8 = exports.NotificationType7 = exports.NotificationType6 = exports.NotificationType5 = exports.NotificationType4 = exports.NotificationType3 = exports.NotificationType2 = exports.NotificationType1 = exports.NotificationType0 = exports.NotificationType = exports.RequestType9 = exports.RequestType8 = exports.RequestType7 = exports.RequestType6 = exports.RequestType5 = exports.RequestType4 = exports.RequestType3 = exports.RequestType2 = exports.RequestType1 = exports.RequestType = exports.RequestType0 = exports.AbstractMessageSignature = exports.ParameterStructures = exports.ResponseError = exports.ErrorCodes = void 0;
9292
9292
  var is = require_is4();
9293
- var ErrorCodes2;
9294
- (function(ErrorCodes3) {
9295
- ErrorCodes3.ParseError = -32700;
9296
- ErrorCodes3.InvalidRequest = -32600;
9297
- ErrorCodes3.MethodNotFound = -32601;
9298
- ErrorCodes3.InvalidParams = -32602;
9299
- ErrorCodes3.InternalError = -32603;
9300
- ErrorCodes3.jsonrpcReservedErrorRangeStart = -32099;
9301
- ErrorCodes3.serverErrorStart = -32099;
9302
- ErrorCodes3.MessageWriteError = -32099;
9303
- ErrorCodes3.MessageReadError = -32098;
9304
- ErrorCodes3.PendingResponseRejected = -32097;
9305
- ErrorCodes3.ConnectionInactive = -32096;
9306
- ErrorCodes3.ServerNotInitialized = -32002;
9307
- ErrorCodes3.UnknownErrorCode = -32001;
9308
- ErrorCodes3.jsonrpcReservedErrorRangeEnd = -32e3;
9309
- ErrorCodes3.serverErrorEnd = -32e3;
9310
- })(ErrorCodes2 || (exports.ErrorCodes = ErrorCodes2 = {}));
9311
- var ResponseError2 = class _ResponseError extends Error {
9293
+ var ErrorCodes3;
9294
+ (function(ErrorCodes4) {
9295
+ ErrorCodes4.ParseError = -32700;
9296
+ ErrorCodes4.InvalidRequest = -32600;
9297
+ ErrorCodes4.MethodNotFound = -32601;
9298
+ ErrorCodes4.InvalidParams = -32602;
9299
+ ErrorCodes4.InternalError = -32603;
9300
+ ErrorCodes4.jsonrpcReservedErrorRangeStart = -32099;
9301
+ ErrorCodes4.serverErrorStart = -32099;
9302
+ ErrorCodes4.MessageWriteError = -32099;
9303
+ ErrorCodes4.MessageReadError = -32098;
9304
+ ErrorCodes4.PendingResponseRejected = -32097;
9305
+ ErrorCodes4.ConnectionInactive = -32096;
9306
+ ErrorCodes4.ServerNotInitialized = -32002;
9307
+ ErrorCodes4.UnknownErrorCode = -32001;
9308
+ ErrorCodes4.jsonrpcReservedErrorRangeEnd = -32e3;
9309
+ ErrorCodes4.serverErrorEnd = -32e3;
9310
+ })(ErrorCodes3 || (exports.ErrorCodes = ErrorCodes3 = {}));
9311
+ var ResponseError3 = class _ResponseError extends Error {
9312
9312
  constructor(code, message, data) {
9313
9313
  super(message);
9314
- this.code = is.number(code) ? code : ErrorCodes2.UnknownErrorCode;
9314
+ this.code = is.number(code) ? code : ErrorCodes3.UnknownErrorCode;
9315
9315
  this.data = data;
9316
9316
  Object.setPrototypeOf(this, _ResponseError.prototype);
9317
9317
  }
@@ -9326,7 +9326,7 @@ ${JSON.stringify(message, null, 4)}`);
9326
9326
  return result;
9327
9327
  }
9328
9328
  };
9329
- exports.ResponseError = ResponseError2;
9329
+ exports.ResponseError = ResponseError3;
9330
9330
  var ParameterStructures = class _ParameterStructures {
9331
9331
  constructor(kind) {
9332
9332
  this.kind = kind;
@@ -12599,7 +12599,7 @@ ${JSON.stringify(message, null, 4)}`);
12599
12599
  }
12600
12600
  CodeDescription3.is = is;
12601
12601
  })(CodeDescription2 || (CodeDescription2 = {}));
12602
- (function(Diagnostic8) {
12602
+ (function(Diagnostic9) {
12603
12603
  function create(range, message, severity, code, source, relatedInformation) {
12604
12604
  let result = { range, message };
12605
12605
  if (Is2.defined(severity)) {
@@ -12616,13 +12616,13 @@ ${JSON.stringify(message, null, 4)}`);
12616
12616
  }
12617
12617
  return result;
12618
12618
  }
12619
- Diagnostic8.create = create;
12619
+ Diagnostic9.create = create;
12620
12620
  function is(value) {
12621
12621
  var _a;
12622
12622
  let candidate = value;
12623
12623
  return Is2.defined(candidate) && Range2.is(candidate.range) && Is2.string(candidate.message) && (Is2.number(candidate.severity) || Is2.undefined(candidate.severity)) && (Is2.integer(candidate.code) || Is2.string(candidate.code) || Is2.undefined(candidate.code)) && (Is2.undefined(candidate.codeDescription) || Is2.string((_a = candidate.codeDescription) === null || _a === void 0 ? void 0 : _a.href)) && (Is2.string(candidate.source) || Is2.undefined(candidate.source)) && (Is2.undefined(candidate.relatedInformation) || Is2.typedArray(candidate.relatedInformation, DiagnosticRelatedInformation2.is));
12624
12624
  }
12625
- Diagnostic8.is = is;
12625
+ Diagnostic9.is = is;
12626
12626
  })(Diagnostic2 || (Diagnostic2 = {}));
12627
12627
  (function(Command3) {
12628
12628
  function create(title, command, ...args) {
@@ -17437,7 +17437,7 @@ ${JSON.stringify(message, null, 4)}`);
17437
17437
  });
17438
17438
 
17439
17439
  // server/src/server.ts
17440
- var import_node13 = __toESM(require_main3());
17440
+ var import_node14 = __toESM(require_main3());
17441
17441
 
17442
17442
  // server/src/platform/shims/fs.ts
17443
17443
  function readFileSync(_path, _enc) {
@@ -133028,6 +133028,13 @@ ${JSON.stringify(message, null, 4)}`);
133028
133028
  * indexed yet" apart from "genuinely doesn't exist".
133029
133029
  */
133030
133030
  workspaceScanComplete = true;
133031
+ /**
133032
+ * Last version given to a stand-in text by `withTexts`. Caches keyed by
133033
+ * version assume one text per uri and version, so each stand-in gets a
133034
+ * version outside the LSP integer range (LSP 3.17, base types).
133035
+ * These internal positive versions are never sent to the client.
133036
+ */
133037
+ temporaryVersion = 2 ** 31 - 1;
133031
133038
  /**
133032
133039
  * Parse a document and cache the result.
133033
133040
  * Returns the cached result if the content hasn't changed.
@@ -133231,6 +133238,35 @@ ${JSON.stringify(message, null, 4)}`);
133231
133238
  this.wsSymbolTable.removeUri(uri);
133232
133239
  this.wsBuiltVersions.delete(uri);
133233
133240
  }
133241
+ /**
133242
+ * Runs `fn` with each text standing in for the document at its uri (or
133243
+ * added as a new document), all at once, then restores the previous
133244
+ * state. `fn` must be synchronous: no other request can run in between,
133245
+ * so no other request ever sees the temporary texts. Every text is
133246
+ * parsed before anything changes. The stand-ins get versions no real
133247
+ * document has, so caches keyed by version never confuse them with the
133248
+ * real documents.
133249
+ */
133250
+ withTexts(documents2, fn) {
133251
+ if (!Number.isSafeInteger(this.temporaryVersion + documents2.length)) {
133252
+ throw new RangeError("Temporary document version space exhausted.");
133253
+ }
133254
+ const parsed = documents2.map(({ uri, text }) => ({ uri, text, result: parseDocument(text) }));
133255
+ const previous = new Map(parsed.map(({ uri }) => [uri, this.cache.get(uri)]));
133256
+ for (const { uri, text, result } of parsed) {
133257
+ this.cache.set(uri, { version: ++this.temporaryVersion, text, result, needsParse: false });
133258
+ }
133259
+ try {
133260
+ return fn();
133261
+ } finally {
133262
+ for (const [uri, entry] of previous) {
133263
+ if (entry) this.cache.set(uri, entry);
133264
+ else this.cache.delete(uri);
133265
+ this.wsSymbolTable.removeUri(uri);
133266
+ this.wsBuiltVersions.delete(uri);
133267
+ }
133268
+ }
133269
+ }
133234
133270
  /**
133235
133271
  * Get all cached URIs.
133236
133272
  */
@@ -136411,12 +136447,19 @@ ${JSON.stringify(message, null, 4)}`);
136411
136447
  function findConflictedQualifiedNames(allSymbols) {
136412
136448
  return groupConflicts(allSymbols.filter((s) => s.qualifiedName !== void 0), (s) => s.qualifiedName);
136413
136449
  }
136450
+ function memberNamesOf(symbol) {
136451
+ return symbol.shortName && symbol.shortName !== symbol.name ? [symbol.name, symbol.shortName] : [symbol.name];
136452
+ }
136414
136453
  function findConflictingDeclarations(allSymbols) {
136415
136454
  const conflicting = /* @__PURE__ */ new Map();
136416
136455
  const add = (groups) => {
136417
- for (const group of groups.values()) for (const s of group) conflicting.set(s, group);
136456
+ for (const group of groups) {
136457
+ for (const s of group) {
136458
+ conflicting.set(s, [.../* @__PURE__ */ new Set([...conflicting.get(s) ?? [], ...group])]);
136459
+ }
136460
+ }
136418
136461
  };
136419
- add(findConflictedQualifiedNames(allSymbols));
136462
+ add(findConflictedQualifiedNames(allSymbols).values());
136420
136463
  const membersOfAnonymous = allSymbols.filter((s) => s.qualifiedName === void 0 && !isAnonymous(s) && s.parentId !== void 0);
136421
136464
  const byOwner = /* @__PURE__ */ new Map();
136422
136465
  for (const s of membersOfAnonymous) {
@@ -136424,13 +136467,33 @@ ${JSON.stringify(message, null, 4)}`);
136424
136467
  list.push(s);
136425
136468
  byOwner.set(s.parentId, list);
136426
136469
  }
136427
- for (const members of byOwner.values()) add(groupConflicts(members, (s) => s.name));
136470
+ for (const members of byOwner.values()) add(groupConflicts(members, (s) => s.name).values());
136471
+ add([...findConflictingShortNames(allSymbols).values()].map((group) => group.symbols));
136428
136472
  return conflicting;
136429
136473
  }
136474
+ function findConflictingShortNames(allSymbols) {
136475
+ const byId = new Map(allSymbols.map((s) => [s.symbolId, s]));
136476
+ const entries = [];
136477
+ const keysWithShortName = /* @__PURE__ */ new Set();
136478
+ for (const s of allSymbols) {
136479
+ if (isAnonymous(s)) continue;
136480
+ const owner = s.parentId ? byId.get(s.parentId) : void 0;
136481
+ const namespace = owner === void 0 ? "q:" : owner.qualifiedName !== void 0 ? `q:${owner.qualifiedName}` : `id:${owner.symbolId}`;
136482
+ for (const name of memberNamesOf(s)) {
136483
+ const key = `${namespace}\0${name}`;
136484
+ entries.push({ symbol: s, key });
136485
+ if (name === s.shortName) keysWithShortName.add(key);
136486
+ }
136487
+ }
136488
+ const groups = groupKeyedConflicts(entries.filter((e) => keysWithShortName.has(e.key)));
136489
+ return new Map([...groups].map(([key, symbols]) => [key, { name: key.slice(key.indexOf("\0") + 1), symbols }]));
136490
+ }
136430
136491
  function groupConflicts(symbols, keyOf) {
136492
+ return groupKeyedConflicts(symbols.map((symbol) => ({ symbol, key: keyOf(symbol) })));
136493
+ }
136494
+ function groupKeyedConflicts(entries) {
136431
136495
  const byKeyAndKind = /* @__PURE__ */ new Map();
136432
- for (const s of symbols) {
136433
- const key = keyOf(s);
136496
+ for (const { symbol: s, key } of entries) {
136434
136497
  let byKind = byKeyAndKind.get(key);
136435
136498
  if (!byKind) {
136436
136499
  byKind = /* @__PURE__ */ new Map();
@@ -136502,7 +136565,13 @@ ${JSON.stringify(message, null, 4)}`);
136502
136565
  for (const s of allSymbols) {
136503
136566
  byId.set(s.symbolId, s);
136504
136567
  }
136505
- const indexes = { byName, byParent, byQualifiedName, byId, definitionsByName, portsByName };
136568
+ const clashingShortNames = /* @__PURE__ */ new Map();
136569
+ for (const { name, symbols } of findConflictingShortNames(allSymbols).values()) {
136570
+ const clashing = clashingShortNames.get(name) ?? /* @__PURE__ */ new Set();
136571
+ for (const s of symbols) clashing.add(s);
136572
+ clashingShortNames.set(name, clashing);
136573
+ }
136574
+ const indexes = { byName, byParent, byQualifiedName, byId, definitionsByName, portsByName, clashingShortNames };
136506
136575
  for (const s of allSymbols) {
136507
136576
  if (isAnonymous(s)) continue;
136508
136577
  const nameList = byName.get(s.name) ?? [];
@@ -136591,6 +136660,16 @@ ${JSON.stringify(message, null, 4)}`);
136591
136660
  resolveNameIn(namespace, name, indexes) {
136592
136661
  return this.resolveQualifiedNameFrom(namespace ? namespaceKeyOf(namespace) : "", name, indexes);
136593
136662
  }
136663
+ /** Resolve an editor reference without losing the reason a name is unresolved. */
136664
+ resolveReferenceIn(namespace, name, indexes) {
136665
+ return this.resolveQualifiedReferenceFrom(namespace ? namespaceKeyOf(namespace) : "", name, indexes);
136666
+ }
136667
+ /** Resolve a public qualified or feature-path member, without enclosing-scope fallback. */
136668
+ resolveMemberReference(owner, name, indexes) {
136669
+ const members = this.getResolvedMembers(namespaceKeyOf(owner), indexes).get(name);
136670
+ if (members && this.isAmbiguous(name, members, indexes)) return { ambiguous: true };
136671
+ return this.referenceTo(members?.find((member) => member.visibility === "public")?.symbol, indexes);
136672
+ }
136594
136673
  /**
136595
136674
  * Resolve a (possibly qualified) name to its symbol per §7.5.1, searching
136596
136675
  * outward from namespace `start` and its enclosing namespaces (its own resolved
@@ -136602,28 +136681,48 @@ ${JSON.stringify(message, null, 4)}`);
136602
136681
  * its own enclosing package already imported, per §7.5.1/§7.5.3).
136603
136682
  */
136604
136683
  resolveQualifiedNameFrom(start, name, indexes) {
136684
+ return this.resolveQualifiedReferenceFrom(start, name, indexes).symbol;
136685
+ }
136686
+ resolveQualifiedReferenceFrom(start, name, indexes) {
136605
136687
  const [first, ...rest] = splitQualifiedName(name);
136606
136688
  let resolved;
136607
136689
  for (const ancestor of this.namespaceAncestorsOf(start, indexes)) {
136608
136690
  const candidates = this.getResolvedMembers(ancestor, indexes).get(first);
136609
136691
  if (candidates && candidates.length > 0) {
136692
+ if (this.isAmbiguous(first, candidates, indexes)) return { ambiguous: true };
136610
136693
  resolved = candidates[0].symbol;
136611
136694
  break;
136612
136695
  }
136613
136696
  }
136614
- if (resolved === void 0) return void 0;
136697
+ if (resolved === void 0) return { ambiguous: false };
136615
136698
  const isWithinStart = (namespace) => this.namespaceAncestorsOf(start, indexes).has(namespace);
136616
136699
  for (const segment of rest) {
136617
136700
  const owner = resolved;
136618
136701
  const ownerKey = namespaceKeyOf(owner);
136619
136702
  const members = this.getResolvedMembers(ownerKey, indexes).get(segment);
136703
+ if (members && this.isAmbiguous(segment, members, indexes)) return { ambiguous: true };
136620
136704
  const visibleMember = members?.find(
136621
136705
  (m2) => m2.visibility === "public" || isWithinStart(ownerKey) || m2.visibility === "protected" && this.isProtectedVisibleFrom(start, owner, indexes)
136622
136706
  );
136623
- if (!visibleMember) return void 0;
136707
+ if (!visibleMember) return { ambiguous: false };
136624
136708
  resolved = visibleMember.symbol;
136625
136709
  }
136626
- return resolved.qualifiedName !== void 0 ? indexes.byQualifiedName.get(resolved.qualifiedName) : resolved;
136710
+ return this.referenceTo(resolved, indexes);
136711
+ }
136712
+ referenceTo(resolved, indexes) {
136713
+ if (!resolved) return { ambiguous: false };
136714
+ const symbol = resolved.qualifiedName !== void 0 ? indexes.byQualifiedName.get(resolved.qualifiedName) : resolved;
136715
+ return { symbol, ambiguous: symbol === void 0 };
136716
+ }
136717
+ /**
136718
+ * Whether `name` names more than one of `candidates` that clash on it
136719
+ * through a short name (`SymbolIndexes.clashingShortNames`), so it can't
136720
+ * be resolved to either (KerML 7.2.5.2). Like a conflicted qualifiedName,
136721
+ * it doesn't fall through to an enclosing namespace's member of that name.
136722
+ */
136723
+ isAmbiguous(name, candidates, indexes) {
136724
+ const clashing = indexes.clashingShortNames.get(name);
136725
+ return clashing !== void 0 && candidates.filter((c) => clashing.has(c.symbol)).length > 1;
136627
136726
  }
136628
136727
  /**
136629
136728
  * §7.5.3's protected-import exception: "A visibility of protected is the
@@ -139329,9 +139428,11 @@ ${childIndent}item def ${sourceName};
139329
139428
  if (target && !path.qualifiedNames.some((name) => name.segments.some((segment) => segment.name === target.name || segment.name === target.shortName))) continue;
139330
139429
  const namespace = namespaces.find((ns) => ns.body < path.start && path.end <= ns.end);
139331
139430
  let receiver;
139431
+ let receiverAmbiguous = false;
139332
139432
  for (let group = 0; group < path.qualifiedNames.length; group++) {
139333
139433
  const qualified = path.qualifiedNames[group];
139334
139434
  let resolved;
139435
+ let ambiguous = false;
139335
139436
  for (let index2 = 0; index2 < qualified.segments.length; index2++) {
139336
139437
  const segment = qualified.segments[index2];
139337
139438
  const range = import_node3.Range.create(doc.positionAt(segment.start), doc.positionAt(segment.end));
@@ -139340,17 +139441,27 @@ ${childIndent}item def ${sourceName};
139340
139441
  while (before >= 0 && /\s/.test(text[before])) before--;
139341
139442
  while (after < text.length && /\s/.test(text[after])) after++;
139342
139443
  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)));
139343
- if (declaration) resolved = declaration;
139344
- else if (index2 > 0) {
139345
- resolved = resolved ? this.resolver.getResolvedMembers(namespaceKeyOf(resolved), this.indexes).get(segment.name)?.find((entry) => entry.visibility === "public")?.symbol : void 0;
139444
+ if (declaration) {
139445
+ resolved = declaration;
139446
+ ambiguous = false;
139447
+ } else if (index2 > 0) {
139448
+ if (resolved) {
139449
+ const result = this.resolver.resolveMemberReference(resolved, segment.name, this.indexes);
139450
+ resolved = result.symbol;
139451
+ ambiguous = result.ambiguous;
139452
+ }
139346
139453
  } else if (group > 0) {
139347
- resolved = receiver ? this.resolveFeature(receiver, segment.name) : void 0;
139454
+ const result = receiver ? this.resolveFeature(receiver, segment.name) : { ambiguous: receiverAmbiguous };
139455
+ resolved = result.symbol;
139456
+ ambiguous = result.ambiguous;
139348
139457
  } else {
139349
- resolved = this.resolver.resolveNameIn(
139458
+ const result = this.resolver.resolveReferenceIn(
139350
139459
  namespace?.symbol,
139351
139460
  joinQualifiedName([segment.name]),
139352
139461
  this.indexes
139353
139462
  );
139463
+ resolved = result.symbol;
139464
+ ambiguous = result.ambiguous;
139354
139465
  }
139355
139466
  if (cursor !== void 0 && (cursor < segment.start || cursor > segment.end)) continue;
139356
139467
  if (target && segment.name !== target.name && segment.name !== target.shortName) continue;
@@ -139360,10 +139471,12 @@ ${childIndent}item def ${sourceName};
139360
139471
  name: segment.name,
139361
139472
  qualifiedName: index2 === qualified.segments.length - 1 ? qualified.name : segment.name,
139362
139473
  symbol: resolved,
139363
- isDeclaration: declaration !== void 0
139474
+ isDeclaration: declaration !== void 0,
139475
+ isAmbiguous: ambiguous
139364
139476
  });
139365
139477
  }
139366
139478
  receiver = resolved;
139479
+ receiverAmbiguous = ambiguous;
139367
139480
  }
139368
139481
  }
139369
139482
  return refs;
@@ -139375,14 +139488,14 @@ ${childIndent}item def ${sourceName};
139375
139488
  const owner = queue[index2];
139376
139489
  if (visited.has(owner)) continue;
139377
139490
  visited.add(owner);
139378
- const member = this.resolver.getResolvedMembers(namespaceKeyOf(owner), this.indexes).get(name)?.find((entry) => entry.visibility === "public")?.symbol;
139379
- if (member) return member;
139491
+ const member = this.resolver.resolveMemberReference(owner, name, this.indexes);
139492
+ if (member.symbol || member.ambiguous) return member;
139380
139493
  for (const typeName of owner.typeNames) {
139381
139494
  const type = this.resolver.resolveNameFrom(owner, typeName, this.indexes);
139382
139495
  if (type && !visited.has(type)) queue.push(type);
139383
139496
  }
139384
139497
  }
139385
- return void 0;
139498
+ return { ambiguous: false };
139386
139499
  }
139387
139500
  };
139388
139501
 
@@ -139399,6 +139512,7 @@ ${childIndent}item def ${sourceName};
139399
139512
  }
139400
139513
  const wsSymbolTable = this.documentManager.getWorkspaceSymbolTable();
139401
139514
  const reference = new NameReferences(this.documentManager).at(params.textDocument.uri, params.position);
139515
+ if (reference?.isAmbiguous) return null;
139402
139516
  if (reference?.symbol && !reference.isDeclaration) {
139403
139517
  return { uri: reference.symbol.uri, range: reference.symbol.selectionRange };
139404
139518
  }
@@ -140013,6 +140127,7 @@ ${childIndent}item def ${sourceName};
140013
140127
  }
140014
140128
  const text = this.documentManager.getText(params.textDocument.uri);
140015
140129
  const reference = new NameReferences(this.documentManager).at(params.textDocument.uri, params.position);
140130
+ if (reference?.isAmbiguous) return null;
140016
140131
  const word = reference?.qualifiedName ?? (text ? this.getWordAtPosition(text, params.position.line, params.position.character) : void 0);
140017
140132
  if (word && word.includes("::") && !reference?.symbol) {
140018
140133
  const libHover = this.buildLibraryHover(word);
@@ -142068,6 +142183,115 @@ ${info.documentation}`);
142068
142183
  }
142069
142184
  };
142070
142185
 
142186
+ // server/src/providers/textValidationProvider.ts
142187
+ var import_node13 = __toESM(require_main3());
142188
+ var DEFAULT_TEXT_VALIDATION_SETTINGS = {
142189
+ enabled: false,
142190
+ maxDocuments: 5,
142191
+ maxLines: 200,
142192
+ maxCharacters: 8192,
142193
+ maxTotalCharacters: 16384
142194
+ };
142195
+ function readTextValidationSettings(section) {
142196
+ const raw = typeof section === "object" && section !== null ? section : {};
142197
+ const limit = (value, fallback) => Number.isSafeInteger(value) && value > 0 ? value : fallback;
142198
+ return {
142199
+ enabled: raw.enabled === true,
142200
+ maxDocuments: limit(raw.maxDocuments, DEFAULT_TEXT_VALIDATION_SETTINGS.maxDocuments),
142201
+ maxLines: limit(raw.maxLines, DEFAULT_TEXT_VALIDATION_SETTINGS.maxLines),
142202
+ maxCharacters: limit(raw.maxCharacters, DEFAULT_TEXT_VALIDATION_SETTINGS.maxCharacters),
142203
+ maxTotalCharacters: limit(raw.maxTotalCharacters, DEFAULT_TEXT_VALIDATION_SETTINGS.maxTotalCharacters)
142204
+ };
142205
+ }
142206
+ var TextValidationProvider = class {
142207
+ /**
142208
+ * `isReported` filters diagnostics as the server does before
142209
+ * publishing them (`sysml.validation.disabledCodes`), so a text gets
142210
+ * exactly what it would get as an open document.
142211
+ */
142212
+ constructor(documentManager2, semanticValidator2, isReported2 = () => true) {
142213
+ this.documentManager = documentManager2;
142214
+ this.semanticValidator = semanticValidator2;
142215
+ this.isReported = isReported2;
142216
+ }
142217
+ documentManager;
142218
+ semanticValidator;
142219
+ isReported;
142220
+ settings = { ...DEFAULT_TEXT_VALIDATION_SETTINGS };
142221
+ /** Applies the client's settings to the requests that follow. */
142222
+ configure(settings) {
142223
+ this.settings = { ...settings };
142224
+ }
142225
+ /**
142226
+ * The diagnostics each text would get as an open document, with all
142227
+ * texts in place at the same time. Answers `MethodNotFound` while
142228
+ * disabled, and `InvalidParams` for malformed parameters or parameters
142229
+ * over a limit.
142230
+ */
142231
+ validate(params) {
142232
+ if (!this.settings.enabled) {
142233
+ throw new import_node13.ResponseError(
142234
+ import_node13.ErrorCodes.MethodNotFound,
142235
+ "sysml/validateText is experimental and disabled: set sysml.experimental.validateText.enabled to true."
142236
+ );
142237
+ }
142238
+ const documents2 = this.checkDocuments(params?.documents);
142239
+ const known = documents2.map((document) => ({ uri: this.knownSpelling(document.uri), text: document.text }));
142240
+ const diagnostics = this.documentManager.withTexts(known, () => known.map(({ uri }) => this.diagnose(uri)));
142241
+ return { documents: documents2.map((document, index2) => ({ uri: document.uri, diagnostics: diagnostics[index2] })) };
142242
+ }
142243
+ /** `documents` checked: a non-empty array of `{ uri, text }` within the limits, each naming a different document. */
142244
+ checkDocuments(documents2) {
142245
+ if (!Array.isArray(documents2) || documents2.length === 0) invalid('"documents" must be a non-empty array of { uri, text }.');
142246
+ const { maxDocuments, maxLines, maxCharacters, maxTotalCharacters } = this.settings;
142247
+ if (documents2.length > maxDocuments) {
142248
+ invalid(`${documents2.length} documents, more than the ${maxDocuments} allowed (sysml.experimental.validateText.maxDocuments).`);
142249
+ }
142250
+ const checked = documents2;
142251
+ let totalCharacters = 0;
142252
+ checked.forEach((document, index2) => {
142253
+ if (typeof document?.text !== "string") invalid(`documents[${index2}] needs "text", the SysML text to validate.`);
142254
+ if (document.text.length > maxCharacters) {
142255
+ invalid(`documents[${index2}] has ${document.text.length} characters, more than the ${maxCharacters} allowed (sysml.experimental.validateText.maxCharacters).`);
142256
+ }
142257
+ totalCharacters += document.text.length;
142258
+ if (totalCharacters > maxTotalCharacters) {
142259
+ invalid(`${totalCharacters} total characters, more than the ${maxTotalCharacters} allowed (sysml.experimental.validateText.maxTotalCharacters).`);
142260
+ }
142261
+ const lines = lineCount(document.text);
142262
+ if (lines > maxLines) {
142263
+ invalid(`documents[${index2}] has ${lines} lines, more than the ${maxLines} allowed (sysml.experimental.validateText.maxLines).`);
142264
+ }
142265
+ if (!isUri(document.uri)) invalid(`documents[${index2}] needs "uri", the document the text is the content of.`);
142266
+ const earlier = checked.findIndex((other) => isSameDocumentUri(other.uri, document.uri));
142267
+ if (earlier !== index2) invalid(`documents[${earlier}] and documents[${index2}] name the same document.`);
142268
+ });
142269
+ return checked;
142270
+ }
142271
+ /** The syntax, keyword and semantic diagnostics of the document at `uri`, as published for an open document. */
142272
+ diagnose(uri) {
142273
+ const diagnostics = new DiagnosticsProvider(this.documentManager).getDiagnostics(uri);
142274
+ const parseResult = this.documentManager.get(uri);
142275
+ if (parseResult) diagnostics.push(...validateKeywords(parseResult));
142276
+ diagnostics.push(...this.semanticValidator.validate(uri));
142277
+ return diagnostics.filter(this.isReported);
142278
+ }
142279
+ /** The spelling under which the server knows the document `uri` names, else `uri` itself (see `isSameDocumentUri`). */
142280
+ knownSpelling(uri) {
142281
+ return this.documentManager.getUris().find((known) => isSameDocumentUri(known, uri)) ?? uri;
142282
+ }
142283
+ };
142284
+ function lineCount(text) {
142285
+ const breaks = text.match(/\r\n|\r|\n/g)?.length ?? 0;
142286
+ return text === "" || /[\r\n]$/.test(text) ? breaks : breaks + 1;
142287
+ }
142288
+ function isUri(value) {
142289
+ return typeof value === "string" && value.trim() !== "";
142290
+ }
142291
+ function invalid(message) {
142292
+ throw new import_node13.ResponseError(import_node13.ErrorCodes.InvalidParams, `sysml/validateText: ${message}`);
142293
+ }
142294
+
142071
142295
  // server/src/platform/shims/fs-promises.ts
142072
142296
  async function readFile(_path, _enc) {
142073
142297
  throw new Error("fs/promises.readFile is not available in the browser");
@@ -142148,7 +142372,7 @@ ${info.documentation}`);
142148
142372
  return void 0;
142149
142373
  }
142150
142374
  var connection = createServerConnection();
142151
- var documents = new import_node13.TextDocuments(TextDocument2);
142375
+ var documents = new import_node14.TextDocuments(TextDocument2);
142152
142376
  var serverStartTime = Date.now();
142153
142377
  var documentManager = new DocumentManager();
142154
142378
  var modelProvider = new SysMLModelProvider(documentManager);
@@ -142165,6 +142389,7 @@ ${info.documentation}`);
142165
142389
  var codeActionProvider = new CodeActionProvider(documentManager);
142166
142390
  var formattingProvider = new FormattingProvider(documents);
142167
142391
  var semanticValidator = new SemanticValidator(documentManager);
142392
+ var textValidationProvider = new TextValidationProvider(documentManager, semanticValidator, isReported);
142168
142393
  hoverProvider.setSemanticValidator(semanticValidator);
142169
142394
  var hasConfigurationCapability = false;
142170
142395
  var hasWorkspaceFolderCapability = false;
@@ -142176,11 +142401,11 @@ ${info.documentation}`);
142176
142401
  var isWorkspaceFile = false;
142177
142402
  var preloadOnOpen = "workspaceOnly";
142178
142403
  var disabledDiagnosticCodes = /* @__PURE__ */ new Set();
142404
+ function isReported(diagnostic) {
142405
+ return diagnostic.code === void 0 || !disabledDiagnosticCodes.has(String(diagnostic.code));
142406
+ }
142179
142407
  function publishDiagnostics(uri, diagnostics) {
142180
- connection.sendDiagnostics({
142181
- uri,
142182
- diagnostics: diagnostics.filter((diagnostic) => diagnostic.code === void 0 || !disabledDiagnosticCodes.has(String(diagnostic.code)))
142183
- });
142408
+ connection.sendDiagnostics({ uri, diagnostics: diagnostics.filter(isReported) });
142184
142409
  }
142185
142410
  var skipDirs = new Set(DEFAULT_SKIP_DIRS);
142186
142411
  var serverReady = false;
@@ -142313,7 +142538,7 @@ ${info.documentation}`);
142313
142538
  };
142314
142539
  const result = {
142315
142540
  capabilities: {
142316
- textDocumentSync: import_node13.TextDocumentSyncKind.Incremental,
142541
+ textDocumentSync: import_node14.TextDocumentSyncKind.Incremental,
142317
142542
  // Completion
142318
142543
  completionProvider: {
142319
142544
  resolveProvider: true,
@@ -142341,7 +142566,7 @@ ${info.documentation}`);
142341
142566
  // Code actions (quick fixes)
142342
142567
  codeActionProvider: {
142343
142568
  codeActionKinds: [
142344
- import_node13.CodeActionKind.QuickFix
142569
+ import_node14.CodeActionKind.QuickFix
142345
142570
  ]
142346
142571
  },
142347
142572
  // Document formatting
@@ -142362,7 +142587,7 @@ ${info.documentation}`);
142362
142587
  connection.onInitialized(async () => {
142363
142588
  if (hasConfigurationCapability) {
142364
142589
  connection.client.register(
142365
- import_node13.DidChangeConfigurationNotification.type,
142590
+ import_node14.DidChangeConfigurationNotification.type,
142366
142591
  void 0
142367
142592
  );
142368
142593
  }
@@ -142423,6 +142648,8 @@ ${info.documentation}`);
142423
142648
  const validation = await connection.workspace.getConfiguration("sysml.validation");
142424
142649
  const codes = validation?.disabledCodes;
142425
142650
  disabledDiagnosticCodes = new Set(Array.isArray(codes) ? codes.filter((code) => typeof code === "string") : []);
142651
+ const experimental = await connection.workspace.getConfiguration("sysml.experimental");
142652
+ textValidationProvider.configure(readTextValidationSettings(experimental?.validateText));
142426
142653
  }
142427
142654
  function applySettings(config) {
142428
142655
  if (!config) return;
@@ -142776,6 +143003,10 @@ ${info.documentation}`);
142776
143003
  await initialization;
142777
143004
  return elementLookupProvider.elementLookup(params);
142778
143005
  });
143006
+ connection.onRequest("sysml/validateText", async (params) => {
143007
+ await initialization;
143008
+ return textValidationProvider.validate(params);
143009
+ });
142779
143010
  connection.onRequest("sysml/serverStats", () => {
142780
143011
  const mem = typeof process !== "undefined" && typeof process.memoryUsage === "function" ? process.memoryUsage() : { heapUsed: 0, heapTotal: 0, rss: 0, external: 0 };
142781
143012
  const toMB = (bytes) => Math.round(bytes / 1024 / 1024);