Explain and update code with Amazon Q Developer - Amazon Q Developer

Explain and update code with Amazon Q Developer

Amazon Q Developer can explain and update specific lines of code in your integrated development environment (IDE). To get your code updated, ask Amazon Q to make changes to a given line or block of code, and it will generate new code that reflects the changes that you asked it to make. Then, you can insert the updated code directly into the file where the code originated.

You can choose from the following options:

  • Explain – Get your code explained in natural language.

  • Refactor – Improve code readability or efficiency, among other improvements.

  • Fix – Debug code.

  • Optimize – Enhance code performance.

  • Send to prompt – Send the highlighted code to the Amazon Q chat panel, and ask questions that you have about the code.

Send code to Amazon Q

To get your code explained or updated by Amazon Q, complete the following steps.

  1. Highlight a section of a code file in your IDE.

  2. Right-click your highlighted code to open a context window. Choose Send to Amazon Q, and then choose Explain, Refactor, Fix, Optimize, or Send to prompt.

    If you choose Send to prompt, Amazon Q copies the highlighted code to the chat panel, where you can enter questions that you have about the code.

  3. To replace the highlighted code with the newly generated code, you can copy the code or insert it directly into your file by choosing Insert code. Amazon Q replaces the original code with the updated code.