Skip to content

Commit 77d9cab

Browse files
committed
detekt
1 parent 989a939 commit 77d9cab

File tree

3 files changed

+25
-21
lines changed

3 files changed

+25
-21
lines changed
Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// Copyright 2023 Amazon.com, Inc. or its affiliates. All Rights Reserved.
22
// SPDX-License-Identifier: Apache-2.0
3-
3+
@file:Suppress("BannedImports")
44
package software.aws.toolkits.jetbrains.services.cwc.commands
55

66
import com.google.gson.Gson
@@ -10,6 +10,7 @@ import kotlinx.coroutines.flow.asSharedFlow
1010
import kotlinx.coroutines.runBlocking
1111
import software.aws.toolkits.jetbrains.services.amazonq.lsp.flareChat.AsyncChatUiListener
1212
import software.aws.toolkits.jetbrains.services.amazonq.lsp.model.aws.chat.GenericCommandParams
13+
import software.aws.toolkits.jetbrains.services.amazonq.lsp.model.aws.chat.SendToPromptParams
1314
import software.aws.toolkits.jetbrains.services.amazonq.lsp.model.aws.chat.TriggerType
1415
import software.aws.toolkits.jetbrains.services.amazonq.messages.AmazonQMessage
1516
import software.aws.toolkits.jetbrains.services.cwc.editor.context.ActiveFileContextExtractor
@@ -25,26 +26,33 @@ class ActionRegistrar {
2526
if (command == EditorContextCommand.GenerateUnitTests) {
2627
// pre-existing old chat code path
2728
_messages.tryEmit(ContextMenuActionMessage(command, project))
28-
}
29-
else {
29+
} else {
3030
// new agentic chat route
3131
runBlocking {
3232
val contextExtractor = ActiveFileContextExtractor.create(fqnWebviewAdapter = null, project = project)
3333
val fileContext = contextExtractor.extractContextForTrigger(ExtractionTriggerType.ContextMenu)
3434
val codeSelection = "\n```\n${fileContext.focusAreaContext?.codeSelection?.trimIndent()?.trim()}\n```\n"
35-
36-
val params = GenericCommandParams(selection = codeSelection, triggerType = TriggerType.CONTEXT_MENU, genericCommand = command.name)
37-
38-
val uiMessage = """
35+
var uiMessage = ""
36+
if (command.verb != "sendToPrompt") {
37+
val params = GenericCommandParams(selection = codeSelection, triggerType = TriggerType.CONTEXT_MENU, genericCommand = command.name)
38+
uiMessage = """
3939
{
4040
"command": "genericCommand",
4141
"params": ${Gson().toJson(params)}
4242
}
4343
""".trimIndent()
44+
} else {
45+
val params = SendToPromptParams(selection = codeSelection, triggerType = TriggerType.CONTEXT_MENU)
46+
uiMessage = """
47+
{
48+
"command": "sendToPrompt",
49+
"params": ${Gson().toJson(params)}
50+
}
51+
""".trimIndent()
52+
}
4453
AsyncChatUiListener.notifyPartialMessageUpdate(uiMessage)
4554
}
4655
}
47-
4856
}
4957

5058
fun reportMessageClick(command: EditorContextCommand, issue: MutableMap<String, String>, project: Project) {
@@ -54,13 +62,5 @@ class ActionRegistrar {
5462
// provide singleton access
5563
companion object {
5664
val instance = ActionRegistrar()
57-
58-
/**
59-
* Computes the product of 10 * 10
60-
* @return The result of 10 * 10
61-
*/
62-
fun computeTenTimesTen(): Int {
63-
return 10 * 10
64-
}
6565
}
6666
}

plugins/amazonq/chat/jetbrains-community/src/software/aws/toolkits/jetbrains/services/cwc/commands/EditorContextCommand.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ enum class EditorContextCommand(
3131
actionId = "aws.amazonq.generateUnitTests",
3232
),
3333
SendToPrompt(
34-
verb = "SendToPrompt",
34+
verb = "sendToPrompt",
3535
actionId = "aws.amazonq.sendToPrompt",
3636
),
3737
ExplainCodeScanIssue(

plugins/amazonq/shared/jetbrains-community/src/software/aws/toolkits/jetbrains/services/amazonq/lsp/model/aws/chat/GenericCommandParams.kt

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,16 +3,20 @@
33

44
package software.aws.toolkits.jetbrains.services.amazonq.lsp.model.aws.chat
55

6-
7-
//https://github.com/aws/language-server-runtimes/blob/main/chat-client-ui-types/src/uiContracts.ts#L27
6+
// https://github.com/aws/language-server-runtimes/blob/main/chat-client-ui-types/src/uiContracts.ts#L27
87
enum class TriggerType(val value: String) {
98
HOTKEYS("hotkeys"),
109
CLICK("click"),
11-
CONTEXT_MENU("contextMenu")
10+
CONTEXT_MENU("contextMenu"),
1211
}
1312

1413
data class GenericCommandParams(
1514
val selection: String,
1615
val triggerType: TriggerType,
17-
val genericCommand: String
16+
val genericCommand: String,
17+
)
18+
19+
data class SendToPromptParams(
20+
val selection: String,
21+
val triggerType: TriggerType,
1822
)

0 commit comments

Comments
 (0)