Skip to content

Commit 1d33071

Browse files
rliandrewyuqWill-ShaoHuaabhikuhikarzixlin7
committed
CodeWhisperer re:Invent 2022
https://aws.amazon.com/codewhisperer Co-authored-by: Andrew Yu <[email protected]> Co-authored-by: Will Lo <[email protected]> Co-authored-by: Abhilash Kuhikar <[email protected]> Co-authored-by: Zoe Lin <[email protected]> Co-authored-by: Richard Li <[email protected]>
1 parent b1a1b4d commit 1d33071

File tree

119 files changed

+5829
-1642
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

119 files changed

+5829
-1642
lines changed
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
"type" : "feature",
3+
"description" : "Amazon CodeWhisperer now supports JavaScript for Security Scan to catch security vulnerabilities."
4+
}
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
"type" : "feature",
3+
"description" : "Amazon CodeWhisperer recommendations are more context aware. We are removing the overlaps from CodeWhisperer suggestions specifically when the cursor is inside a code block."
4+
}
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
"type" : "feature",
3+
"description" : "Amazon CodeWhisperer now supports TypeScript and C# programming languages."
4+
}
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
"type" : "feature",
3+
"description" : "Amazon CodeWhisperer is now available as a supported feature and no longer an experimental feature."
4+
}
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
"type" : "feature",
3+
"description" : "Amazon CodeWhisperer now adds new access methods with AWS Builder ID and AWS IAM Identity Center to enable and get started."
4+
}

core/src/software/aws/toolkits/core/credentials/ToolkitCredentialsProvider.kt

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ package software.aws.toolkits.core.credentials
55

66
import software.amazon.awssdk.auth.credentials.AwsCredentialsProvider
77
import software.amazon.awssdk.auth.token.credentials.SdkTokenProvider
8+
import software.aws.toolkits.resources.message
89

910
enum class CredentialType {
1011
StaticProfile,
@@ -88,7 +89,7 @@ interface ToolkitAuthenticationProvider {
8889

8990
class ToolkitCredentialsProvider(
9091
val identifier: CredentialIdentifier,
91-
delegate: AwsCredentialsProvider
92+
val delegate: AwsCredentialsProvider
9293
) : ToolkitAuthenticationProvider, AwsCredentialsProvider by delegate {
9394
override val id: String = identifier.id
9495
override val displayName = identifier.displayName
@@ -114,10 +115,20 @@ interface ToolkitBearerTokenProviderDelegate : SdkTokenProvider, ToolkitAuthenti
114115

115116
class ToolkitBearerTokenProvider(val delegate: ToolkitBearerTokenProviderDelegate) : SdkTokenProvider by delegate, ToolkitAuthenticationProvider by delegate {
116117
companion object {
117-
fun identifier(startUrl: String) = "sso;$startUrl"
118-
fun displayName(startUrl: String) = "SSO ($startUrl)"
118+
fun ssoIdentifier(startUrl: String) = "sso;$startUrl"
119+
120+
// TODO: For AWS Builder ID, we only have startUrl for now instead of each users' metadata data i.e. Email address
121+
fun ssoDisplayName(startUrl: String) = if (startUrl == SONO_URL) {
122+
message("aws_builder_id.service_name")
123+
} else {
124+
message("iam_identity_center.service_name", extractOrgID(startUrl))
125+
}
119126

120127
fun diskSessionIdentifier(profileName: String) = "diskSessionProfile;$profileName"
121128
fun diskSessionDisplayName(profileName: String) = "IAM Identity Center Session ($profileName)"
122129
}
123130
}
131+
132+
private const val SONO_URL = "https://view.awsapps.com/start"
133+
134+
private fun extractOrgID(startUrl: String) = startUrl.removePrefix("https://").removeSuffix(".awsapps.com/start")

gradle/libs.versions.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
[versions]
22
apacheCommons = "2.8.0"
33
assertJ = "3.20.2" # Upgrading leads to SAM errors: https://youtrack.jetbrains.com/issue/KT-17765
4-
awsSdk = "2.17.289"
4+
awsSdk = "2.17.292"
55
commonmark = "0.17.1"
66
detekt = "1.21.0"
77
intellijGradle = "1.10.0-SNAPSHOT"
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
## Using Amazon CodeWhisperer
2+
3+
CodeWhisperer uses machine learning to generate code suggestions from the existing code and comments in your IDE.
4+
Supported languages include: **Java, Python, JavaScript, C# and TypeScript**.
5+
6+
---
7+
8+
### Navigating with the tab and arrow keys
9+
10+
As you enter your code, CodeWhisperer will offer inline code suggestions. Use **TAB to accept** a suggestion.
11+
CodeWhisperer may provide multiple suggestions to choose from. Use **[left arrow] and [right arrow] to navigate**
12+
between suggestions.
13+
14+
If you don’t like the suggestions you see, keep typing (or hit ESC). The suggestions will disappear, and
15+
CodeWhisperer will generate new ones at a later point based on the additional context.
16+
17+
<img src="example.gif" style="max-height:400px;" alt="example">
18+
19+
---
20+
21+
### Requesting suggestions manually
22+
23+
You can request suggestions at any time. Use **Option-C** on Mac or **ALT-C** on Windows. After you receive
24+
suggestions, use TAB to accept and arrow keys to navigate.
25+
26+
---
27+
28+
### Getting the best recommendations
29+
30+
For best results, follow these practices.
31+
* Give CodeWhisperer something to work with. The more code your file contains, the more context CodeWhisperer
32+
has for generating recommendations.
33+
* Write descriptive comments. “Function to upload a file to S3” will get better results than “Upload a file”.
34+
* Specify the libraries you prefer by using import statements.
35+
* Use descriptive names for variable and functions. A function called “upload_file_to_S3” will get better results
36+
than a function called “file_upload”.
37+
* Break down complex tasks into simpler tasks.
38+
39+
---
40+
41+
### Further reading
42+
43+
To learn more about working with CodeWhisperer and JetBrains, see [Amazon CodeWhisperer
44+
for JetBrains and the AWS Toolkit](https://docs.aws.amazon.com/toolkit-for-jetbrains/latest/userguide/codewhisperer.html).
45+
46+
---
47+
48+
### Providing feedback
49+
50+
CodeWhisperer is in preview. Let us know what you think by sharing feedback (using the AWS Toolkit feedback button)
51+
or by reaching out to [[email protected]](mailto:[email protected]).

jetbrains-core/assets/example.gif

706 KB
Loading

jetbrains-core/build.gradle.kts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,18 @@ tasks.jar {
5050
}
5151
}
5252

53+
val codewhispererReadmeAssets = tasks.register<Sync>("codewhispererReadmeAssets") {
54+
from("${project.projectDir}/assets")
55+
into("$buildDir/assets")
56+
}
57+
58+
tasks.prepareSandbox {
59+
dependsOn(codewhispererReadmeAssets)
60+
from(codewhispererReadmeAssets) {
61+
into("aws-toolkit-jetbrains/assets")
62+
}
63+
}
64+
5365
tasks.testJar {
5466
// classpath.index is a duplicated
5567
duplicatesStrategy = DuplicatesStrategy.INCLUDE

0 commit comments

Comments
 (0)