Skip to content

Commit

Permalink
NEW (Extension) @W-16442046@ Apex guru fixer logic
Browse files Browse the repository at this point in the history
  • Loading branch information
jag-j committed Aug 14, 2024
1 parent 5cb3946 commit 0e56474
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 3 deletions.
3 changes: 1 addition & 2 deletions src/lib/fixer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -110,15 +110,14 @@ export class _ApexGuruFixGenerator extends FixGenerator {
}

public generateApexGuruSuppresssion(document: vscode.TextDocument): vscode.CodeAction {
const existingCode = this.diagnostic.relatedInformation[0].message;
const suggestedCode = this.diagnostic.relatedInformation[1].message;

const action = new vscode.CodeAction(messages.fixer.fixWithApexGuruSuggestions, vscode.CodeActionKind.QuickFix);
action.diagnostics = [this.diagnostic];

const edit = new vscode.WorkspaceEdit();
const range = this.diagnostic.range; // Assuming the range is the location of the existing code in the document
edit.replace(document.uri, range, suggestedCode);
edit.insert(document.uri, range.start, suggestedCode + '\n');

// Assign the edit to the action
action.edit = edit;
Expand Down
2 changes: 1 addition & 1 deletion src/lib/messages.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ export const messages = {
fixer: {
supressOnLine: "Suppress violations on this line.",
supressOnClass: "Suppress violations on this class.",
fixWithApexGuruSuggestions: "***Fix violations with suggestions from Apex Guru***"
fixWithApexGuruSuggestions: "***Insert code suggestions from Apex Guru***"
},
diagnostics: {
messageGenerator: (severity: number, message: string) => `Sev${severity}: ${message}`,
Expand Down

0 comments on commit 0e56474

Please sign in to comment.