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(amazonq): enable code actions for awesome lightbulb #5620

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

32teeth
Copy link
Member

@32teeth 32teeth commented Sep 17, 2024

Problem

The Amazon Q VS Code extension requires a more streamlined approach to handle various CodeAction scenarios such as quick fixes, refactoring, and code explanation for better user experience.

Solution

codeActions

  1. Enhanced Code Actions: Introduced a CodeActions provider that dynamically generates and registers various actions (e.g., QuickFix, RefactorRewrite, ExplainCode) based on user selection.

Key Changes:

  • Refactored the activation logic in extension.ts to ensure proper extension initialization and handling for both the Node.js and web environments.
  • Created CodeActions class to provide code actions like explaining, refactoring, and fixing code with a dynamic selection mechanism.

License: I confirm that my contribution is made under the terms of the Apache 2.0 license.

@32teeth 32teeth requested a review from a team as a code owner September 17, 2024 21:55
Copy link

This pull request modifies files in src/ but no tests were added/updated. Confirm whether tests should be added or ensure the PR description explains why tests are not required.

Copy link

This pull request modifies a feature or fixes a bug, but it does not include a changelog entry. All pull requests that introduce new features or bug fixes must have a corresponding changelog item describing the changes.

@tverney
Copy link
Contributor

tverney commented Sep 18, 2024

This pull request modifies a feature or fixes a bug, but it does not include a changelog entry. All pull requests that introduce new features or bug fixes must have a corresponding changelog item describing the changes.

@32teeth the changelog here its added by a command. Check the CONTRIBUTING.md file, there is some set of commands that you can run and add that automatically.

@32teeth 32teeth force-pushed the andruseu/feature/lightbulb-menu branch from bfdd060 to cb6bd30 Compare September 18, 2024 14:36
@32teeth
Copy link
Member Author

32teeth commented Sep 18, 2024

This pull request modifies a feature or fixes a bug, but it does not include a changelog entry. All pull requests that introduce new features or bug fixes must have a corresponding changelog item describing the changes.

@32teeth the changelog here its added by a command. Check the CONTRIBUTING.md file, there is some set of commands that you can run and add that automatically.

Wicked, thanks for the heads up. Ran npm run newChange -w packages/amazonq to generate the json file 🙏


private suffix: string = 'using Amazon Q'

private commands: Map<string, { title: string; kind: vscode.CodeActionKind }> = new Map<
Copy link
Member

Choose a reason for hiding this comment

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

Can we create an abstract class (or a common class) CodeActions in shared and pass the following commands during Amazon Q activation. That way, we can share most of the logic in Toolkits and the Q Extension.

Copy link
Member Author

Choose a reason for hiding this comment

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

Good call. We can itemize as a fast follow

vscode.CodeActionKind.Empty,
]

private suffix: string = 'using Amazon Q'
Copy link
Member

Choose a reason for hiding this comment

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

This could be parametrized as well so that the code can be shared by Amazon Q and Toolkits.

Copy link
Member Author

Choose a reason for hiding this comment

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

Is there a preference as to where to add consts in the source code?

@@ -0,0 +1,4 @@
{
"type": "Feature",
"description": "feat(amazonq): enable code actions for awesome lightbulb"
Copy link
Contributor

Choose a reason for hiding this comment

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

Thanks for including a changelog. Please review the changelog guidelines. Is this the most meaningful thing we can say about this improvement for customers that will be interested in it?


import * as vscode from 'vscode'

export class CodeActions implements vscode.CodeActionProvider {
Copy link
Contributor

Choose a reason for hiding this comment

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

Notice that there is a app/chat/ for application code for AmazonQ.

If this CodeActions module is generally useful for all Q features, it could live in packages/amazonq/src/util/ or packages/amazonq/src/shared/. If it's for a particular Q feature, it should live in app/<feature>/.

Or it could live in app/ directly.

The main point is that the top-level src/ directory isn't the right place for most code files.

Copy link
Member Author

Choose a reason for hiding this comment

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

Good call. Will review

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.

4 participants