-
Notifications
You must be signed in to change notification settings - Fork 272
feat(amazonq): Add command to generate unit tests for selected code #4869
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
Changes from 29 commits
fbe77d7
8c8701f
5596ce6
2476e8a
a200346
2673db8
2050c28
665a7c4
9a88b0f
b6e4e7b
b884109
edbde53
3cdb18e
4a206c1
a478c5a
930e706
334e8e1
ac85a6f
29e3613
edaecdb
54816fb
a8ba166
c25dbe5
c8ed616
673c6e1
d589b60
0d52a23
2408b8c
c07fee0
8b5f672
3c3d9f3
3124e9a
c9f1491
4808425
061fd25
9c83687
465b2c9
ba4329d
5317be3
2c4fe57
f3f324d
88fb53a
5abad70
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
// Copyright 2023 Amazon.com, Inc. or its affiliates. All Rights Reserved. | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
package software.aws.toolkits.jetbrains.services.cwc.commands | ||
|
||
import com.intellij.openapi.actionSystem.AnActionEvent | ||
import com.intellij.openapi.actionSystem.CommonDataKeys | ||
import software.aws.toolkits.jetbrains.core.credentials.AwsBearerTokenConnection | ||
import software.aws.toolkits.jetbrains.core.credentials.ToolkitConnectionManager | ||
import software.aws.toolkits.jetbrains.core.credentials.pinning.QConnection | ||
import java.security.MessageDigest | ||
import kotlin.text.Charsets.UTF_8 | ||
|
||
class TestCodeAction : CustomAction(EditorContextCommand.Test) { | ||
Check warning on line 14 in plugins/amazonq/chat/jetbrains-community/src/software/aws/toolkits/jetbrains/services/cwc/commands/TestCodeAction.kt
|
||
override fun update(e: AnActionEvent) { | ||
val project = e.getData(CommonDataKeys.PROJECT) ?: return | ||
val connection = ToolkitConnectionManager.getInstance(project).activeConnectionForFeature(QConnection.getInstance()) as? AwsBearerTokenConnection | ||
if (connection == null) { | ||
// Hide the action by default if no connection found. | ||
e.presentation.isEnabledAndVisible = false | ||
return | ||
} | ||
e.presentation.isEnabledAndVisible = connection.startUrl == "https://amzn.awsapps.com/start" | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -130,6 +130,8 @@ | |
var shouldAddIndexInProgressMessage: Boolean = false | ||
var shouldUseWorkspaceContext: Boolean = false | ||
val isDataCollectionGroup = CodeWhispererFeatureConfigService.getInstance().getIsDataCollectionEnabled() | ||
val startUrl = getStartUrl(context.project) | ||
|
||
if (prompt.contains("@workspace")) { | ||
if (CodeWhispererSettings.getInstance().isProjectContextEnabled()) { | ||
shouldUseWorkspaceContext = true | ||
|
@@ -151,7 +153,7 @@ | |
triggerId = triggerId, | ||
message = prompt, | ||
activeFileContext = contextExtractor.extractContextForTrigger(ExtractionTriggerType.ChatMessage), | ||
userIntent = intentRecognizer.getUserIntentFromPromptChatMessage(message.chatMessage), | ||
userIntent = intentRecognizer.getUserIntentFromPromptChatMessage(message.chatMessage, startUrl), | ||
TriggerType.Click, | ||
projectContextQueryResult = queryResult, | ||
shouldAddIndexInProgressMessage = shouldAddIndexInProgressMessage, | ||
|
@@ -332,7 +334,9 @@ | |
} | ||
|
||
// Create prompt | ||
val prompt = "${message.command} the following part of my code for me: $codeSelection" | ||
val prompt = if (EditorContextCommand.Test == message.command) | ||
"${message.command.verb} the following part of my code for me: $codeSelection" else | ||
"${message.command} the following part of my code for me: $codeSelection"; | ||
|
||
|
||
processPromptActions(prompt, message, triggerId, fileContext) | ||
} | ||
|
Uh oh!
There was an error while loading. Please reload this page.