Skip to content

Commit b7afc17

Browse files
committed
integrate with exsited utils
1 parent 357d703 commit b7afc17

File tree

1 file changed

+16
-5
lines changed

1 file changed

+16
-5
lines changed

packages/amazonq/src/lsp/chat/autoDebug/shared/diagnosticUtils.ts

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,19 +4,30 @@
44
*/
55

66
import * as vscode from 'vscode'
7+
import { toIdeDiagnostics } from 'aws-core-vscode/codewhisperer'
78

89
/**
910
* Maps VSCode DiagnosticSeverity to string representation
11+
* Reuses the existing toIdeDiagnostics logic but returns lowercase format expected by Problem interface
1012
*/
1113
export function mapDiagnosticSeverity(severity: vscode.DiagnosticSeverity): 'error' | 'warning' | 'info' | 'hint' {
12-
switch (severity) {
13-
case vscode.DiagnosticSeverity.Error:
14+
// Create a minimal diagnostic to use with toIdeDiagnostics
15+
const tempDiagnostic: vscode.Diagnostic = {
16+
range: new vscode.Range(0, 0, 0, 0),
17+
message: '',
18+
severity: severity,
19+
}
20+
21+
const ideDiagnostic = toIdeDiagnostics(tempDiagnostic)
22+
// Convert uppercase severity to lowercase format expected by Problem interface
23+
switch (ideDiagnostic.severity) {
24+
case 'ERROR':
1425
return 'error'
15-
case vscode.DiagnosticSeverity.Warning:
26+
case 'WARNING':
1627
return 'warning'
17-
case vscode.DiagnosticSeverity.Information:
28+
case 'INFORMATION':
1829
return 'info'
19-
case vscode.DiagnosticSeverity.Hint:
30+
case 'HINT':
2031
return 'hint'
2132
default:
2233
return 'error'

0 commit comments

Comments
 (0)