(payload: WireFileCodePayload)
| 215 | * empty gutter that reads as "nothing happens here". |
| 216 | */ |
| 217 | export function buildFileRefs(payload: WireFileCodePayload): Map<number, LineRef[]> { |
| 218 | const byLine = new Map<number, LineRef[]>(); |
| 219 | const add = (line: number, ref: LineRef): void => { |
| 220 | const bucket = byLine.get(line); |
| 221 | if (bucket) bucket.push(ref); |
| 222 | else byLine.set(line, [ref]); |
| 223 | }; |
| 224 | |
| 225 | for (const call of payload.calls.items) { |
| 226 | const relation = call.relation; |
| 227 | const ident = lastSegment(relation.node.name); |
| 228 | const words = relationWords(relation); |
| 229 | const covered = new Set<number>(); |
| 230 | for (const edge of relation.edges) { |
| 231 | if (!edge.line) continue; |
| 232 | covered.add(edge.line); |
| 233 | add(edge.line, { |
| 234 | ident, |
| 235 | col: typeof edge.col === 'number' ? edge.col : null, |
| 236 | targetId: relation.node.id, |
| 237 | uncertain: relation.uncertain, |
| 238 | outside: false, |
| 239 | title: |
| 240 | `${words[0] || 'calls'} ${relation.node.qualifiedName} — ${relation.node.file}:${relation.node.line}` + |
| 241 | (edge.confidence != null ? ` · confidence ${edge.confidence}` : '') + |
| 242 | (edge.resolvedBy ? ` · resolved by ${edge.resolvedBy}` : ''), |
| 243 | }); |
| 244 | } |
| 245 | for (const line of relation.lines) { |
| 246 | if (covered.has(line)) continue; |
| 247 | add(line, { |
| 248 | ident, |
| 249 | col: null, |
| 250 | targetId: relation.node.id, |
| 251 | uncertain: relation.uncertain, |
| 252 | outside: false, |
| 253 | title: `${words[0] || 'calls'} ${relation.node.qualifiedName} — ${relation.node.file}:${relation.node.line}`, |
| 254 | }); |
| 255 | } |
| 256 | } |
| 257 | |
| 258 | for (const ref of payload.outside.items) add(ref.line, outsideRef(ref)); |
| 259 | return byLine; |
| 260 | } |
| 261 | |
| 262 | function outsideRef(ref: WireFileOutsideRef): LineRef { |
| 263 | return { |
no test coverage detected