umple-lsp-server 0.2.0 → 0.2.2
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/completions.scm +21 -6
- package/definitions.scm +4 -0
- package/out/completionAnalysis.d.ts +44 -0
- package/out/completionAnalysis.js +391 -0
- package/out/completionAnalysis.js.map +1 -0
- package/out/completionBuilder.d.ts +28 -0
- package/out/completionBuilder.js +251 -0
- package/out/completionBuilder.js.map +1 -0
- package/out/documentSymbolBuilder.d.ts +13 -0
- package/out/documentSymbolBuilder.js +95 -0
- package/out/documentSymbolBuilder.js.map +1 -0
- package/out/formatter.d.ts +31 -0
- package/out/formatter.js +96 -0
- package/out/formatter.js.map +1 -0
- package/out/hoverBuilder.d.ts +21 -0
- package/out/hoverBuilder.js +308 -0
- package/out/hoverBuilder.js.map +1 -0
- package/out/importGraph.d.ts +28 -0
- package/out/importGraph.js +91 -0
- package/out/importGraph.js.map +1 -0
- package/out/referenceSearch.d.ts +22 -0
- package/out/referenceSearch.js +271 -0
- package/out/referenceSearch.js.map +1 -0
- package/out/resolver.d.ts +21 -0
- package/out/resolver.js +174 -0
- package/out/resolver.js.map +1 -0
- package/out/server.js +350 -328
- package/out/server.js.map +1 -1
- package/out/symbolIndex.d.ts +86 -94
- package/out/symbolIndex.js +357 -399
- package/out/symbolIndex.js.map +1 -1
- package/out/symbolTypes.d.ts +34 -0
- package/out/symbolTypes.js +9 -0
- package/out/symbolTypes.js.map +1 -0
- package/out/tokenAnalysis.d.ts +24 -0
- package/out/tokenAnalysis.js +195 -0
- package/out/tokenAnalysis.js.map +1 -0
- package/out/tokenTypes.d.ts +46 -0
- package/out/tokenTypes.js +28 -0
- package/out/tokenTypes.js.map +1 -0
- package/out/treeUtils.d.ts +32 -0
- package/out/treeUtils.js +89 -0
- package/out/treeUtils.js.map +1 -0
- package/package.json +4 -2
- package/references.scm +78 -10
- package/tree-sitter-umple.wasm +0 -0
|
@@ -0,0 +1,308 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Hover content builder.
|
|
4
|
+
*
|
|
5
|
+
* Produces markdown hover strings from SymbolEntry data + tree access.
|
|
6
|
+
* No dependency on LSP connection, documents, or SymbolIndex class.
|
|
7
|
+
*/
|
|
8
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
+
exports.buildHoverMarkdown = buildHoverMarkdown;
|
|
10
|
+
// Module-level context set by the entry point
|
|
11
|
+
let ctx;
|
|
12
|
+
function findDefNode(sym) {
|
|
13
|
+
if (sym.defLine == null || sym.defEndLine == null)
|
|
14
|
+
return null;
|
|
15
|
+
const tree = ctx.getTree(sym.file);
|
|
16
|
+
if (!tree)
|
|
17
|
+
return null;
|
|
18
|
+
return tree.rootNode.descendantForPosition({ row: sym.defLine, column: sym.defColumn ?? 0 }, { row: sym.defEndLine, column: sym.defEndColumn ?? 0 });
|
|
19
|
+
}
|
|
20
|
+
function buildClassLikeHover(sym, allSymbols) {
|
|
21
|
+
const keyword = sym.kind;
|
|
22
|
+
const parts = [];
|
|
23
|
+
const sameNameSyms = allSymbols.filter((s) => s.kind === sym.kind && s.name === sym.name);
|
|
24
|
+
let isAbstract = false;
|
|
25
|
+
for (const s of sameNameSyms) {
|
|
26
|
+
const node = findDefNode(s);
|
|
27
|
+
if (node &&
|
|
28
|
+
node.children.some((c) => c.type === "abstract_declaration")) {
|
|
29
|
+
isAbstract = true;
|
|
30
|
+
break;
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
let header = "";
|
|
34
|
+
if (isAbstract)
|
|
35
|
+
header += "abstract ";
|
|
36
|
+
header += `${keyword} ${sym.name}`;
|
|
37
|
+
parts.push(header);
|
|
38
|
+
const parents = ctx.getIsAParents(sym.name);
|
|
39
|
+
if (parents.length > 0) {
|
|
40
|
+
parts.push(`isA ${parents.join(", ")}`);
|
|
41
|
+
}
|
|
42
|
+
if (keyword === "enum") {
|
|
43
|
+
const defNode = findDefNode(sym);
|
|
44
|
+
if (defNode) {
|
|
45
|
+
const values = [];
|
|
46
|
+
for (const child of defNode.children) {
|
|
47
|
+
if (child.type === "enum_value") {
|
|
48
|
+
const name = child.childForFieldName("name");
|
|
49
|
+
if (name)
|
|
50
|
+
values.push(name.text);
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
if (values.length > 0) {
|
|
54
|
+
parts.push(`{ ${values.join(", ")} }`);
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
return "```umple\n" + parts.join("\n") + "\n```";
|
|
59
|
+
}
|
|
60
|
+
function buildAttributeHover(sym, defNode) {
|
|
61
|
+
const parts = [];
|
|
62
|
+
const modifier = defNode.children.find((c) => c.type === "attribute_modifier");
|
|
63
|
+
if (modifier)
|
|
64
|
+
parts.push(modifier.text);
|
|
65
|
+
const typeNode = defNode.childForFieldName("type");
|
|
66
|
+
if (typeNode) {
|
|
67
|
+
parts.push(typeNode.text);
|
|
68
|
+
}
|
|
69
|
+
else if (!modifier || modifier.text !== "autounique") {
|
|
70
|
+
parts.push("String");
|
|
71
|
+
}
|
|
72
|
+
parts.push(sym.name);
|
|
73
|
+
let extra = "";
|
|
74
|
+
if (sym.container) {
|
|
75
|
+
extra = `\n\n*in class ${sym.container}*`;
|
|
76
|
+
}
|
|
77
|
+
return "```umple\n" + parts.join(" ") + "\n```" + extra;
|
|
78
|
+
}
|
|
79
|
+
function buildConstHover(sym, defNode) {
|
|
80
|
+
const typeNode = defNode.childForFieldName("type");
|
|
81
|
+
const typeName = typeNode ? typeNode.text : "String";
|
|
82
|
+
let value = "";
|
|
83
|
+
let seenEquals = false;
|
|
84
|
+
for (const child of defNode.children) {
|
|
85
|
+
if (child.type === "=" || child.text === "=") {
|
|
86
|
+
seenEquals = true;
|
|
87
|
+
continue;
|
|
88
|
+
}
|
|
89
|
+
if (seenEquals && child.text !== ";") {
|
|
90
|
+
value = child.text;
|
|
91
|
+
break;
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
let result = "```umple\nconst " + typeName + " " + sym.name;
|
|
95
|
+
if (value)
|
|
96
|
+
result += " = " + value;
|
|
97
|
+
result += "\n```";
|
|
98
|
+
if (sym.container) {
|
|
99
|
+
result += `\n\n*in class ${sym.container}*`;
|
|
100
|
+
}
|
|
101
|
+
return result;
|
|
102
|
+
}
|
|
103
|
+
function buildMethodHover(sym, defNode) {
|
|
104
|
+
const parts = [];
|
|
105
|
+
const vis = defNode.children.find((c) => c.type === "visibility");
|
|
106
|
+
if (vis)
|
|
107
|
+
parts.push(vis.text);
|
|
108
|
+
for (const child of defNode.children) {
|
|
109
|
+
if (child.type === "static") {
|
|
110
|
+
parts.push("static");
|
|
111
|
+
break;
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
const returnType = defNode.childForFieldName("return_type");
|
|
115
|
+
if (returnType) {
|
|
116
|
+
parts.push(returnType.text);
|
|
117
|
+
}
|
|
118
|
+
else {
|
|
119
|
+
parts.push("void");
|
|
120
|
+
}
|
|
121
|
+
const paramList = defNode.children.find((c) => c.type === "param_list");
|
|
122
|
+
let paramStr = "";
|
|
123
|
+
if (paramList) {
|
|
124
|
+
const params = [];
|
|
125
|
+
for (const p of paramList.children) {
|
|
126
|
+
if (p.type === "param") {
|
|
127
|
+
const pName = p.childForFieldName("name");
|
|
128
|
+
const pType = p.children.find((c) => c.type === "type_name");
|
|
129
|
+
if (pType && pName) {
|
|
130
|
+
params.push(`${pType.text} ${pName.text}`);
|
|
131
|
+
}
|
|
132
|
+
else if (pName) {
|
|
133
|
+
params.push(pName.text);
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
paramStr = params.join(", ");
|
|
138
|
+
}
|
|
139
|
+
parts.push(`${sym.name}(${paramStr})`);
|
|
140
|
+
let extra = "";
|
|
141
|
+
if (sym.container) {
|
|
142
|
+
extra = `\n\n*in class ${sym.container}*`;
|
|
143
|
+
}
|
|
144
|
+
return "```umple\n" + parts.join(" ") + "\n```" + extra;
|
|
145
|
+
}
|
|
146
|
+
function buildStateMachineHover(sym, allSymbols) {
|
|
147
|
+
const stateNames = [];
|
|
148
|
+
const sameNameSyms = allSymbols.filter((s) => s.kind === "statemachine" && s.name === sym.name);
|
|
149
|
+
for (const s of sameNameSyms) {
|
|
150
|
+
const node = findDefNode(s);
|
|
151
|
+
if (!node)
|
|
152
|
+
continue;
|
|
153
|
+
for (const child of node.children) {
|
|
154
|
+
if (child.type === "state") {
|
|
155
|
+
const name = child.childForFieldName("name");
|
|
156
|
+
if (name && !stateNames.includes(name.text)) {
|
|
157
|
+
stateNames.push(name.text);
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
let result = "```umple\n" + sym.name + " (state machine)\n```";
|
|
163
|
+
if (stateNames.length > 0) {
|
|
164
|
+
result += `\n\nStates: ${stateNames.join(", ")}`;
|
|
165
|
+
}
|
|
166
|
+
if (sym.container) {
|
|
167
|
+
result += `\n\n*in class ${sym.container}*`;
|
|
168
|
+
}
|
|
169
|
+
return result;
|
|
170
|
+
}
|
|
171
|
+
function collectStateInfo(defNode) {
|
|
172
|
+
const transitions = [];
|
|
173
|
+
const actions = [];
|
|
174
|
+
const nestedStates = [];
|
|
175
|
+
for (const child of defNode.children) {
|
|
176
|
+
if (child.type === "transition") {
|
|
177
|
+
const event = child.childForFieldName("event");
|
|
178
|
+
const target = child.childForFieldName("target");
|
|
179
|
+
const guard = child.children.find((c) => c.type === "guard");
|
|
180
|
+
let transStr = " ";
|
|
181
|
+
if (event)
|
|
182
|
+
transStr += event.text;
|
|
183
|
+
else
|
|
184
|
+
transStr += "(auto)";
|
|
185
|
+
if (guard)
|
|
186
|
+
transStr += ` ${guard.text}`;
|
|
187
|
+
if (target)
|
|
188
|
+
transStr += ` -> ${target.text}`;
|
|
189
|
+
if (!transitions.includes(transStr))
|
|
190
|
+
transitions.push(transStr);
|
|
191
|
+
}
|
|
192
|
+
if (child.type === "entry_exit_action") {
|
|
193
|
+
const keyword = child.children.find((c) => c.text === "entry" || c.text === "exit")
|
|
194
|
+
?.text ?? "action";
|
|
195
|
+
const line = ` ${keyword} / { ... }`;
|
|
196
|
+
if (!actions.includes(line))
|
|
197
|
+
actions.push(line);
|
|
198
|
+
}
|
|
199
|
+
if (child.type === "state") {
|
|
200
|
+
const name = child.childForFieldName("name");
|
|
201
|
+
if (name && !nestedStates.includes(name.text)) {
|
|
202
|
+
nestedStates.push(name.text);
|
|
203
|
+
}
|
|
204
|
+
}
|
|
205
|
+
}
|
|
206
|
+
return { transitions, actions, nestedStates };
|
|
207
|
+
}
|
|
208
|
+
function buildStateHover(sym, allSymbols) {
|
|
209
|
+
const lines = [`${sym.name} (state)`];
|
|
210
|
+
const sameNameStates = allSymbols.filter((s) => s.kind === "state" && s.name === sym.name);
|
|
211
|
+
for (const s of sameNameStates) {
|
|
212
|
+
const node = findDefNode(s);
|
|
213
|
+
if (!node)
|
|
214
|
+
continue;
|
|
215
|
+
const info = collectStateInfo(node);
|
|
216
|
+
for (const t of info.transitions) {
|
|
217
|
+
if (!lines.includes(t))
|
|
218
|
+
lines.push(t);
|
|
219
|
+
}
|
|
220
|
+
for (const a of info.actions) {
|
|
221
|
+
if (!lines.includes(a))
|
|
222
|
+
lines.push(a);
|
|
223
|
+
}
|
|
224
|
+
if (info.nestedStates.length > 0) {
|
|
225
|
+
const nested = ` nested: ${info.nestedStates.join(", ")}`;
|
|
226
|
+
if (!lines.includes(nested))
|
|
227
|
+
lines.push(nested);
|
|
228
|
+
}
|
|
229
|
+
}
|
|
230
|
+
let result = "```umple\n" + lines.join("\n") + "\n```";
|
|
231
|
+
if (sym.container) {
|
|
232
|
+
const smDisplay = sym.container.includes(".")
|
|
233
|
+
? sym.container.substring(sym.container.indexOf(".") + 1)
|
|
234
|
+
: sym.container;
|
|
235
|
+
result += `\n\n*in state machine ${smDisplay}*`;
|
|
236
|
+
}
|
|
237
|
+
return result;
|
|
238
|
+
}
|
|
239
|
+
function buildAssociationHover(sym, defNode) {
|
|
240
|
+
const nodeType = defNode.type;
|
|
241
|
+
if (nodeType === "association_definition") {
|
|
242
|
+
const members = defNode.children.filter((c) => c.type === "association_member");
|
|
243
|
+
if (members.length > 0) {
|
|
244
|
+
const lines = [];
|
|
245
|
+
for (const member of members) {
|
|
246
|
+
lines.push(member.text.trim());
|
|
247
|
+
}
|
|
248
|
+
let result = "```umple\nassociation";
|
|
249
|
+
if (sym.name)
|
|
250
|
+
result += ` ${sym.name}`;
|
|
251
|
+
result += `\n ${lines.join("\n ")}\n\`\`\``;
|
|
252
|
+
return result;
|
|
253
|
+
}
|
|
254
|
+
}
|
|
255
|
+
if (nodeType === "inline_association" || nodeType === "association_inline") {
|
|
256
|
+
return "```umple\n" + defNode.text.trim() + "\n```";
|
|
257
|
+
}
|
|
258
|
+
return "```umple\nassociation " + sym.name + "\n```";
|
|
259
|
+
}
|
|
260
|
+
/**
|
|
261
|
+
* Build markdown hover content for a resolved symbol.
|
|
262
|
+
*
|
|
263
|
+
* @param sym The primary resolved symbol
|
|
264
|
+
* @param allSymbols Full match list (for merging split definitions)
|
|
265
|
+
* @param hoverCtx Callbacks for tree access and isA parents
|
|
266
|
+
* @returns Markdown string, or null if no definition node found
|
|
267
|
+
*/
|
|
268
|
+
function buildHoverMarkdown(sym, allSymbols, hoverCtx) {
|
|
269
|
+
ctx = hoverCtx;
|
|
270
|
+
const defNode = findDefNode(sym);
|
|
271
|
+
if (!defNode)
|
|
272
|
+
return null;
|
|
273
|
+
switch (sym.kind) {
|
|
274
|
+
case "class":
|
|
275
|
+
case "interface":
|
|
276
|
+
case "trait":
|
|
277
|
+
case "enum":
|
|
278
|
+
return buildClassLikeHover(sym, allSymbols);
|
|
279
|
+
case "attribute":
|
|
280
|
+
return buildAttributeHover(sym, defNode);
|
|
281
|
+
case "const":
|
|
282
|
+
return buildConstHover(sym, defNode);
|
|
283
|
+
case "method":
|
|
284
|
+
return buildMethodHover(sym, defNode);
|
|
285
|
+
case "statemachine":
|
|
286
|
+
return buildStateMachineHover(sym, allSymbols);
|
|
287
|
+
case "state":
|
|
288
|
+
return buildStateHover(sym, allSymbols);
|
|
289
|
+
case "association":
|
|
290
|
+
return buildAssociationHover(sym, defNode);
|
|
291
|
+
case "enum_value": {
|
|
292
|
+
let result = "```umple\n" + sym.name + "\n```";
|
|
293
|
+
if (sym.container) {
|
|
294
|
+
result += `\n\n*in enum ${sym.container}*`;
|
|
295
|
+
}
|
|
296
|
+
return result;
|
|
297
|
+
}
|
|
298
|
+
case "mixset":
|
|
299
|
+
return "```umple\nmixset " + sym.name + "\n```";
|
|
300
|
+
case "requirement":
|
|
301
|
+
return "```umple\nrequirement " + sym.name + "\n```";
|
|
302
|
+
case "template":
|
|
303
|
+
return "```umple\ntemplate " + sym.name + "\n```";
|
|
304
|
+
default:
|
|
305
|
+
return "```umple\n" + sym.kind + " " + sym.name + "\n```";
|
|
306
|
+
}
|
|
307
|
+
}
|
|
308
|
+
//# sourceMappingURL=hoverBuilder.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"hoverBuilder.js","sourceRoot":"","sources":["../src/hoverBuilder.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;AAwUH,gDA4CC;AA1WD,8CAA8C;AAC9C,IAAI,GAAiB,CAAC;AAEtB,SAAS,WAAW,CAAC,GAAgB;IACnC,IAAI,GAAG,CAAC,OAAO,IAAI,IAAI,IAAI,GAAG,CAAC,UAAU,IAAI,IAAI;QAAE,OAAO,IAAI,CAAC;IAC/D,MAAM,IAAI,GAAG,GAAG,CAAC,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;IACnC,IAAI,CAAC,IAAI;QAAE,OAAO,IAAI,CAAC;IACvB,OAAO,IAAI,CAAC,QAAQ,CAAC,qBAAqB,CACxC,EAAE,GAAG,EAAE,GAAG,CAAC,OAAO,EAAE,MAAM,EAAE,GAAG,CAAC,SAAS,IAAI,CAAC,EAAE,EAChD,EAAE,GAAG,EAAE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CAAC;QAChB,CAAC;QACD,KAAK,QAAQ;YACX,OAAO,mBAAmB,GAAG,GAAG,CAAC,IAAI,GAAG,OAAO,CAAC;QAClD,KAAK,aAAa;YAChB,OAAO,wBAAwB,GAAG,GAAG,CAAC,IAAI,GAAG,OAAO,CAAC;QACvD,KAAK,UAAU;YACb,OAAO,qBAAqB,GAAG,GAAG,CAAC,IAAI,GAAG,OAAO,CAAC;QACpD;YACE,OAAO,YAAY,GAAG,GAAG,CAAC,IAAI,GAAG,GAAG,GAAG,GAAG,CAAC,IAAI,GAAG,OAAO,CAAC;IAC9D,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Import graph data structure.
|
|
3
|
+
*
|
|
4
|
+
* Manages forward (file → imports) and reverse (file → importers) edge maps
|
|
5
|
+
* for use-statement resolution. Owns only edge storage and traversal —
|
|
6
|
+
* path resolution, use parsing, and fs policy stay in symbolIndex.ts.
|
|
7
|
+
*/
|
|
8
|
+
export declare class ImportGraph {
|
|
9
|
+
private forward;
|
|
10
|
+
private reverse;
|
|
11
|
+
/**
|
|
12
|
+
* Update import edges for a file. Removes old edges first, then adds new ones.
|
|
13
|
+
*/
|
|
14
|
+
setEdges(filePath: string, imports: Set<string>): void;
|
|
15
|
+
/**
|
|
16
|
+
* Remove all edges for a file (both directions).
|
|
17
|
+
*/
|
|
18
|
+
removeEdges(filePath: string): void;
|
|
19
|
+
/**
|
|
20
|
+
* Get forward imports for a file.
|
|
21
|
+
*/
|
|
22
|
+
getForward(filePath: string): Set<string> | undefined;
|
|
23
|
+
/**
|
|
24
|
+
* Transitive reverse closure: all files whose use chain can reach
|
|
25
|
+
* any of the given target files.
|
|
26
|
+
*/
|
|
27
|
+
getReverseImporters(targetFiles: Set<string>): Set<string>;
|
|
28
|
+
}
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Import graph data structure.
|
|
4
|
+
*
|
|
5
|
+
* Manages forward (file → imports) and reverse (file → importers) edge maps
|
|
6
|
+
* for use-statement resolution. Owns only edge storage and traversal —
|
|
7
|
+
* path resolution, use parsing, and fs policy stay in symbolIndex.ts.
|
|
8
|
+
*/
|
|
9
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10
|
+
exports.ImportGraph = void 0;
|
|
11
|
+
class ImportGraph {
|
|
12
|
+
forward = new Map();
|
|
13
|
+
reverse = new Map();
|
|
14
|
+
/**
|
|
15
|
+
* Update import edges for a file. Removes old edges first, then adds new ones.
|
|
16
|
+
*/
|
|
17
|
+
setEdges(filePath, imports) {
|
|
18
|
+
// Remove old forward edges from reverse map
|
|
19
|
+
const oldImports = this.forward.get(filePath);
|
|
20
|
+
if (oldImports) {
|
|
21
|
+
for (const imp of oldImports) {
|
|
22
|
+
const rev = this.reverse.get(imp);
|
|
23
|
+
if (rev) {
|
|
24
|
+
rev.delete(filePath);
|
|
25
|
+
if (rev.size === 0)
|
|
26
|
+
this.reverse.delete(imp);
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
// Set new forward edges
|
|
31
|
+
this.forward.set(filePath, imports);
|
|
32
|
+
// Add new reverse edges
|
|
33
|
+
for (const imp of imports) {
|
|
34
|
+
let rev = this.reverse.get(imp);
|
|
35
|
+
if (!rev) {
|
|
36
|
+
rev = new Set();
|
|
37
|
+
this.reverse.set(imp, rev);
|
|
38
|
+
}
|
|
39
|
+
rev.add(filePath);
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* Remove all edges for a file (both directions).
|
|
44
|
+
*/
|
|
45
|
+
removeEdges(filePath) {
|
|
46
|
+
// Clean forward → reverse
|
|
47
|
+
const oldImports = this.forward.get(filePath);
|
|
48
|
+
if (oldImports) {
|
|
49
|
+
for (const imp of oldImports) {
|
|
50
|
+
const rev = this.reverse.get(imp);
|
|
51
|
+
if (rev) {
|
|
52
|
+
rev.delete(filePath);
|
|
53
|
+
if (rev.size === 0)
|
|
54
|
+
this.reverse.delete(imp);
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
this.forward.delete(filePath);
|
|
59
|
+
// Also remove as a target in reverse map
|
|
60
|
+
this.reverse.delete(filePath);
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* Get forward imports for a file.
|
|
64
|
+
*/
|
|
65
|
+
getForward(filePath) {
|
|
66
|
+
return this.forward.get(filePath);
|
|
67
|
+
}
|
|
68
|
+
/**
|
|
69
|
+
* Transitive reverse closure: all files whose use chain can reach
|
|
70
|
+
* any of the given target files.
|
|
71
|
+
*/
|
|
72
|
+
getReverseImporters(targetFiles) {
|
|
73
|
+
const result = new Set();
|
|
74
|
+
const queue = [...targetFiles];
|
|
75
|
+
while (queue.length > 0) {
|
|
76
|
+
const file = queue.pop();
|
|
77
|
+
const importers = this.reverse.get(file);
|
|
78
|
+
if (!importers)
|
|
79
|
+
continue;
|
|
80
|
+
for (const importer of importers) {
|
|
81
|
+
if (!result.has(importer) && !targetFiles.has(importer)) {
|
|
82
|
+
result.add(importer);
|
|
83
|
+
queue.push(importer);
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
return result;
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
exports.ImportGraph = ImportGraph;
|
|
91
|
+
//# sourceMappingURL=importGraph.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"importGraph.js","sourceRoot":"","sources":["../src/importGraph.ts"],"names":[],"mappings":";AAAA;;;;;;GAMG;;;AAEH,MAAa,WAAW;IACd,OAAO,GAAG,IAAI,GAAG,EAAuB,CAAC;IACzC,OAAO,GAAG,IAAI,GAAG,EAAuB,CAAC;IAEjD;;OAEG;IACH,QAAQ,CAAC,QAAgB,EAAE,OAAoB;QAC7C,4CAA4C;QAC5C,MAAM,UAAU,GAAG,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC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
* Finds all references to a symbol across indexed files using
|
|
5
|
+
* references.scm query captures and semantic filtering.
|
|
6
|
+
* No dependency on SymbolIndex class.
|
|
7
|
+
*/
|
|
8
|
+
declare const TreeSitter: any;
|
|
9
|
+
type Tree = InstanceType<typeof TreeSitter.Tree>;
|
|
10
|
+
type Query = InstanceType<typeof TreeSitter.Query>;
|
|
11
|
+
import type { SymbolEntry, ReferenceLocation } from "./symbolTypes";
|
|
12
|
+
/**
|
|
13
|
+
* Find all references to a symbol across the given files.
|
|
14
|
+
*
|
|
15
|
+
* @param declarations Target symbol declaration(s)
|
|
16
|
+
* @param includeDeclaration Whether to include declaration sites in results
|
|
17
|
+
* @param referencesQuery Loaded references.scm query
|
|
18
|
+
* @param fileTreeMap filePath → cached parse tree (only files to search)
|
|
19
|
+
* @param isAGraph className → parent class names (for inheritance checks)
|
|
20
|
+
*/
|
|
21
|
+
export declare function searchReferences(declarations: SymbolEntry[], includeDeclaration: boolean, referencesQuery: Query, fileTreeMap: Map<string, Tree>, isAGraph: Map<string, string[]>): ReferenceLocation[];
|
|
22
|
+
export {};
|