Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feat/ai/explain #568

Draft
wants to merge 12 commits into
base: main
Choose a base branch
from
Draft

Feat/ai/explain #568

wants to merge 12 commits into from

Conversation

BBerabi
Copy link
Contributor

@BBerabi BBerabi commented Dec 20, 2024

Description

Provide description of this PR and changes, if linked Jira ticket doesn't cover it in full.

Checklist

  • Tests added and all succeed
  • Linted
  • CHANGELOG.md updated
  • README.md updated, if user-facing

Screenshots / GIFs

Visuals that may help the reviewer. Please add screenshots for any UI change. GIFs are most welcome!

@bastiandoetsch bastiandoetsch marked this pull request as ready for review December 28, 2024 17:50
@bastiandoetsch bastiandoetsch requested a review from a team as a code owner December 28, 2024 17:50
@BBerabi BBerabi marked this pull request as draft January 16, 2025 08:50
@BBerabi BBerabi self-assigned this Jan 16, 2025
Comment on lines +312 to +333
const fileContent = readFileSync(filePath, 'utf8');

const derivationLineNumbers: Set<number> = new Set<number>();
for (const markerLocation of suggestion.markers!) {
for (const markerPos of markerLocation.pos) {
const lines = markerPos.rows;
for (const line of lines) {
derivationLineNumbers.add(line + 1);
}
}
markerLocation.pos;
}
console.log('derivation lines: ', ...derivationLineNumbers);

const derivationLines: string[] = [];
const fileLines: string[] = fileContent.split('\n');
for (const derivationLineNumber of derivationLineNumbers) {
derivationLines.push(fileLines.at(derivationLineNumber - 1)!);
}
let derivation = derivationLines.join(',');
derivation = derivation.replace(/\t/g, ' ');
console.log('derivation: ', derivation);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Dunno what derivation is, but probably should be done on the LS side. Should just pass the issueID and the fixID and let LS do all the work.

Comment on lines +350 to +364
this.logger.info('generating fix explanation');
const { suggestion, diff } = message.args;

let explanation: string = '';
explanation = await vscode.commands.executeCommand(
SNYK_CODE_GENERATE_AI_EXPLANATION,
/* derivation */ '',
suggestion.rule,
/* ruleMessage */ '',
diff,
);
console.log('vscode: got fix explanation: ', explanation);
void this.postSuggestMessage({ type: 'setFixExplanation', args: { explanation: explanation } });

break;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same here

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants