Code references - CodeWhisperer

Code references

Viewing code references

CodeWhisperer learns, in part, from open-source projects. Sometimes, a suggestion it's giving you may be similar to a specific piece of training data.

With the reference log, you can view references to code recommendations that are similar to training data. You can also update and edit code recommendations suggested by CodeWhisperer.

This chapter explains how to view the code references.

Toolkit for Visual Studio

When CodeWhisperer suggests code that contains a reference in Toolkit for Visual Studio, the reference type appears in the suggestion description.

All accepted suggestions that contain references are captured in the reference log.

To access the reference log, choose the CodeWhisperer icon, then select Open Code Reference Log.

A list of accepted suggestions that contain references will appear. This list includes:

  • The location where the suggestion was accepted. Double clicking on this will take you to that location in your code.

  • The associated license

  • The referenced source code

  • The fragment of code attributed to the reference

AWS Toolkit for Visual Studio Code

To display the CodeWhisperer reference log in VS Code, use the following procedure.

  1. Make sure you are using the latest version of both VS Code and the AWS Toolkit.

  2. In VS Code, choose the AWS logo from the left side of the window.

  3. Open the Developer Tools dropdown menu.

  4. Choose Open Code Reference Log.

    The code reference log will appear in the lower right part of the VS Code window.


                            The CodeWhisperer code reference log in VS Code.
AWS Toolkit for JetBrains

To display the CodeWhisperer reference log in JetBrains, use the following procedure.

  1. Make sure you are using the latest version of both JetBrains and the AWS Toolkit.

  2. On the left side of the JetBrains window, choose the AWS logo.

  3. In the AWS Toolkit panel, select the Developer Tools tab.

  4. In the CodeWhisperer dropdown, choose Open Code Reference Log.


                            The CodeWhisperer code reference log in VS Code.
AWS Cloud 9

When you use CodeWhisperer with AWS Cloud 9, code references are on by default.

To turn them off, or to turn them back on later, use the following procedure.

  1. On the AWS Cloud 9 console, in the upper left corner, choose the AWS Cloud 9 logo.

  2. From the dropdown menu, choose Preferences.

    On the right side of the console, the Preferences tab will open.

  3. On the Preferences tab, under Project Settings, under Extensions, select AWS Toolkit.

  4. Select or deselect CodeWhisperer: Include Suggestions With Code References.


                            Toggling suggestions with code references in VS Code.
Lambda

CodeWhisperer in Lambda does not support code references. When you use CodeWhisperer with Lambda, any code suggestions with references are omitted.

SageMaker Studio

To display the CodeWhisperer reference log in SageMaker Studio, use the following procedure.

  1. At the bottom of the SageMaker Studio window, open the CodeWhisperer panel.

  2. Choose Open Code Reference Log.

JupyterLab

To display the CodeWhisperer reference log in JupyterLab, use the following procedure.

  1. At the bottom of the JupyterLab window, open the CodeWhisperer panel.

  2. Choose Open Code Reference Log.

AWS Glue Studio Notebook

To display the CodeWhisperer reference log in AWS Glue Studio Notebook, use the following procedure.

  1. At the bottom of the AWS Glue Studio Notebook window, open the CodeWhisperer panel.

  2. Choose Open Code Reference Log.

Turning code references off and on

With the reference log, you can view references to code recommendations. You can also update and edit code recommendations suggested by CodeWhisperer.

This section explains how to use the code reference options.

AWS Toolkit for Visual Studio Code

When you use CodeWhisperer with VS Code, code references are on by default.

To turn them off, or to turn them back on later, use the following procedures.

  1. Make sure you are using the latest version of both VS Code and the AWS Toolkit.

  2. In VS Code, choose the AWS logo from the left side of the window.

  3. Open the Developer Tools dropdown menu.

  4. Open the Developer Tools dropdown menu.

  5. Next to the CodeWhisperer option, choose the gear icon.

    On the side of the VS Code window, the Settings tab will open, with the options related to CodeWhisperer displayed.

  6. Select or deselect the box under Include Suggestions with Code References.


                            Opting out of suggestions with code references in VS
                                Code.
AWS Toolkit for JetBrains

When you use CodeWhisperer with JetBrains, code references are on by default.

