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.
- package/CHANGELOG.md +21 -0
- package/README.md +23 -1
- package/dist/server/browserServerMain.js +308 -77
- package/dist/server/mcpServer.js +72 -9
- package/dist/server/server.js +286 -55
- package/package.json +35 -1
package/dist/server/mcpServer.js
CHANGED
|
@@ -159214,12 +159214,19 @@ var MAX_NAMESPACE_NESTING_DEPTH = 64;
|
|
|
159214
159214
|
function findConflictedQualifiedNames(allSymbols) {
|
|
159215
159215
|
return groupConflicts(allSymbols.filter((s) => s.qualifiedName !== void 0), (s) => s.qualifiedName);
|
|
159216
159216
|
}
|
|
159217
|
+
function memberNamesOf(symbol2) {
|
|
159218
|
+
return symbol2.shortName && symbol2.shortName !== symbol2.name ? [symbol2.name, symbol2.shortName] : [symbol2.name];
|
|
159219
|
+
}
|
|
159217
159220
|
function findConflictingDeclarations(allSymbols) {
|
|
159218
159221
|
const conflicting = /* @__PURE__ */ new Map();
|
|
159219
159222
|
const add = (groups) => {
|
|
159220
|
-
for (const group of groups
|
|
159223
|
+
for (const group of groups) {
|
|
159224
|
+
for (const s of group) {
|
|
159225
|
+
conflicting.set(s, [.../* @__PURE__ */ new Set([...conflicting.get(s) ?? [], ...group])]);
|
|
159226
|
+
}
|
|
159227
|
+
}
|
|
159221
159228
|
};
|
|
159222
|
-
add(findConflictedQualifiedNames(allSymbols));
|
|
159229
|
+
add(findConflictedQualifiedNames(allSymbols).values());
|
|
159223
159230
|
const membersOfAnonymous = allSymbols.filter((s) => s.qualifiedName === void 0 && !isAnonymous(s) && s.parentId !== void 0);
|
|
159224
159231
|
const byOwner = /* @__PURE__ */ new Map();
|
|
159225
159232
|
for (const s of membersOfAnonymous) {
|
|
@@ -159227,13 +159234,33 @@ function findConflictingDeclarations(allSymbols) {
|
|
|
159227
159234
|
list.push(s);
|
|
159228
159235
|
byOwner.set(s.parentId, list);
|
|
159229
159236
|
}
|
|
159230
|
-
for (const members2 of byOwner.values()) add(groupConflicts(members2, (s) => s.name));
|
|
159237
|
+
for (const members2 of byOwner.values()) add(groupConflicts(members2, (s) => s.name).values());
|
|
159238
|
+
add([...findConflictingShortNames(allSymbols).values()].map((group) => group.symbols));
|
|
159231
159239
|
return conflicting;
|
|
159232
159240
|
}
|
|
159241
|
+
function findConflictingShortNames(allSymbols) {
|
|
159242
|
+
const byId = new Map(allSymbols.map((s) => [s.symbolId, s]));
|
|
159243
|
+
const entries = [];
|
|
159244
|
+
const keysWithShortName = /* @__PURE__ */ new Set();
|
|
159245
|
+
for (const s of allSymbols) {
|
|
159246
|
+
if (isAnonymous(s)) continue;
|
|
159247
|
+
const owner = s.parentId ? byId.get(s.parentId) : void 0;
|
|
159248
|
+
const namespace = owner === void 0 ? "q:" : owner.qualifiedName !== void 0 ? `q:${owner.qualifiedName}` : `id:${owner.symbolId}`;
|
|
159249
|
+
for (const name of memberNamesOf(s)) {
|
|
159250
|
+
const key = `${namespace}\0${name}`;
|
|
159251
|
+
entries.push({ symbol: s, key });
|
|
159252
|
+
if (name === s.shortName) keysWithShortName.add(key);
|
|
159253
|
+
}
|
|
159254
|
+
}
|
|
159255
|
+
const groups = groupKeyedConflicts(entries.filter((e) => keysWithShortName.has(e.key)));
|
|
159256
|
+
return new Map([...groups].map(([key, symbols]) => [key, { name: key.slice(key.indexOf("\0") + 1), symbols }]));
|
|
159257
|
+
}
|
|
159233
159258
|
function groupConflicts(symbols, keyOf) {
|
|
159259
|
+
return groupKeyedConflicts(symbols.map((symbol2) => ({ symbol: symbol2, key: keyOf(symbol2) })));
|
|
159260
|
+
}
|
|
159261
|
+
function groupKeyedConflicts(entries) {
|
|
159234
159262
|
const byKeyAndKind = /* @__PURE__ */ new Map();
|
|
159235
|
-
for (const s of
|
|
159236
|
-
const key = keyOf(s);
|
|
159263
|
+
for (const { symbol: s, key } of entries) {
|
|
159237
159264
|
let byKind = byKeyAndKind.get(key);
|
|
159238
159265
|
if (!byKind) {
|
|
159239
159266
|
byKind = /* @__PURE__ */ new Map();
|
|
@@ -159305,7 +159332,13 @@ function buildSymbolIndexes(allSymbols) {
|
|
|
159305
159332
|
for (const s of allSymbols) {
|
|
159306
159333
|
byId.set(s.symbolId, s);
|
|
159307
159334
|
}
|
|
159308
|
-
const
|
|
159335
|
+
const clashingShortNames = /* @__PURE__ */ new Map();
|
|
159336
|
+
for (const { name, symbols } of findConflictingShortNames(allSymbols).values()) {
|
|
159337
|
+
const clashing = clashingShortNames.get(name) ?? /* @__PURE__ */ new Set();
|
|
159338
|
+
for (const s of symbols) clashing.add(s);
|
|
159339
|
+
clashingShortNames.set(name, clashing);
|
|
159340
|
+
}
|
|
159341
|
+
const indexes = { byName, byParent, byQualifiedName, byId, definitionsByName, portsByName, clashingShortNames };
|
|
159309
159342
|
for (const s of allSymbols) {
|
|
159310
159343
|
if (isAnonymous(s)) continue;
|
|
159311
159344
|
const nameList = byName.get(s.name) ?? [];
|
|
@@ -159394,6 +159427,16 @@ var NamespaceResolver = class {
|
|
|
159394
159427
|
resolveNameIn(namespace, name, indexes) {
|
|
159395
159428
|
return this.resolveQualifiedNameFrom(namespace ? namespaceKeyOf(namespace) : "", name, indexes);
|
|
159396
159429
|
}
|
|
159430
|
+
/** Resolve an editor reference without losing the reason a name is unresolved. */
|
|
159431
|
+
resolveReferenceIn(namespace, name, indexes) {
|
|
159432
|
+
return this.resolveQualifiedReferenceFrom(namespace ? namespaceKeyOf(namespace) : "", name, indexes);
|
|
159433
|
+
}
|
|
159434
|
+
/** Resolve a public qualified or feature-path member, without enclosing-scope fallback. */
|
|
159435
|
+
resolveMemberReference(owner, name, indexes) {
|
|
159436
|
+
const members2 = this.getResolvedMembers(namespaceKeyOf(owner), indexes).get(name);
|
|
159437
|
+
if (members2 && this.isAmbiguous(name, members2, indexes)) return { ambiguous: true };
|
|
159438
|
+
return this.referenceTo(members2?.find((member) => member.visibility === "public")?.symbol, indexes);
|
|
159439
|
+
}
|
|
159397
159440
|
/**
|
|
159398
159441
|
* Resolve a (possibly qualified) name to its symbol per §7.5.1, searching
|
|
159399
159442
|
* outward from namespace `start` and its enclosing namespaces (its own resolved
|
|
@@ -159405,28 +159448,48 @@ var NamespaceResolver = class {
|
|
|
159405
159448
|
* its own enclosing package already imported, per §7.5.1/§7.5.3).
|
|
159406
159449
|
*/
|
|
159407
159450
|
resolveQualifiedNameFrom(start, name, indexes) {
|
|
159451
|
+
return this.resolveQualifiedReferenceFrom(start, name, indexes).symbol;
|
|
159452
|
+
}
|
|
159453
|
+
resolveQualifiedReferenceFrom(start, name, indexes) {
|
|
159408
159454
|
const [first, ...rest] = splitQualifiedName(name);
|
|
159409
159455
|
let resolved;
|
|
159410
159456
|
for (const ancestor of this.namespaceAncestorsOf(start, indexes)) {
|
|
159411
159457
|
const candidates = this.getResolvedMembers(ancestor, indexes).get(first);
|
|
159412
159458
|
if (candidates && candidates.length > 0) {
|
|
159459
|
+
if (this.isAmbiguous(first, candidates, indexes)) return { ambiguous: true };
|
|
159413
159460
|
resolved = candidates[0].symbol;
|
|
159414
159461
|
break;
|
|
159415
159462
|
}
|
|
159416
159463
|
}
|
|
159417
|
-
if (resolved === void 0) return
|
|
159464
|
+
if (resolved === void 0) return { ambiguous: false };
|
|
159418
159465
|
const isWithinStart = (namespace) => this.namespaceAncestorsOf(start, indexes).has(namespace);
|
|
159419
159466
|
for (const segment of rest) {
|
|
159420
159467
|
const owner = resolved;
|
|
159421
159468
|
const ownerKey = namespaceKeyOf(owner);
|
|
159422
159469
|
const members2 = this.getResolvedMembers(ownerKey, indexes).get(segment);
|
|
159470
|
+
if (members2 && this.isAmbiguous(segment, members2, indexes)) return { ambiguous: true };
|
|
159423
159471
|
const visibleMember = members2?.find(
|
|
159424
159472
|
(m2) => m2.visibility === "public" || isWithinStart(ownerKey) || m2.visibility === "protected" && this.isProtectedVisibleFrom(start, owner, indexes)
|
|
159425
159473
|
);
|
|
159426
|
-
if (!visibleMember) return
|
|
159474
|
+
if (!visibleMember) return { ambiguous: false };
|
|
159427
159475
|
resolved = visibleMember.symbol;
|
|
159428
159476
|
}
|
|
159429
|
-
return resolved
|
|
159477
|
+
return this.referenceTo(resolved, indexes);
|
|
159478
|
+
}
|
|
159479
|
+
referenceTo(resolved, indexes) {
|
|
159480
|
+
if (!resolved) return { ambiguous: false };
|
|
159481
|
+
const symbol2 = resolved.qualifiedName !== void 0 ? indexes.byQualifiedName.get(resolved.qualifiedName) : resolved;
|
|
159482
|
+
return { symbol: symbol2, ambiguous: symbol2 === void 0 };
|
|
159483
|
+
}
|
|
159484
|
+
/**
|
|
159485
|
+
* Whether `name` names more than one of `candidates` that clash on it
|
|
159486
|
+
* through a short name (`SymbolIndexes.clashingShortNames`), so it can't
|
|
159487
|
+
* be resolved to either (KerML 7.2.5.2). Like a conflicted qualifiedName,
|
|
159488
|
+
* it doesn't fall through to an enclosing namespace's member of that name.
|
|
159489
|
+
*/
|
|
159490
|
+
isAmbiguous(name, candidates, indexes) {
|
|
159491
|
+
const clashing = indexes.clashingShortNames.get(name);
|
|
159492
|
+
return clashing !== void 0 && candidates.filter((c) => clashing.has(c.symbol)).length > 1;
|
|
159430
159493
|
}
|
|
159431
159494
|
/**
|
|
159432
159495
|
* §7.5.3's protected-import exception: "A visibility of protected is the
|