MCPcopy
hub / github.com/codeaashu/claude-code / formatOutgoingCallsResult

Function formatOutgoingCallsResult

src/tools/LSPTool/formatters.ts:538–592  ·  view source on GitHub ↗
(
  result: CallHierarchyOutgoingCall[] | null,
  cwd?: string,
)

Source from the content-addressed store, hash-verified

536 * Shows all functions/methods called by the target
537 */
538export function formatOutgoingCallsResult(
539 result: CallHierarchyOutgoingCall[] | null,
540 cwd?: string,
541): string {
542 if (!result || result.length === 0) {
543 return 'No outgoing calls found (this function calls nothing)'
544 }
545
546 const lines = [
547 `Found ${result.length} outgoing ${plural(result.length, 'call')}:`,
548 ]
549
550 // Group by file
551 const byFile = new Map<string, CallHierarchyOutgoingCall[]>()
552 for (const call of result) {
553 if (!call.to) {
554 logForDebugging(
555 'formatOutgoingCallsResult: CallHierarchyOutgoingCall has undefined to field',
556 { level: 'warn' },
557 )
558 continue
559 }
560 const filePath = formatUri(call.to.uri, cwd)
561 const existing = byFile.get(filePath)
562 if (existing) {
563 existing.push(call)
564 } else {
565 byFile.set(filePath, [call])
566 }
567 }
568
569 for (const [filePath, calls] of byFile) {
570 lines.push(`\n${filePath}:`)
571 for (const call of calls) {
572 if (!call.to) {
573 continue // Already logged above
574 }
575 const kind = symbolKindToString(call.to.kind)
576 const line = call.to.range.start.line + 1
577 let callLine = ` ${call.to.name} (${kind}) - Line ${line}`
578
579 // Show call sites within the current function
580 if (call.fromRanges && call.fromRanges.length > 0) {
581 const callSites = call.fromRanges
582 .map(r => `${r.start.line + 1}:${r.start.character + 1}`)
583 .join(', ')
584 callLine += ` [called from: ${callSites}]`
585 }
586
587 lines.push(callLine)
588 }
589 }
590
591 return lines.join('\n')
592}
593

Callers 1

formatResultFunction · 0.85

Calls 7

pluralFunction · 0.85
logForDebuggingFunction · 0.85
symbolKindToStringFunction · 0.85
formatUriFunction · 0.70
getMethod · 0.65
pushMethod · 0.45
setMethod · 0.45

Tested by

no test coverage detected