Skip to content

Commit 167408f

Browse files
committed
fix(amazonq): use the new DiagnosticInfo interface
1 parent 062e153 commit 167408f

File tree

1 file changed

+9
-5
lines changed

1 file changed

+9
-5
lines changed

packages/amazonq/src/lsp/chat/messages.ts

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@ import {
6868
OpenFileDialogResult,
6969
CheckDiagnosticsRequestType,
7070
CheckDiagnosticsParams,
71+
DiagnosticInfo,
7172
openWorkspaceFileRequestType,
7273
OpenWorkspaceFileParams,
7374
} from '@aws/language-server-runtimes/protocol'
@@ -565,16 +566,16 @@ export function registerMessageListeners(
565566
registerHandlerWithResponseRouter(getSerializedChatRequestType.method)
566567
// Register diagnostic check handler
567568
languageClient.onRequest(CheckDiagnosticsRequestType.method, async (params: CheckDiagnosticsParams) => {
568-
const result: Record<string, any> = {}
569+
const result: Record<string, DiagnosticInfo[]> = {}
569570

570-
for (const [filePath, diagnosticJson] of Object.entries(params.filePaths)) {
571+
for (const [filePath, diagnosticJson] of Object.entries(params.filePath)) {
571572
try {
572573
const uri = vscode.Uri.file(filePath)
573574
const diagnostics = vscode.languages.getDiagnostics(uri)
574575

575576
if (diagnostics && diagnostics.length > 0) {
576577
// Convert VSCode diagnostics to JSON format
577-
const diagnosticsJson = diagnostics.map((diagnostic) => ({
578+
const diagnosticsJson: DiagnosticInfo[] = diagnostics.map((diagnostic) => ({
578579
range: {
579580
start: {
580581
line: diagnostic.range.start.line,
@@ -585,7 +586,10 @@ export function registerMessageListeners(
585586
severity: diagnostic.severity,
586587
message: diagnostic.message,
587588
source: diagnostic.source,
588-
code: diagnostic.code,
589+
code:
590+
typeof diagnostic.code === 'object' && diagnostic.code !== null
591+
? diagnostic.code.value
592+
: diagnostic.code,
589593
}))
590594
result[filePath] = diagnosticsJson
591595
} else {
@@ -597,7 +601,7 @@ export function registerMessageListeners(
597601
result[filePath] = diagnosticJson || []
598602
}
599603
}
600-
return { filePaths: result }
604+
return { filePath: result }
601605
})
602606

603607
// Register openWorkspaceFile handler

0 commit comments

Comments
 (0)