@@ -21,6 +21,7 @@ import { LLMAnalysisReportPanel } from './llmAnalysisReportPanel';
2121// eslint-disable-next-line @typescript-eslint/no-require-imports
2222import CliTable3 = require( 'cli-table3' ) ;
2323import { Language , Parser , Query } from 'web-tree-sitter' ;
24+ import { AbstractDiagnosticsPipeline } from './diagnosticsPipeline' ;
2425
2526export let outputChannelDep : DepOutputChannel ;
2627
@@ -311,10 +312,16 @@ export async function activate(context: vscode.ExtensionContext) {
311312
312313 const showVulnerabilityFoundPrompt = async ( msg : string , filePath : vscode . Uri ) => {
313314 const fileName = path . basename ( filePath . fsPath ) ;
314- const selection = await vscode . window . showWarningMessage ( `${ msg } ` , PromptText . FULL_STACK_PROMPT_TEXT ) ;
315+ const selection = await vscode . window . showWarningMessage ( `${ msg } ` , PromptText . FULL_STACK_PROMPT_TEXT as string , PromptText . IGNORE_FILE ) ;
315316 if ( selection === PromptText . FULL_STACK_PROMPT_TEXT ) {
316317 record ( context , TelemetryActions . vulnerabilityReportPopupOpened , { manifest : fileName , fileName : fileName } ) ;
317318 vscode . commands . executeCommand ( commands . STACK_ANALYSIS_COMMAND , filePath . fsPath ) ;
319+ } else if ( selection === PromptText . IGNORE_FILE ) {
320+ outputChannelDep . info ( `Added "${ filePath . fsPath } " to workspace exclude list` ) ;
321+ await globalConfig . addFileToExcludeList ( filePath . fsPath ) ;
322+ AbstractDiagnosticsPipeline . diagnosticsCollection . delete ( filePath ) ;
323+ clearCodeActionsMap ( filePath ) ;
324+ // TODO: need to clear status bar
318325 } else {
319326 record ( context , TelemetryActions . vulnerabilityReportPopupIgnored , { manifest : fileName , fileName : fileName } ) ;
320327 }
@@ -334,12 +341,19 @@ export async function activate(context: vscode.ExtensionContext) {
334341 }
335342 } ) ;
336343
337- notifications . on ( 'caError' , ( errorData : CANotificationData ) => {
344+ notifications . on ( 'caError' , async ( errorData : CANotificationData ) => {
338345 const notification = new CANotification ( errorData ) ;
339346 caStatusBarProvider . setError ( ) ;
340347
341348 // Since CA is an automated feature, only warning message will be shown on failure
342- vscode . window . showWarningMessage ( `RHDA error while analyzing ${ errorData . uri . fsPath } : ${ notification . errorMsg ( ) } ` ) ;
349+ const selection = await vscode . window . showWarningMessage ( `RHDA error while analyzing ${ errorData . uri . fsPath } : ${ notification . errorMsg ( ) } ` , PromptText . IGNORE_FILE ) ;
350+ if ( selection === PromptText . IGNORE_FILE ) {
351+ outputChannelDep . info ( `Added "${ errorData . uri . fsPath } " to workspace exclude list` ) ;
352+ await globalConfig . addFileToExcludeList ( errorData . uri . fsPath ) ;
353+ AbstractDiagnosticsPipeline . diagnosticsCollection . delete ( errorData . uri ) ;
354+ clearCodeActionsMap ( errorData . uri ) ;
355+ // TODO: need to clear status bar
356+ }
343357
344358 // Record telemetry event
345359 record ( context , TelemetryActions . componentAnalysisFailed , { manifest : path . basename ( notification . origin ( ) . fsPath ) , fileName : path . basename ( notification . origin ( ) . fsPath ) , error : notification . errorMsg ( ) } ) ;
@@ -362,6 +376,7 @@ export async function activate(context: vscode.ExtensionContext) {
362376
363377 vscode . workspace . onDidChangeConfiguration ( ( ) => {
364378 globalConfig . loadData ( ) ;
379+ outputChannelDep . debug ( `configuration updated` ) ;
365380 } ) ;
366381}
367382
@@ -424,8 +439,11 @@ function showRHRepositoryRecommendationNotification() {
424439 * @param context - The extension context.
425440 */
426441function registerStackAnalysisCommands ( context : vscode . ExtensionContext ) {
427-
428- const invokeFullStackReport = async ( filePath : string ) => {
442+ const recordAndInvoke = async ( origin : string , uri : vscode . Uri ) => {
443+ // TODO: vscode.window.activeTextEditor may be null
444+ const fileUri = uri || vscode . window . activeTextEditor ! . document . uri ;
445+ const filePath = fileUri . fsPath ;
446+ record ( context , origin , { manifest : path . basename ( filePath ) , fileName : path . basename ( filePath ) } ) ;
429447 const fileName = path . basename ( filePath ) ;
430448 try {
431449 const metrics = await generateRHDAReport ( context , filePath , outputChannelDep ) ;
@@ -443,14 +461,6 @@ function registerStackAnalysisCommands(context: vscode.ExtensionContext) {
443461 }
444462 } ;
445463
446- const recordAndInvoke = ( origin : string , uri : vscode . Uri ) => {
447- // TODO: vscode.window.activeTextEditor may be null
448- const fileUri = uri || vscode . window . activeTextEditor ! . document . uri ;
449- const filePath = fileUri . fsPath ;
450- record ( context , origin , { manifest : path . basename ( filePath ) , fileName : path . basename ( filePath ) } ) ;
451- invokeFullStackReport ( filePath ) ;
452- } ;
453-
454464 const registerCommand = ( cmd : string , action : TelemetryActions ) => {
455465 return vscode . commands . registerCommand ( cmd , recordAndInvoke . bind ( null , action ) ) ;
456466 } ;
0 commit comments