Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions buildSrc/settings.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -43,5 +43,11 @@ dependencyResolutionManagement {
includeGroupByRegex("org\\.jetbrains\\.intellij\\.platform.*")
}
}
maven {
url = uri("https://s01.oss.sonatype.org/content/repositories/snapshots/")
content {
includeGroupByRegex("org\\.mockito\\.kotlin")
}
}
}
}
4 changes: 2 additions & 2 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ detekt = "1.23.7"
diff-util = "4.12"
intellijExt = "1.1.8"
# match with <root>/settings.gradle.kts
intellijGradle = "2.3.0"
intellijGradle = "2.6.0"
intellijRemoteRobot = "0.11.22"
jackson = "2.17.2"
jacoco = "0.8.12"
Expand All @@ -24,7 +24,7 @@ kotlin = "2.1.20"
kotlinCoroutines = "1.8.0"
lsp4j = "0.24.0"
mockito = "5.12.0"
mockitoKotlin = "5.4.0"
mockitoKotlin = "5.4.1-SNAPSHOT"
mockk = "1.13.17"
nimbus-jose-jwt = "9.40"
node-gradle = "7.0.2"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,10 @@
import com.intellij.openapi.actionSystem.ActionUpdateThread
import com.intellij.openapi.actionSystem.AnActionEvent
import com.intellij.openapi.application.ApplicationManager
import com.intellij.openapi.progress.currentThreadCoroutineScope
import com.intellij.openapi.project.DumbAwareAction
import com.intellij.util.messages.Topic
import kotlinx.coroutines.launch
import software.aws.toolkits.jetbrains.services.amazonq.lsp.AmazonQLspService
import software.aws.toolkits.jetbrains.services.amazonq.lsp.flareChat.ChatCommunicationManager
import software.aws.toolkits.jetbrains.services.amazonq.lsp.model.aws.chat.CHAT_TAB_REMOVE
Expand All @@ -22,9 +24,11 @@