To turn them off, or to turn them back on later, use the following procedures.

  1. Make sure you are using the latest version of both JetBrains and the AWS Toolkit.

  2. In IntelliJ, open Preferences.

  3. In the Preferences window, under Tools, under AWS, select CodeWhisperer.

  4. In the CodeWhisperer panel on the right, select or deselect the box labeled Include suggestions with code references.

AWS Cloud 9

When you use CodeWhisperer with AWS Cloud 9, code references are on by default.

To turn them off, or to turn them back on later, use the following procedure.

  1. On the AWS Cloud 9 console, in the upper left corner, choose the AWS Cloud 9 logo.

  2. From the dropdown menu, choose Preferences.

    On the right side of the console, the Preferences tab will open.

  3. On the Preferences tab, under Project Settings, under Extensions, select AWS Toolkit.

  4. Select or deselect CodeWhisperer: Include Suggestions With Code References.


                            Toggling suggestions with code references in VS Code.
Lambda

CodeWhisperer in Lambda does not support code references. When you use CodeWhisperer with Lambda, any code suggestions with references are omitted.

SageMaker Studio

When you use CodeWhisperer with SageMaker Studio, code references are on by default.

To turn them off, or to turn them back on later, use the following procedure.

  1. From the top of the SageMaker Studio window choose Settings.

  2. From the Settings dropdown, choose Advanced Settings Editor.

  3. In the Amazon CodeWhisperer dropdown, select or deselect the box next to Enable suggestions with code references.

JupyterLab

When you use CodeWhisperer with JupyterLab, code references are on by default.

To turn them off, or to turn them back on later, use the following procedure.

  1. From the top of the JupyterLab window choose Settings.

  2. From the Settings dropdown, choose Advanced Settings Editor.

  3. In the Amazon CodeWhisperer dropdown, select or deselect the box next to Enable suggestions with code references.

AWS Glue Studio Notebook
  1. From the bottom of the AWS Glue Studio Notebook window choose CodeWhisperer.

  2. From the pop-up menu, toggle the switch next to Code with references.

Note

Pausing code references will be valid only for the duration of the current AWS Glue Studio Notebook.

Opting out of code with references

In some cases, you can, at the enterprise level, opt out of receiving suggestions with references.

This section explains how to do so.

Toolkit for Visual Studio

You can toggle code references off and on in one of two ways:

  • Choose the CodeWhisperer icon at the edge of the window, then select Options...

  • Go to Tools -> AWS Toolkit, CodeWhisperer

Then change the toggle to True or False, depending on whether you want to include suggestions with references.

AWS Toolkit for Visual Studio Code

If you are an enterprise administrator, you can opt out of suggestions with code references for your entire organization. If you do this, individual developers in your organization will not be able to opt back in through the IDE. Those developers will be able to select and deselect the box discussed in the procedure above. But if you have opted out at the enterprise level, that individual action will have no effect.

To opt out of suggestions with references at the enterprise level, use the following procedure.

  1. On the main CodeWhisperer console page, choose Set up CodeWhisperer.

  2. On the setup page, under Suggestions deselect the box labeled Include suggestions with code references.

  3. At the bottom of the console window, choose Set up CodeWhisperer.

AWS Toolkit for JetBrains

If you are an enterprise administrator, you can opt out of suggestions with code references for your entire organization. If you do this, individual developers in your organization will not be able to opt back in through the IDE. Those developers will be able to select and deselect the box discussed in the procedure above. But if you have opted out at the enterprise level, that individual action will have no effect.

To opt out of suggestions with references at the enterprise level, use the following procedure.

  1. On the main CodeWhisperer console page, choose Set up CodeWhisperer.

  2. On the setup page, under Suggestions deselect the box labeled Include suggestions with code references.

  3. At the bottom of the console window, choose Set up CodeWhisperer.

AWS Cloud 9

CodeWhisperer in AWS Cloud 9 does not support opting out of code suggestions with references at the enterprise level.

To opt out at the individual developer level, see Toggling code references.

Lambda

CodeWhisperer in Lambda does not support code references. When you use CodeWhisperer with Lambda, any code suggestions with references are omitted.

SageMaker Studio

CodeWhisperer does not support opting out of code suggestions with references at the enterprise level in SageMaker Studio.

JupyterLab

CodeWhisperer does not support opting out of code suggestions with references at the enterprise level in JupyterLab.

AWS Glue Studio Notebook

CodeWhisperer does not support opting out of code suggestions with references in AWS Glue Studio Notebook.