@@ -14,6 +14,9 @@ import {SfCli} from './lib/sf-cli';
14
14
15
15
import { Displayable , ProgressNotification , UxDisplay } from './lib/display' ;
16
16
import { DiagnosticManager , DiagnosticConvertible , DiagnosticManagerImpl } from './lib/diagnostics' ;
17
+ import { DiffCreateAction } from './lib/actions/diff-create-action' ;
18
+ import { DiffAcceptAction } from './lib/actions/diff-accept-action' ;
19
+ import { DiffRejectAction } from './lib/actions/diff-reject-action' ;
17
20
import { ScannerAction } from './lib/actions/scanner-action' ;
18
21
import { CliScannerV4Strategy } from './lib/scanner-strategies/v4-scanner' ;
19
22
import { CliScannerV5Strategy } from './lib/scanner-strategies/v5-scanner' ;
@@ -225,21 +228,31 @@ export async function activate(context: vscode.ExtensionContext): Promise<vscode
225
228
context . subscriptions . push ( documentSaveListener ) ;
226
229
227
230
telemetryService . sendExtensionActivationEvent ( extensionHrStart ) ;
228
- setupUnifiedDiff ( context , diagnosticManager ) ;
231
+ setupUnifiedDiff ( context , diagnosticManager , telemetryService ) ;
229
232
outputChannel . appendLine ( `Extension sfdx-code-analyzer-vscode activated.` ) ;
230
233
return Promise . resolve ( context ) ;
231
234
}
232
235
233
236
234
- function setupUnifiedDiff ( context : vscode . ExtensionContext , diagnosticManager : DiagnosticManager ) {
237
+ function setupUnifiedDiff ( context : vscode . ExtensionContext , diagnosticManager : DiagnosticManager , telemetryService : TelemetryService ) {
235
238
context . subscriptions . push (
236
239
vscode . commands . registerCommand ( Constants . UNIFIED_DIFF , async ( code : string , file ?: string ) => {
240
+ await ( new DiffCreateAction ( Constants . UNIFIED_DIFF , {
241
+ callback : ( code : string , file ?: string ) => VSCodeUnifiedDiff . singleton . unifiedDiff ( code , file ) ,
242
+ telemetryService
243
+ } ) ) . run ( code , file ) ;
237
244
await VSCodeUnifiedDiff . singleton . unifiedDiff ( code , file ) ;
238
245
} )
239
246
) ;
240
247
context . subscriptions . push (
241
248
vscode . commands . registerCommand ( CODEGENIE_UNIFIED_DIFF_ACCEPT , async ( hunk : DiffHunk ) => {
242
- await VSCodeUnifiedDiff . singleton . unifiedDiffAccept ( hunk ) ;
249
+ await ( new DiffAcceptAction ( CODEGENIE_UNIFIED_DIFF_ACCEPT , {
250
+ callback : async ( diffHunk : DiffHunk ) => {
251
+ await VSCodeUnifiedDiff . singleton . unifiedDiffAccept ( diffHunk ) ;
252
+ return diffHunk . lines . length ;
253
+ } ,
254
+ telemetryService
255
+ } ) ) . run ( hunk ) ;
243
256
// For accept & accept all, it is tricky to track the diagnostics and the changed lines as multiple fixes are requested.
244
257
// Hence, we save the file and rerun the scan instead.
245
258
await vscode . window . activeTextEditor . document . save ( ) ;
@@ -252,12 +265,18 @@ function setupUnifiedDiff(context: vscode.ExtensionContext, diagnosticManager: D
252
265
) ;
253
266
context . subscriptions . push (
254
267
vscode . commands . registerCommand ( CODEGENIE_UNIFIED_DIFF_REJECT , async ( hunk : DiffHunk ) => {
255
- await VSCodeUnifiedDiff . singleton . unifiedDiffReject ( hunk ) ;
268
+ await ( new DiffRejectAction ( CODEGENIE_UNIFIED_DIFF_REJECT , {
269
+ callback : ( diffHunk : DiffHunk ) => VSCodeUnifiedDiff . singleton . unifiedDiffReject ( diffHunk ) ,
270
+ telemetryService
271
+ } ) ) . run ( hunk ) ;
256
272
} )
257
273
) ;
258
274
context . subscriptions . push (
259
275
vscode . commands . registerCommand ( CODEGENIE_UNIFIED_DIFF_ACCEPT_ALL , async ( ) => {
260
- await VSCodeUnifiedDiff . singleton . unifiedDiffAcceptAll ( ) ;
276
+ await ( new DiffAcceptAction ( CODEGENIE_UNIFIED_DIFF_ACCEPT_ALL , {
277
+ callback : ( ) => VSCodeUnifiedDiff . singleton . unifiedDiffAcceptAll ( ) ,
278
+ telemetryService
279
+ } ) ) . run ( ) ;
261
280
await vscode . window . activeTextEditor . document . save ( ) ;
262
281
return _runAndDisplayScanner ( Constants . COMMAND_RUN_ON_ACTIVE_FILE , [ vscode . window . activeTextEditor . document . fileName ] , {
263
282
telemetryService,
@@ -268,7 +287,10 @@ function setupUnifiedDiff(context: vscode.ExtensionContext, diagnosticManager: D
268
287
) ;
269
288
context . subscriptions . push (
270
289
vscode . commands . registerCommand ( CODEGENIE_UNIFIED_DIFF_REJECT_ALL , async ( ) => {
271
- await VSCodeUnifiedDiff . singleton . unifiedDiffRejectAll ( ) ;
290
+ await ( new DiffRejectAction ( CODEGENIE_UNIFIED_DIFF_REJECT_ALL , {
291
+ callback : ( ) => VSCodeUnifiedDiff . singleton . unifiedDiffRejectAll ( ) ,
292
+ telemetryService
293
+ } ) ) . run ( ) ;
272
294
} )
273
295
) ;
274
296
VSCodeUnifiedDiff . singleton . activate ( context ) ;
@@ -498,7 +520,6 @@ export async function _runAndDisplayScanner(commandName: string, targets: string
498
520
} ) ;
499
521
} catch ( e ) {
500
522
const errMsg = e instanceof Error ? e . message : e as string ;
501
- console . log ( errMsg ) ;
502
523
telemetryService . sendException ( Constants . TELEM_FAILED_STATIC_ANALYSIS , errMsg , {
503
524
executedCommand : commandName ,
504
525
duration : ( Date . now ( ) - startTime ) . toString ( )
@@ -547,7 +568,6 @@ export async function _runAndDisplayDfa(context:vscode.ExtensionContext ,runInfo
547
568
} )
548
569
} catch ( e ) {
549
570
const errMsg = e instanceof Error ? e . message : e as string ;
550
- console . log ( errMsg ) ;
551
571
telemetryService . sendException ( Constants . TELEM_FAILED_DFA_ANALYSIS , errMsg , {
552
572
executedCommand : commandName ,
553
573
duration : ( Date . now ( ) - startTime ) . toString ( )
@@ -600,7 +620,6 @@ export async function _clearDiagnosticsForSelectedFiles(selections: vscode.Uri[]
600
620
} ) ;
601
621
} catch ( e ) {
602
622
const errMsg = e instanceof Error ? e . message : e as string ;
603
- console . log ( errMsg ) ;
604
623
telemetryService . sendException ( Constants . TELEM_FAILED_STATIC_ANALYSIS , errMsg , {
605
624
executedCommand : commandName ,
606
625
duration : ( Date . now ( ) - startTime ) . toString ( )
0 commit comments