// Notify LSP server about all open tabs being removed
val chatManager = ChatCommunicationManager.getInstance(project)
chatManager.getAllTabIds().forEach { tabId ->
AmazonQLspService.executeIfRunning(project) { server ->
rawEndpoint.notify(CHAT_TAB_REMOVE, mapOf("tabId" to tabId))
currentThreadCoroutineScope().launch {

Check warning on line 27 in plugins/amazonq/chat/jetbrains-community/src/software/aws/toolkits/jetbrains/services/amazonq/QRefreshPanelAction.kt

View workflow job for this annotation

GitHub Actions / Qodana Community for JVM

Unstable API Usage

'currentThreadCoroutineScope()' is declared in unstable 'com.intellij.openapi.progress.CoroutinesKt' marked with @ApiStatus.Experimental

Check warning

Code scanning / QDJVMC

Unstable API Usage Warning

'currentThreadCoroutineScope()' is declared in unstable 'com.intellij.openapi.progress.CoroutinesKt' marked with @ApiStatus.Experimental
chatManager.getAllTabIds().forEach { tabId ->

Check warning on line 28 in plugins/amazonq/chat/jetbrains-community/src/software/aws/toolkits/jetbrains/services/amazonq/QRefreshPanelAction.kt

View check run for this annotation

Codecov / codecov/patch

plugins/amazonq/chat/jetbrains-community/src/software/aws/toolkits/jetbrains/services/amazonq/QRefreshPanelAction.kt#L27-L28

Added lines #L27 - L28 were not covered by tests
AmazonQLspService.executeAsyncIfRunning(project) {
rawEndpoint.notify(CHAT_TAB_REMOVE, mapOf("tabId" to tabId))
}

Check warning on line 31 in plugins/amazonq/chat/jetbrains-community/src/software/aws/toolkits/jetbrains/services/amazonq/QRefreshPanelAction.kt

View check run for this annotation

Codecov / codecov/patch

plugins/amazonq/chat/jetbrains-community/src/software/aws/toolkits/jetbrains/services/amazonq/QRefreshPanelAction.kt#L30-L31

Added lines #L30 - L31 were not covered by tests
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@
private val themeBrowserAdapter: ThemeBrowserAdapter = ThemeBrowserAdapter(),
private val project: Project,
) {
var uiReady = CompletableDeferred<Boolean>()
val uiReady = CompletableDeferred<Boolean>()

Check warning on line 119 in plugins/amazonq/chat/jetbrains-community/src/software/aws/toolkits/jetbrains/services/amazonq/webview/BrowserConnector.kt

View check run for this annotation

Codecov / codecov/patch

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

Added line #L119 was not covered by tests
private val chatCommunicationManager = ChatCommunicationManager.getInstance(project)
private val chatAsyncResultManager = ChatAsyncResultManager.getInstance(project)

Expand Down Expand Up @@ -216,7 +216,7 @@
}
}

private fun handleFlareChatMessages(browser: Browser, node: JsonNode) {
private suspend fun handleFlareChatMessages(browser: Browser, node: JsonNode) {
when (node.command) {
SEND_CHAT_COMMAND_PROMPT -> {
val requestFromUi = serializer.deserializeChatMessages<SendChatPromptRequest>(node)
Expand All @@ -238,7 +238,7 @@
chatCommunicationManager.registerPartialResultToken(partialResultToken)

var encryptionManager: JwtEncryptionManager? = null
val result = AmazonQLspService.executeIfRunning(project) { server ->
val result = AmazonQLspService.executeAsyncIfRunning(project) { server ->
encryptionManager = this.encryptionManager

val encryptedParams = EncryptedChatParams(this.encryptionManager.encrypt(chatParams), partialResultToken)
Expand All @@ -258,7 +258,7 @@
val partialResultToken = chatCommunicationManager.addPartialChatMessage(tabId)
chatCommunicationManager.registerPartialResultToken(partialResultToken)
var encryptionManager: JwtEncryptionManager? = null
val result = AmazonQLspService.executeIfRunning(project) { server ->
val result = AmazonQLspService.executeAsyncIfRunning(project) { server ->
encryptionManager = this.encryptionManager

val encryptedParams = EncryptedQuickActionChatParams(this.encryptionManager.encrypt(quickActionParams), partialResultToken)
Expand Down Expand Up @@ -613,7 +613,7 @@
}
}

private inline fun <reified Request, Response> handleChat(
private suspend inline fun <reified Request, Response> handleChat(
lspMethod: JsonRpcMethod<Request, Response>,
node: JsonNode,
crossinline serverAction: (params: Request, invokeService: () -> CompletableFuture<Response>) -> CompletableFuture<Response>,
Expand All @@ -624,7 +624,7 @@
serializer.deserializeChatMessages<Request>(node.params, lspMethod.params)
}

return AmazonQLspService.executeIfRunning(project) { _ ->
return AmazonQLspService.executeAsyncIfRunning(project) { _ ->
val invokeService = when (lspMethod) {
is JsonRpcNotification<Request> -> {
// notify is Unit
Expand All @@ -646,7 +646,7 @@
} ?: CompletableFuture.failedFuture<Response>(IllegalStateException("LSP Server not running"))
}

private inline fun <reified Request, Response> handleChat(
private suspend inline fun <reified Request, Response> handleChat(
lspMethod: JsonRpcMethod<Request, Response>,
node: JsonNode,
): CompletableFuture<Response> = handleChat(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ class FeatureDevControllerTest : FeatureDevTestBase() {
whenever(featureDevClient.createTaskAssistConversation()).thenReturn(exampleCreateTaskAssistConversationResponse)
whenever(featureDevClient.sendFeatureDevTelemetryEvent(any())).thenReturn(exampleSendTelemetryEventResponse)
whenever(chatSessionStorage.getSession(any(), any())).thenReturn(spySession)
doNothing().`when`(chatSessionStorage).deleteSession(any())
doNothing().whenever(chatSessionStorage).deleteSession(any())

mockkObject(AmazonqTelemetry)
every { AmazonqTelemetry.endChat(amazonqConversationId = any(), amazonqEndOfTheConversationLatency = any()) } just runs
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -187,11 +187,17 @@
CodeWhispererInvocationStatus.getInstance().setInvocationStart()
var nextToken: Either<String, Int>? = null
do {
val result = AmazonQLspService.executeIfRunning(requestContext.project) { server ->
val result = AmazonQLspService.executeAsyncIfRunning(requestContext.project) { server ->
val params = createInlineCompletionParams(requestContext.editor, requestContext.triggerTypeInfo, nextToken)
server.inlineCompletionWithReferences(params)
}
val completion = result?.await() ?: break
val completion = result?.await()
if (completion == null) {
// no result / not running
CodeWhispererInvocationStatus.getInstance().finishInvocation()
break

Check warning on line 198 in plugins/amazonq/codewhisperer/jetbrains-community/src/software/aws/toolkits/jetbrains/services/codewhisperer/service/CodeWhispererService.kt

View check run for this annotation

Codecov / codecov/patch

plugins/amazonq/codewhisperer/jetbrains-community/src/software/aws/toolkits/jetbrains/services/codewhisperer/service/CodeWhispererService.kt#L197-L198

Added lines #L197 - L198 were not covered by tests
}

nextToken = completion.partialResultToken
val endTime = System.nanoTime()
val latency = TimeUnit.NANOSECONDS.toMillis(endTime - startTime).toDouble()
Expand Down Expand Up @@ -426,7 +432,7 @@
CodeWhispererTelemetryService.getInstance().sendUserTriggerDecisionEvent(project, latencyContext, sessionId, recommendationContext)
}

fun getRequestContext(
suspend fun getRequestContext(
triggerTypeInfo: TriggerTypeInfo,
editor: Editor,
project: Project,
Expand Down Expand Up @@ -472,11 +478,11 @@
)
}

fun getWorkspaceIds(project: Project): CompletableFuture<LspServerConfigurations> {
suspend fun getWorkspaceIds(project: Project): CompletableFuture<LspServerConfigurations> {
val payload = GetConfigurationFromServerParams(
section = "aws.q.workspaceContext"
)
return AmazonQLspService.executeIfRunning(project) { server ->
return AmazonQLspService.executeAsyncIfRunning(project) { server ->
server.getConfigurationFromServer(payload)
} ?: (CompletableFuture.failedFuture(IllegalStateException("LSP Server not running")))
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ class CodeWhispererServiceNew(private val cs: CoroutineScope) : Disposable {
var requestCount = 0
var nextToken: Either<String, Int>? = null
do {
val result = AmazonQLspService.executeIfRunning(requestContext.project) { server ->
val result = AmazonQLspService.executeAsyncIfRunning(requestContext.project) { server ->
val params = createInlineCompletionParams(requestContext.editor, requestContext.triggerTypeInfo, nextToken)
server.inlineCompletionWithReferences(params)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import com.intellij.openapi.options.Configurable
import com.intellij.openapi.options.SearchableConfigurable
import com.intellij.openapi.options.ex.Settings
import com.intellij.openapi.progress.currentThreadCoroutineScope
import com.intellij.openapi.project.Project
import com.intellij.openapi.project.ProjectManager
import com.intellij.openapi.ui.emptyText
Expand All @@ -22,6 +23,8 @@
import com.intellij.ui.dsl.builder.panel
import com.intellij.util.concurrency.EdtExecutorService
import com.intellij.util.execution.ParametersListUtil
import kotlinx.coroutines.launch
import org.eclipse.lsp4j.DidChangeConfigurationParams
import software.aws.toolkits.jetbrains.core.credentials.ToolkitConnection
import software.aws.toolkits.jetbrains.core.credentials.ToolkitConnectionManagerListener
import software.aws.toolkits.jetbrains.services.amazonq.lsp.AmazonQLspService
Expand Down Expand Up @@ -310,7 +313,12 @@
if (project.isDisposed) {
return@forEach
}
AmazonQLspService.didChangeConfiguration(project)

currentThreadCoroutineScope().launch {

Check warning on line 317 in plugins/amazonq/codewhisperer/jetbrains-community/src/software/aws/toolkits/jetbrains/services/codewhisperer/settings/CodeWhispererConfigurable.kt

View workflow job for this annotation

GitHub Actions / Qodana Community for JVM

Unstable API Usage

'currentThreadCoroutineScope()' is declared in unstable 'com.intellij.openapi.progress.CoroutinesKt' marked with @ApiStatus.Experimental

Check warning on line 317 in plugins/amazonq/codewhisperer/jetbrains-community/src/software/aws/toolkits/jetbrains/services/codewhisperer/settings/CodeWhispererConfigurable.kt

View check run for this annotation

Codecov / codecov/patch

plugins/amazonq/codewhisperer/jetbrains-community/src/software/aws/toolkits/jetbrains/services/codewhisperer/settings/CodeWhispererConfigurable.kt#L317

Added line #L317 was not covered by tests

Check warning

Code scanning / QDJVMC

Unstable API Usage Warning

'currentThreadCoroutineScope()' is declared in unstable 'com.intellij.openapi.progress.CoroutinesKt' marked with @ApiStatus.Experimental
AmazonQLspService.executeAsyncIfRunning(project) { server ->
server.workspaceService.didChangeConfiguration(DidChangeConfigurationParams())
}
}

Check warning on line 321 in plugins/amazonq/codewhisperer/jetbrains-community/src/software/aws/toolkits/jetbrains/services/codewhisperer/settings/CodeWhispererConfigurable.kt

View check run for this annotation

Codecov / codecov/patch

plugins/amazonq/codewhisperer/jetbrains-community/src/software/aws/toolkits/jetbrains/services/codewhisperer/settings/CodeWhispererConfigurable.kt#L319-L321

Added lines #L319 - L321 were not covered by tests
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
import com.intellij.openapi.components.Service
import com.intellij.openapi.components.service
import com.intellij.openapi.project.Project
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.launch
import software.aws.toolkits.core.utils.debug
import software.aws.toolkits.core.utils.getLogger
import software.aws.toolkits.jetbrains.services.amazonq.lsp.AmazonQLspService
Expand Down Expand Up @@ -33,7 +35,7 @@
import java.time.Instant

@Service
class CodeWhispererTelemetryService {
class CodeWhispererTelemetryService(private val cs: CoroutineScope) {

Check warning on line 38 in plugins/amazonq/codewhisperer/jetbrains-community/src/software/aws/toolkits/jetbrains/services/codewhisperer/telemetry/CodeWhispererTelemetryService.kt

View check run for this annotation

Codecov / codecov/patch

plugins/amazonq/codewhisperer/jetbrains-community/src/software/aws/toolkits/jetbrains/services/codewhisperer/telemetry/CodeWhispererTelemetryService.kt#L38

Added line #L38 was not covered by tests
companion object {
fun getInstance(): CodeWhispererTelemetryService = service()
val LOG = getLogger<CodeWhispererTelemetryService>()
Expand All @@ -45,22 +47,24 @@
sessionId: String,
recommendationContext: RecommendationContext,
) {
AmazonQLspService.executeIfRunning(project) { server ->
val params = LogInlineCompletionSessionResultsParams(
sessionId = sessionId,
completionSessionResult = recommendationContext.details.associate {
it.itemId to InlineCompletionStates(
seen = it.hasSeen,
accepted = it.isAccepted,
discarded = it.isDiscarded
)
},
firstCompletionDisplayLatency = latencyContext.perceivedLatency,
totalSessionDisplayTime = CodeWhispererInvocationStatus.getInstance().completionShownTime?.let { Duration.between(it, Instant.now()) }
?.toMillis()?.toDouble(),
typeaheadLength = recommendationContext.userInput.length.toLong()
)
server.logInlineCompletionSessionResults(params)
cs.launch {

Check warning on line 50 in plugins/amazonq/codewhisperer/jetbrains-community/src/software/aws/toolkits/jetbrains/services/codewhisperer/telemetry/CodeWhispererTelemetryService.kt

View check run for this annotation

Codecov / codecov/patch

plugins/amazonq/codewhisperer/jetbrains-community/src/software/aws/toolkits/jetbrains/services/codewhisperer/telemetry/CodeWhispererTelemetryService.kt#L50

Added line #L50 was not covered by tests
AmazonQLspService.executeAsyncIfRunning(project) { server ->
val params = LogInlineCompletionSessionResultsParams(
sessionId = sessionId,
completionSessionResult = recommendationContext.details.associate {
it.itemId to InlineCompletionStates(
seen = it.hasSeen,
accepted = it.isAccepted,
discarded = it.isDiscarded
)

Check warning on line 59 in plugins/amazonq/codewhisperer/jetbrains-community/src/software/aws/toolkits/jetbrains/services/codewhisperer/telemetry/CodeWhispererTelemetryService.kt

View check run for this annotation

Codecov / codecov/patch

plugins/amazonq/codewhisperer/jetbrains-community/src/software/aws/toolkits/jetbrains/services/codewhisperer/telemetry/CodeWhispererTelemetryService.kt#L52-L59

Added lines #L52 - L59 were not covered by tests
},
firstCompletionDisplayLatency = latencyContext.perceivedLatency,

Check warning on line 61 in plugins/amazonq/codewhisperer/jetbrains-community/src/software/aws/toolkits/jetbrains/services/codewhisperer/telemetry/CodeWhispererTelemetryService.kt

View check run for this annotation

Codecov / codecov/patch

plugins/amazonq/codewhisperer/jetbrains-community/src/software/aws/toolkits/jetbrains/services/codewhisperer/telemetry/CodeWhispererTelemetryService.kt#L61

Added line #L61 was not covered by tests
totalSessionDisplayTime = CodeWhispererInvocationStatus.getInstance().completionShownTime?.let { Duration.between(it, Instant.now()) }
?.toMillis()?.toDouble(),
typeaheadLength = recommendationContext.userInput.length.toLong()

Check warning on line 64 in plugins/amazonq/codewhisperer/jetbrains-community/src/software/aws/toolkits/jetbrains/services/codewhisperer/telemetry/CodeWhispererTelemetryService.kt

View check run for this annotation

Codecov / codecov/patch

plugins/amazonq/codewhisperer/jetbrains-community/src/software/aws/toolkits/jetbrains/services/codewhisperer/telemetry/CodeWhispererTelemetryService.kt#L64

Added line #L64 was not covered by tests
)
server.logInlineCompletionSessionResults(params)
}

Check warning on line 67 in plugins/amazonq/codewhisperer/jetbrains-community/src/software/aws/toolkits/jetbrains/services/codewhisperer/telemetry/CodeWhispererTelemetryService.kt

View check run for this annotation

Codecov / codecov/patch

plugins/amazonq/codewhisperer/jetbrains-community/src/software/aws/toolkits/jetbrains/services/codewhisperer/telemetry/CodeWhispererTelemetryService.kt#L66-L67

Added lines #L66 - L67 were not covered by tests
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
import com.intellij.openapi.components.Service
import com.intellij.openapi.components.service
import com.intellij.openapi.project.Project
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.launch
import software.aws.toolkits.core.utils.debug
import software.aws.toolkits.core.utils.getLogger
import software.aws.toolkits.jetbrains.services.amazonq.lsp.AmazonQLspService
Expand All @@ -29,7 +31,7 @@
import java.time.Instant

@Service
class CodeWhispererTelemetryServiceNew {
class CodeWhispererTelemetryServiceNew(private val cs: CoroutineScope) {

Check warning on line 34 in plugins/amazonq/codewhisperer/jetbrains-community/src/software/aws/toolkits/jetbrains/services/codewhisperer/telemetry/CodeWhispererTelemetryServiceNew.kt

View check run for this annotation

Codecov / codecov/patch

plugins/amazonq/codewhisperer/jetbrains-community/src/software/aws/toolkits/jetbrains/services/codewhisperer/telemetry/CodeWhispererTelemetryServiceNew.kt#L34

Added line #L34 was not covered by tests

companion object {
fun getInstance(): CodeWhispererTelemetryServiceNew = service()
Expand Down Expand Up @@ -109,24 +111,26 @@
}

fun sendUserTriggerDecisionEvent(project: Project, latencyContext: LatencyContext) {
AmazonQLspService.executeIfRunning(project) { server ->
CodeWhispererServiceNew.getInstance().getAllPaginationSessions().forEach { jobId, state ->
if (state == null) return@forEach
val params = LogInlineCompletionSessionResultsParams(
sessionId = state.responseContext.sessionId,
completionSessionResult = state.recommendationContext.details.associate {
it.itemId to InlineCompletionStates(
seen = it.hasSeen,
accepted = it.isAccepted,
discarded = it.isDiscarded
)
},
firstCompletionDisplayLatency = latencyContext.perceivedLatency,
totalSessionDisplayTime = CodeWhispererInvocationStatus.getInstance().completionShownTime?.let { Duration.between(it, Instant.now()) }
?.toMillis()?.toDouble(),
typeaheadLength = state.recommendationContext.userInput.length.toLong()
)
server.logInlineCompletionSessionResults(params)
cs.launch {

Check warning on line 114 in plugins/amazonq/codewhisperer/jetbrains-community/src/software/aws/toolkits/jetbrains/services/codewhisperer/telemetry/CodeWhispererTelemetryServiceNew.kt

View check run for this annotation

Codecov / codecov/patch

plugins/amazonq/codewhisperer/jetbrains-community/src/software/aws/toolkits/jetbrains/services/codewhisperer/telemetry/CodeWhispererTelemetryServiceNew.kt#L114

Added line #L114 was not covered by tests
AmazonQLspService.executeAsyncIfRunning(project) { server ->
CodeWhispererServiceNew.getInstance().getAllPaginationSessions().forEach { jobId, state ->

Check warning on line 116 in plugins/amazonq/codewhisperer/jetbrains-community/src/software/aws/toolkits/jetbrains/services/codewhisperer/telemetry/CodeWhispererTelemetryServiceNew.kt

View check run for this annotation

Codecov / codecov/patch

plugins/amazonq/codewhisperer/jetbrains-community/src/software/aws/toolkits/jetbrains/services/codewhisperer/telemetry/CodeWhispererTelemetryServiceNew.kt#L116

Added line #L116 was not covered by tests
if (state == null) return@forEach
val params = LogInlineCompletionSessionResultsParams(
sessionId = state.responseContext.sessionId,
completionSessionResult = state.recommendationContext.details.associate {
it.itemId to InlineCompletionStates(
seen = it.hasSeen,
accepted = it.isAccepted,
discarded = it.isDiscarded
)

Check warning on line 125 in plugins/amazonq/codewhisperer/jetbrains-community/src/software/aws/toolkits/jetbrains/services/codewhisperer/telemetry/CodeWhispererTelemetryServiceNew.kt

View check run for this annotation

Codecov / codecov/patch

plugins/amazonq/codewhisperer/jetbrains-community/src/software/aws/toolkits/jetbrains/services/codewhisperer/telemetry/CodeWhispererTelemetryServiceNew.kt#L118-L125

Added lines #L118 - L125 were not covered by tests
},
firstCompletionDisplayLatency = latencyContext.perceivedLatency,

Check warning on line 127 in plugins/amazonq/codewhisperer/jetbrains-community/src/software/aws/toolkits/jetbrains/services/codewhisperer/telemetry/CodeWhispererTelemetryServiceNew.kt

View check run for this annotation

Codecov / codecov/patch

plugins/amazonq/codewhisperer/jetbrains-community/src/software/aws/toolkits/jetbrains/services/codewhisperer/telemetry/CodeWhispererTelemetryServiceNew.kt#L127

Added line #L127 was not covered by tests
totalSessionDisplayTime = CodeWhispererInvocationStatus.getInstance().completionShownTime?.let { Duration.between(it, Instant.now()) }
?.toMillis()?.toDouble(),
typeaheadLength = state.recommendationContext.userInput.length.toLong()

Check warning on line 130 in plugins/amazonq/codewhisperer/jetbrains-community/src/software/aws/toolkits/jetbrains/services/codewhisperer/telemetry/CodeWhispererTelemetryServiceNew.kt

View check run for this annotation

Codecov / codecov/patch

plugins/amazonq/codewhisperer/jetbrains-community/src/software/aws/toolkits/jetbrains/services/codewhisperer/telemetry/CodeWhispererTelemetryServiceNew.kt#L130

Added line #L130 was not covered by tests
)
server.logInlineCompletionSessionResults(params)
}

Check warning on line 133 in plugins/amazonq/codewhisperer/jetbrains-community/src/software/aws/toolkits/jetbrains/services/codewhisperer/telemetry/CodeWhispererTelemetryServiceNew.kt

View check run for this annotation

Codecov / codecov/patch

plugins/amazonq/codewhisperer/jetbrains-community/src/software/aws/toolkits/jetbrains/services/codewhisperer/telemetry/CodeWhispererTelemetryServiceNew.kt#L132-L133

Added lines #L132 - L133 were not covered by tests
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import org.mockito.kotlin.any
import org.mockito.kotlin.argumentCaptor
import org.mockito.kotlin.doNothing
import org.mockito.kotlin.eq
import org.mockito.kotlin.whenever
import software.aws.toolkits.jetbrains.services.amazonq.QConstants
import software.aws.toolkits.jetbrains.services.codewhisperer.actions.CodeWhispererLearnMoreAction
import software.aws.toolkits.jetbrains.services.codewhisperer.actions.CodeWhispererShowSettingsAction
Expand Down Expand Up @@ -78,7 +79,7 @@ class CodeWhispererActionTest : CodeWhispererTestBase() {
@Test
fun `CodeWhispererShowSettingsAction actionPerformed should show settings dialog`() {
val settingsSpy = spy(ShowSettingsUtil.getInstance())
doNothing().`when`(settingsSpy).showSettingsDialog(any(), any<Class<out Configurable>>())
doNothing().whenever(settingsSpy).showSettingsDialog(any(), any<Class<out Configurable>>())
ApplicationManager.getApplication().replaceService(ShowSettingsUtil::class.java, settingsSpy, disposableRule.disposable)
val action = CodeWhispererShowSettingsAction()
runInEdtAndWait {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import com.intellij.ui.dsl.builder.components.DslLabel
import org.assertj.core.api.Assertions.assertThat
import org.junit.Test
import org.mockito.kotlin.doNothing
import org.mockito.kotlin.whenever
import software.aws.toolkits.jetbrains.core.credentials.ToolkitConnectionManagerListener
import software.aws.toolkits.jetbrains.services.codewhisperer.settings.CodeWhispererConfigurable
import software.aws.toolkits.resources.message
Expand All @@ -19,9 +20,9 @@ class CodeWhispererConfigurableTest : CodeWhispererTestBase() {

@Test
fun `test CodeWhisperer configurable`() {
doNothing().`when`(codeScanManager).buildCodeScanUI()
doNothing().`when`(codeScanManager).showCodeScanUI()
doNothing().`when`(codeScanManager).removeCodeScanUI()
doNothing().whenever(codeScanManager).buildCodeScanUI()
doNothing().whenever(codeScanManager).showCodeScanUI()
doNothing().whenever(codeScanManager).removeCodeScanUI()
val configurable = CodeWhispererConfigurable(projectRule.project)

// A workaround to initialize disposable in the DslConfigurableBase since somehow the disposable is
Expand Down
Loading
Loading