Overview of the CodeWhisperer for AWS Cloud9 - AWS Cloud9

Overview of the CodeWhisperer for AWS Cloud9

This overview contains a list of CodeWhisperer user actions and common ways for you to utilize CodeWhisperer while coding in AWS Cloud9.

User actions

When you're coding in AWS Cloud9, these user actions are associated with the CodeWhisperer.

Action Keyboard shortcut

Manually trigger CodeWhisperer

MacOS: Option + C

Windows: Alt + C

Linux: Alt + C

Accept a recommendation

Tab, enter, or click.

Reject a recommendation

ESC, backspace, or keep typing and the recommendation will disapperar as soon as there is a character mismatch.

Use cases

Here are common ways for you to utilize CodeWhisperer while working in AWS Cloud9 projects.

Example: Single-line code completion

When you start typing out single lines of code, CodeWhisperer makes suggestions based on your current and previous inputs.

In the example below, in Java, a user enters the string public into an existing class.

Based on the input, CodeWhisperer generates a suggestion for the signature of the main method.


                        An example of the single-line completion feature.

Example: Block completion

Block completion is used to complete your if/for/while/try code blocks.

In the example below, in Java, a user enters the signature of an if statement. The body of the statement is a suggestion from CodeWhisperer.


                        An example of the block completion feature.

Example: Full function generation from a comment

CodeWhisperer can generate an entire function based on a comment that you've written. As you finish your comment CodeWhisperer will suggest a function signature. If you accept the suggestion, CodeWhisperer automatically advances your cursor to the next part of the function and makes a suggestion. Even if you enter an additional comment or line of code in between suggestions, CodeWhisperer will refactor based on your input.

The following list contains examples of how CodeWhisperer makes suggestions and advances you through the entire process of creating a function.

  1. In the example below, in Java, a user inputs a comment. CodeWhisperer suggests a function signature.

    After the user accepts that suggestion, CodeWhisperer suggests a function body.

    
                                An example of a function generated from a comment.
  2. In the image below, a user inputs a comment in the body of the function prior to accepting a suggestion from CodeWhisperer. On the following line, CodeWhisperer generates a suggestion based on the comment.

    
                                An example of a function generated from a comment inside an existing block of code.

Example: Single-line comment completion

In the example below, in Java, the user starts to input a comment, and CodeWhisperer generates a suggestion to complete the comment.


                        An example of comment completion.

Example: Docstring and Javadoc completion

The following example is adapted from an example on the Oracle website.

In the example below, in Java, the user enters a docstring. CodeWhisperer suggests a function to process the docstring.


                        An example of code completion based on a Javadoc.

Code reference tracking

In the event that the code generation is sufficiently similar to an example in the training data, CodeWhisperer can provide a reference to that code, so that you can more easily find and review the similar code, decide whether to use the code in your project, and attribute and license the code as you see fit.

Supported programming languages

CodeWhisperer supports the following languages:

  • Python

  • Java

  • JavaScript