Skip to content

Commit af8f3f1

Browse files
committed
POC: On Demand Remediation but still to impl the logic
1 parent 18101ab commit af8f3f1

File tree

1 file changed

+20
-21
lines changed

1 file changed

+20
-21
lines changed

packages/core/src/codewhisperer/commands/basicCommands.ts

Lines changed: 20 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -352,44 +352,43 @@ TODO:
352352
export const generateSecurityFix = Commands.declare(
353353
'aws.amazonq.generateSecurityFix',
354354
() => async (issue: CodeScanIssue, filePath: string, source: Component) => {
355-
/* Working
355+
/* Working */
356356
return vscode.window.withProgress(
357357
{
358358
location: vscode.ProgressLocation.Notification,
359359
// title: CodeWhispererConstants.runningSecurityScan,
360-
title: "Generating security fix...",
360+
title: 'Generating security fix...',
361361
cancellable: false,
362362
},
363363
async () => {
364-
const uri = vscode.Uri.file(filePath);
364+
const uri = vscode.Uri.file(filePath)
365365

366366
try {
367-
const originalDoc = await vscode.workspace.openTextDocument(uri);
368-
const originalCode = originalDoc.getText();
369-
370-
const originalTempUri = vscode.Uri.parse(`${uri.fsPath}`);
371-
const changedTempUri = vscode.Uri.parse(`untitled:changed_${uri.fsPath}`);
372-
373-
await vscode.workspace.openTextDocument(changedTempUri).then(async doc => {
374-
const edit = new vscode.WorkspaceEdit();
375-
edit.insert(changedTempUri, new vscode.Position(0, 0), originalCode.toUpperCase());
376-
const success = await vscode.workspace.applyEdit(edit)
377-
});
367+
const originalDoc = await vscode.workspace.openTextDocument(uri)
368+
const originalCode = originalDoc.getText()
369+
370+
const originalTempUri = vscode.Uri.parse(`${uri.fsPath}`)
371+
const changedTempUri = vscode.Uri.parse(`untitled:changed_${uri.fsPath}`)
372+
373+
await vscode.workspace.openTextDocument(changedTempUri).then(async (doc) => {
374+
const edit = new vscode.WorkspaceEdit()
375+
edit.insert(changedTempUri, new vscode.Position(0, 0), originalCode.toUpperCase())
376+
const success = await vscode.workspace.applyEdit(edit)
377+
})
378378
await vscode.commands.executeCommand(
379379
'vscode.diff',
380380
originalTempUri,
381381
changedTempUri,
382382
`Diff: ${uri.fsPath}`
383-
);
384-
385-
} catch (error) {
386-
vscode.window.showErrorMessage(`Failed to show diff: ${error.message}`);
387-
}
383+
)
384+
} catch (error) {
385+
vscode.window.showErrorMessage(`Failed to show diff: ${error.message}`)
386+
}
388387
}
389388
)
390389
// void vscode.window.showInformationMessage(`Generating security fix...`)
391-
*/
392390

391+
/*
393392
return vscode.window.withProgress(
394393
{
395394
location: vscode.ProgressLocation.Notification,
@@ -467,7 +466,7 @@ export const generateSecurityFix = Commands.declare(
467466
vscode.window.showErrorMessage(`Failed to show diff: ${error.message}`)
468467
}
469468
}
470-
)
469+
)*/
471470
}
472471
)
473472

0 commit comments

Comments
 (0)