Skip to content

Commit da7c3dc

Browse files
committed
detekt
1 parent a0a10f7 commit da7c3dc

File tree

3 files changed

+10
-33
lines changed

3 files changed

+10
-33
lines changed

plugins/amazonq/chat/jetbrains-community/src/software/aws/toolkits/jetbrains/services/amazonq/webview/BrowserConnector.kt

Lines changed: 6 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,6 @@ import software.aws.toolkits.jetbrains.services.amazonq.lsp.model.aws.chat.Promp
9191
import software.aws.toolkits.jetbrains.services.amazonq.lsp.model.aws.chat.PromptInputOptionChangeParams
9292
import software.aws.toolkits.jetbrains.services.amazonq.lsp.model.aws.chat.QuickChatActionRequest
9393
import software.aws.toolkits.jetbrains.services.amazonq.lsp.model.aws.chat.SEND_CHAT_COMMAND_PROMPT
94-
import software.aws.toolkits.jetbrains.services.amazonq.lsp.model.aws.chat.CHAT_ERROR_PARAMS
9594
import software.aws.toolkits.jetbrains.services.amazonq.lsp.model.aws.chat.STOP_CHAT_RESPONSE
9695
import software.aws.toolkits.jetbrains.services.amazonq.lsp.model.aws.chat.SendChatPromptRequest
9796
import software.aws.toolkits.jetbrains.services.amazonq.lsp.model.aws.chat.SourceLinkClickNotification
@@ -212,8 +211,6 @@ class BrowserConnector(
212211
}
213212
}
214213

215-
216-
217214
private fun handleFlareChatMessages(browser: Browser, node: JsonNode) {
218215
when (node.command) {
219216
SEND_CHAT_COMMAND_PROMPT -> {
@@ -285,21 +282,14 @@ class BrowserConnector(
285282
server.listConversations(requestFromUi.params)
286283
} ?: (CompletableFuture.failedFuture(IllegalStateException("LSP Server not running")))
287284

288-
result.whenComplete { response, error ->
289-
try {
290-
if (error != null) {
291-
throw error
292-
}
293-
val uiMessage = """
285+
result.whenComplete { response, _ ->
286+
val uiMessage = """
294287
{
295288
"command": "$CHAT_LIST_CONVERSATIONS",
296289
"params": ${Gson().toJson(response)}
297290
}
298291
""".trimIndent()
299-
browser.postChat(uiMessage)
300-
} catch (e: Exception) {
301-
LOG.error { "Failed to perform list conversation $e" }
302-
}
292+
browser.postChat(uiMessage)
303293
}
304294
}
305295
CHAT_CONVERSATION_CLICK -> {
@@ -308,21 +298,14 @@ class BrowserConnector(
308298
server.conversationClick(requestFromUi.params)
309299
} ?: (CompletableFuture.failedFuture(IllegalStateException("LSP Server not running")))
310300

311-
result.whenComplete { response, error ->
312-
try {
313-
if (error != null) {
314-
throw error
315-
}
316-
val uiMessage = """
301+
result.whenComplete { response, _ ->
302+
val uiMessage = """
317303
{
318304
"command": "$CHAT_CONVERSATION_CLICK",
319305
"params": ${Gson().toJson(response)}
320306
}
321307
""".trimIndent()
322-
browser.postChat(uiMessage)
323-
} catch (e: Exception) {
324-
LOG.error { "Failed to perform conversation click $e" }
325-
}
308+
browser.postChat(uiMessage)
326309
}
327310
}
328311
CHAT_FEEDBACK -> {
@@ -506,11 +489,9 @@ class BrowserConnector(
506489
LOG.error { "Failed to send chat message $e" }
507490
browser.postChat(chatCommunicationManager.getErrorUiMessage(tabId, e, partialResultToken))
508491
}
509-
510492
}
511493
}
512494

513-
514495
private fun cancelInflightRequests(tabId: String) {
515496
chatCommunicationManager.getInflightRequestForTab(tabId)?.let { request ->
516497
request.cancel(true)

plugins/amazonq/shared/jetbrains-community/src/software/aws/toolkits/jetbrains/services/amazonq/lsp/flareChat/ChatCommunicationManager.kt

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,18 +4,17 @@
44
package software.aws.toolkits.jetbrains.services.amazonq.lsp.flareChat
55

66
import com.google.gson.Gson
7-
import com.google.gson.JsonElement
87
import com.intellij.openapi.components.Service
98
import com.intellij.openapi.components.service
109
import com.intellij.openapi.project.Project
1110
import org.eclipse.lsp4j.ProgressParams
1211
import software.aws.toolkits.jetbrains.services.amazonq.lsp.AmazonQLspService
1312
import software.aws.toolkits.jetbrains.services.amazonq.lsp.flareChat.ProgressNotificationUtils.getObject
13+
import software.aws.toolkits.jetbrains.services.amazonq.lsp.model.aws.chat.CHAT_ERROR_PARAMS
1414
import software.aws.toolkits.jetbrains.services.amazonq.lsp.model.aws.chat.ErrorParams
1515
import software.aws.toolkits.jetbrains.services.amazonq.lsp.model.aws.chat.GetSerializedChatResult
1616
import software.aws.toolkits.jetbrains.services.amazonq.lsp.model.aws.chat.OpenTabResult
1717
import software.aws.toolkits.jetbrains.services.amazonq.lsp.model.aws.chat.SEND_CHAT_COMMAND_PROMPT
18-
import software.aws.toolkits.jetbrains.services.amazonq.lsp.model.aws.chat.CHAT_ERROR_PARAMS
1918
import java.util.UUID
2019
import java.util.concurrent.CompletableFuture
2120
import java.util.concurrent.ConcurrentHashMap
@@ -81,18 +80,17 @@ class ChatCommunicationManager {
8180
val errorMessage = "Details: ${exception.message}"
8281
val errorParams = Gson().toJson(ErrorParams(tabId, null, errorMessage, errorTitle)).toString()
8382
val isPartialResult = false
84-
val uiMessage = """
83+
val uiMessage = """
8584
{
8685
"command":"$CHAT_ERROR_PARAMS",
8786
"tabId": "$tabId",
8887
"params": $errorParams,
8988
"isPartialResult": $isPartialResult
9089
}
91-
""".trimIndent()
90+
""".trimIndent()
9291
return uiMessage
9392
}
9493

95-
9694
companion object {
9795
fun getInstance(project: Project) = project.service<ChatCommunicationManager>()
9896

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

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,9 @@
33

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

6-
import org.eclipse.lsp4j.TextDocumentIdentifier
7-
86
data class ErrorParams(
97
val tabId: String,
108
val triggerType: String?,
119
val message: String,
12-
val title: String
10+
val title: String,
1311
)

0 commit comments

Comments
 (0)