@@ -66,6 +66,10 @@ import {
6666 ShowOpenDialogParams ,
6767 openFileDialogRequestType ,
6868 OpenFileDialogResult ,
69+ CheckDiagnosticsRequestType ,
70+ CheckDiagnosticsParams ,
71+ openWorkspaceFileRequestType ,
72+ OpenWorkspaceFileParams ,
6973} from '@aws/language-server-runtimes/protocol'
7074import { v4 as uuidv4 } from 'uuid'
7175import * as vscode from 'vscode'
@@ -559,6 +563,58 @@ export function registerMessageListeners(
559563
560564 registerHandlerWithResponseRouter ( openTabRequestType . method )
561565 registerHandlerWithResponseRouter ( getSerializedChatRequestType . method )
566+ // Register diagnostic check handler
567+ languageClient . onRequest ( CheckDiagnosticsRequestType . method , async ( params : CheckDiagnosticsParams ) => {
568+ const result : Record < string , any > = { }
569+
570+ for ( const [ filePath , diagnosticJson ] of Object . entries ( params . filePaths ) ) {
571+ try {
572+ const uri = vscode . Uri . file ( filePath )
573+ const diagnostics = vscode . languages . getDiagnostics ( uri )
574+
575+ if ( diagnostics && diagnostics . length > 0 ) {
576+ // Convert VSCode diagnostics to JSON format
577+ const diagnosticsJson = diagnostics . map ( ( diagnostic ) => ( {
578+ range : {
579+ start : {
580+ line : diagnostic . range . start . line ,
581+ character : diagnostic . range . start . character ,
582+ } ,
583+ end : { line : diagnostic . range . end . line , character : diagnostic . range . end . character } ,
584+ } ,
585+ severity : diagnostic . severity ,
586+ message : diagnostic . message ,
587+ source : diagnostic . source ,
588+ code : diagnostic . code ,
589+ } ) )
590+ result [ filePath ] = diagnosticsJson
591+ } else {
592+ // No diagnostics found, return the original or empty
593+ result [ filePath ] = diagnosticJson || [ ]
594+ }
595+ } catch ( error ) {
596+ languageClient . error ( `Failed to get diagnostics for ${ filePath } : ${ error } ` )
597+ result [ filePath ] = diagnosticJson || [ ]
598+ }
599+ }
600+ return { filePaths : result }
601+ } )
602+
603+ // Register openWorkspaceFile handler
604+ languageClient . onRequest ( openWorkspaceFileRequestType . method , async ( params : OpenWorkspaceFileParams ) => {
605+ try {
606+ const uri = vscode . Uri . file ( params . filePath )
607+ const doc = await vscode . workspace . openTextDocument ( uri )
608+ await vscode . window . showTextDocument ( doc , { preview : false } )
609+ if ( params . makeActive ) {
610+ await vscode . window . showTextDocument ( doc , { preview : false , preserveFocus : false } )
611+ }
612+ return { success : true }
613+ } catch ( error ) {
614+ languageClient . error ( `Failed to open workspace file ${ params . filePath } : ${ error } ` )
615+ return { success : false }
616+ }
617+ } )
562618
563619 languageClient . onRequest ( ShowSaveFileDialogRequestType . method , async ( params : ShowSaveFileDialogParams ) => {
564620 const filters : Record < string , string [ ] > = { }
0 commit comments