From 2024a0a54a5e9774c43b8ddcad98cadaf4f8793f Mon Sep 17 00:00:00 2001 From: Andrew Yu Date: Tue, 2 Sep 2025 13:48:59 -0700 Subject: [PATCH 1/2] fix(amazonq): add IntelliSense trigger for JB --- .../service/CodeWhispererService.kt | 21 +++++++++++++++++++ .../service/CodeWhispererServiceNew.kt | 2 ++ .../InlineCompletionWithReferencesParams.kt | 3 +++ 3 files changed, 26 insertions(+) diff --git a/plugins/amazonq/codewhisperer/jetbrains-community/src/software/aws/toolkits/jetbrains/services/codewhisperer/service/CodeWhispererService.kt b/plugins/amazonq/codewhisperer/jetbrains-community/src/software/aws/toolkits/jetbrains/services/codewhisperer/service/CodeWhispererService.kt index 44e19c9cf7f..0b6e3e40ba2 100644 --- a/plugins/amazonq/codewhisperer/jetbrains-community/src/software/aws/toolkits/jetbrains/services/codewhisperer/service/CodeWhispererService.kt +++ b/plugins/amazonq/codewhisperer/jetbrains-community/src/software/aws/toolkits/jetbrains/services/codewhisperer/service/CodeWhispererService.kt @@ -24,8 +24,11 @@ import kotlinx.coroutines.Job import kotlinx.coroutines.future.await import kotlinx.coroutines.launch import kotlinx.coroutines.withContext +import org.eclipse.lsp4j.DidChangeTextDocumentParams import org.eclipse.lsp4j.Position +import org.eclipse.lsp4j.TextDocumentContentChangeEvent import org.eclipse.lsp4j.TextDocumentIdentifier +import org.eclipse.lsp4j.VersionedTextDocumentIdentifier import org.eclipse.lsp4j.jsonrpc.JsonRpcException import org.eclipse.lsp4j.jsonrpc.messages.Either import software.amazon.awssdk.core.exception.SdkServiceException @@ -520,6 +523,24 @@ class CodeWhispererService(private val cs: CoroutineScope) : Disposable { else -> InlineCompletionTriggerKind.Invoke } ), + documentChangeParams = + if (triggerTypeInfo.automatedTriggerType == CodeWhispererAutomatedTriggerType.IntelliSense()) { + DidChangeTextDocumentParams( + VersionedTextDocumentIdentifier(), + listOf( + TextDocumentContentChangeEvent( + null, + CodeWhispererAutomatedTriggerType.IntelliSense().toString() + ) + ), + ) + } else { + null + }, + openTabFilepaths = editor.project?.let { project -> + com.intellij.openapi.fileEditor.FileEditorManager.getInstance(project) + .openFiles.mapNotNull { toUriString(it) } + } ?: emptyList(), ).apply { textDocument = TextDocumentIdentifier(toUriString(editor.virtualFile)) position = Position( diff --git a/plugins/amazonq/codewhisperer/jetbrains-community/src/software/aws/toolkits/jetbrains/services/codewhisperer/service/CodeWhispererServiceNew.kt b/plugins/amazonq/codewhisperer/jetbrains-community/src/software/aws/toolkits/jetbrains/services/codewhisperer/service/CodeWhispererServiceNew.kt index 81713e2ce47..dadbeb2f8dc 100644 --- a/plugins/amazonq/codewhisperer/jetbrains-community/src/software/aws/toolkits/jetbrains/services/codewhisperer/service/CodeWhispererServiceNew.kt +++ b/plugins/amazonq/codewhisperer/jetbrains-community/src/software/aws/toolkits/jetbrains/services/codewhisperer/service/CodeWhispererServiceNew.kt @@ -569,6 +569,8 @@ class CodeWhispererServiceNew(private val cs: CoroutineScope) : Disposable { else -> InlineCompletionTriggerKind.Invoke } ), + documentChangeParams = null, + openTabFilepaths = null, ).apply { textDocument = TextDocumentIdentifier(toUriString(editor.virtualFile)) position = Position( diff --git a/plugins/amazonq/shared/jetbrains-community/src/software/aws/toolkits/jetbrains/services/amazonq/lsp/model/aws/textDocument/InlineCompletionWithReferencesParams.kt b/plugins/amazonq/shared/jetbrains-community/src/software/aws/toolkits/jetbrains/services/amazonq/lsp/model/aws/textDocument/InlineCompletionWithReferencesParams.kt index 6d639d480aa..5ee915b58fa 100644 --- a/plugins/amazonq/shared/jetbrains-community/src/software/aws/toolkits/jetbrains/services/amazonq/lsp/model/aws/textDocument/InlineCompletionWithReferencesParams.kt +++ b/plugins/amazonq/shared/jetbrains-community/src/software/aws/toolkits/jetbrains/services/amazonq/lsp/model/aws/textDocument/InlineCompletionWithReferencesParams.kt @@ -3,8 +3,11 @@ package software.aws.toolkits.jetbrains.services.amazonq.lsp.model.aws.textDocument +import org.eclipse.lsp4j.DidChangeTextDocumentParams import org.eclipse.lsp4j.TextDocumentPositionAndWorkDoneProgressAndPartialResultParams data class InlineCompletionWithReferencesParams( var context: InlineCompletionContext, + var documentChangeParams: DidChangeTextDocumentParams?, + var openTabFilepaths: List?, ) : TextDocumentPositionAndWorkDoneProgressAndPartialResultParams() From 39fce779caebffac193734f0443c4c413c56cf55 Mon Sep 17 00:00:00 2001 From: Andrew Yu Date: Tue, 2 Sep 2025 17:18:00 -0700 Subject: [PATCH 2/2] detekt --- .../services/codewhisperer/service/CodeWhispererService.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/amazonq/codewhisperer/jetbrains-community/src/software/aws/toolkits/jetbrains/services/codewhisperer/service/CodeWhispererService.kt b/plugins/amazonq/codewhisperer/jetbrains-community/src/software/aws/toolkits/jetbrains/services/codewhisperer/service/CodeWhispererService.kt index 0b6e3e40ba2..d4d264e4d13 100644 --- a/plugins/amazonq/codewhisperer/jetbrains-community/src/software/aws/toolkits/jetbrains/services/codewhisperer/service/CodeWhispererService.kt +++ b/plugins/amazonq/codewhisperer/jetbrains-community/src/software/aws/toolkits/jetbrains/services/codewhisperer/service/CodeWhispererService.kt @@ -540,7 +540,7 @@ class CodeWhispererService(private val cs: CoroutineScope) : Disposable { openTabFilepaths = editor.project?.let { project -> com.intellij.openapi.fileEditor.FileEditorManager.getInstance(project) .openFiles.mapNotNull { toUriString(it) } - } ?: emptyList(), + }.orEmpty(), ).apply { textDocument = TextDocumentIdentifier(toUriString(editor.virtualFile)) position = Position(