MCPcopy Create free account
hub / github.com/colbymchenry/codegraph / refsByLine

Function refsByLine

ui/src/lib/symbol-model.ts:215–243  ·  view source on GitHub ↗
(payload: WireSymbolPayload)

Source from the content-addressed store, hash-verified

213 * the graph from this line", and a type reference does.
214 */
215export function refsByLine(payload: WireSymbolPayload): Map<number, LineRef[]> {
216 const byLine = new Map<number, LineRef[]>();
217 const add = (line: number, ref: LineRef): void => {
218 const bucket = byLine.get(line);
219 if (bucket) bucket.push(ref);
220 else byLine.set(line, [ref]);
221 };
222
223 for (const relation of [...payload.outgoing.items, ...payload.typesUsed]) {
224 for (const edge of relation.edges) {
225 if (!edge.line) continue;
226 const word = edgeWord(edge);
227 add(edge.line, {
228 ident: lastSegment(relation.node.name),
229 col: typeof edge.col === 'number' ? edge.col : null,
230 targetId: relation.node.id,
231 uncertain: relation.uncertain,
232 outside: false,
233 title:
234 `${word || 'calls'} ${relation.node.qualifiedName} — ${relation.node.file}:${relation.node.line}` +
235 (edge.confidence != null ? ` · confidence ${edge.confidence}` : '') +
236 (edge.resolvedBy ? ` · resolved by ${edge.resolvedBy}` : ''),
237 });
238 }
239 }
240
241 for (const ref of outsideRefs(payload.outsideIndex)) add(ref.line, ref.ref);
242 return byLine;
243}
244
245/**
246 * The lines a long body is windowed around.

Callers 1

Calls 4

edgeWordFunction · 0.85
outsideRefsFunction · 0.85
addFunction · 0.70
lastSegmentFunction · 0.70

Tested by

no test coverage detected