* Formats a CallHierarchyItem with its location * Validates URI before formatting to handle malformed LSP data
( item: CallHierarchyItem, cwd?: string, )
| 426 | * Validates URI before formatting to handle malformed LSP data |
| 427 | */ |
| 428 | function formatCallHierarchyItem( |
| 429 | item: CallHierarchyItem, |
| 430 | cwd?: string, |
| 431 | ): string { |
| 432 | // Validate URI - handle undefined/null gracefully |
| 433 | if (!item.uri) { |
| 434 | logForDebugging( |
| 435 | 'formatCallHierarchyItem: CallHierarchyItem has undefined URI', |
| 436 | { level: 'warn' }, |
| 437 | ) |
| 438 | return `${item.name} (${symbolKindToString(item.kind)}) - <unknown location>` |
| 439 | } |
| 440 | |
| 441 | const filePath = formatUri(item.uri, cwd) |
| 442 | const line = item.range.start.line + 1 |
| 443 | const kind = symbolKindToString(item.kind) |
| 444 | let result = `${item.name} (${kind}) - ${filePath}:${line}` |
| 445 | if (item.detail) { |
| 446 | result += ` [${item.detail}]` |
| 447 | } |
| 448 | return result |
| 449 | } |
| 450 | |
| 451 | /** |
| 452 | * Formats prepareCallHierarchy result |
no test coverage detected