MCPcopy Create free account
hub / github.com/codeaashu/claude-code / formatDiagnosticsForAttachment

Function formatDiagnosticsForAttachment

src/services/lsp/passiveFeedback.ts:43–100  ·  view source on GitHub ↗
(
  params: PublishDiagnosticsParams,
)

Source from the content-addressed store, hash-verified

41 * used by Claude's attachment system.
42 */
43export function formatDiagnosticsForAttachment(
44 params: PublishDiagnosticsParams,
45): DiagnosticFile[] {
46 // Parse URI (may be file:// or plain path) and normalize to file system path
47 let uri: string
48 try {
49 // Handle both file:// URIs and plain paths
50 uri = params.uri.startsWith('file://')
51 ? fileURLToPath(params.uri)
52 : params.uri
53 } catch (error) {
54 const err = toError(error)
55 logError(err)
56 logForDebugging(
57 `Failed to convert URI to file path: ${params.uri}. Error: ${err.message}. Using original URI as fallback.`,
58 )
59 // Gracefully fallback to original URI - LSP servers may send malformed URIs
60 uri = params.uri
61 }
62
63 const diagnostics = params.diagnostics.map(
64 (diag: {
65 message: string
66 severity?: number
67 range: {
68 start: { line: number; character: number }
69 end: { line: number; character: number }
70 }
71 source?: string
72 code?: string | number
73 }) => ({
74 message: diag.message,
75 severity: mapLSPSeverity(diag.severity),
76 range: {
77 start: {
78 line: diag.range.start.line,
79 character: diag.range.start.character,
80 },
81 end: {
82 line: diag.range.end.line,
83 character: diag.range.end.character,
84 },
85 },
86 source: diag.source,
87 code:
88 diag.code !== undefined && diag.code !== null
89 ? String(diag.code)
90 : undefined,
91 }),
92 )
93
94 return [
95 {
96 uri,
97 diagnostics,
98 },
99 ]
100}

Callers 1

Calls 4

toErrorFunction · 0.85
logForDebuggingFunction · 0.85
mapLSPSeverityFunction · 0.85
logErrorFunction · 0.50

Tested by

no test coverage detected