55 ViewColumn ,
66 Uri ,
77 workspace ,
8+ extensions ,
9+ commands ,
810} from 'vscode' ;
911import * as path from 'path' ;
1012
@@ -14,6 +16,7 @@ import {
1416 FromRemoteQueriesMessage ,
1517 RemoteQueryDownloadAnalysisResultsMessage ,
1618 RemoteQueryDownloadAllAnalysesResultsMessage ,
19+ RemoteQueryViewAnalysisResultsMessage ,
1720} from '../pure/interface-types' ;
1821import { Logger } from '../logging' ;
1922import { getHtmlForWebview } from '../interface-utils' ;
@@ -199,6 +202,9 @@ export class RemoteQueriesInterfaceManager {
199202 case 'remoteQueryDownloadAllAnalysesResults' :
200203 await this . downloadAllAnalysesResults ( msg ) ;
201204 break ;
205+ case 'remoteQueryViewAnalysisResults' :
206+ await this . viewAnalysisResults ( msg ) ;
207+ break ;
202208 default :
203209 assertNever ( msg ) ;
204210 }
@@ -217,6 +223,28 @@ export class RemoteQueriesInterfaceManager {
217223 results => this . setAnalysisResults ( results ) ) ;
218224 }
219225
226+ private async viewAnalysisResults ( msg : RemoteQueryViewAnalysisResultsMessage ) : Promise < void > {
227+ const downloadLink = msg . analysisSummary . downloadLink ;
228+ const filePath = path . join ( tmpDir . name , downloadLink . id , downloadLink . innerFilePath || '' ) ;
229+
230+ const sarifViewerExtensionId = 'MS-SarifVSCode.sarif-viewer' ;
231+
232+ const sarifExt = extensions . getExtension ( sarifViewerExtensionId ) ;
233+ if ( ! sarifExt ) {
234+ // Ask the user if they want to install the extension to view the results.
235+ void commands . executeCommand ( 'workbench.extensions.installExtension' , sarifViewerExtensionId ) ;
236+ return ;
237+ }
238+
239+ if ( ! sarifExt . isActive ) {
240+ await sarifExt . activate ( ) ;
241+ }
242+
243+ await sarifExt . exports . openLogs ( [
244+ Uri . file ( filePath ) ,
245+ ] ) ;
246+ }
247+
220248 public async setAnalysisResults ( analysesResults : AnalysisResults [ ] ) : Promise < void > {
221249 if ( this . panel ?. active ) {
222250 await this . postMessage ( {
0 commit comments