Skip to content

Commit

Permalink
Merge branch 'feature/q-lsp' into samgst/q-lsp-TDmessages
Browse files Browse the repository at this point in the history
  • Loading branch information
samgst-amazon authored Feb 28, 2025
2 parents c842495 + 6bfc0e5 commit 370ecc5
Show file tree
Hide file tree
Showing 14 changed files with 83 additions and 35 deletions.
20 changes: 20 additions & 0 deletions .changes/3.57.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{
"date" : "2025-02-28",
"version" : "3.57",
"entries" : [ {
"type" : "bugfix",
"description" : "Fix suggestion not visible in remote for 2024.3"
}, {
"type" : "bugfix",
"description" : "/test: update capability card text"
}, {
"type" : "bugfix",
"description" : "Amazon Q /doc: update workspace too large error message"
}, {
"type" : "bugfix",
"description" : "Amazon Q /doc: Fix uploading file method throwing incorrect workspace too large error message"
}, {
"type" : "bugfix",
"description" : "/transform: skip running tests locally when user chooses to do so"
} ]
}

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
# _3.57_ (2025-02-28)
- **(Bug Fix)** Fix suggestion not visible in remote for 2024.3
- **(Bug Fix)** /test: update capability card text
- **(Bug Fix)** Amazon Q /doc: update workspace too large error message
- **(Bug Fix)** Amazon Q /doc: Fix uploading file method throwing incorrect workspace too large error message
- **(Bug Fix)** /transform: skip running tests locally when user chooses to do so

# _3.56_ (2025-02-20)
- **(Feature)** Amazon Q /doc: support making changes to architecture diagrams

Expand Down
12 changes: 6 additions & 6 deletions buildspec/windowsTestsForAmazonQ.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,12 @@ env:
phases:
install:
commands:
- # force install java21 while we work throuh path issues
- |
$javaName = "C:\Program Files\Amazon Corretto" | ForEach-Object {
ls $_ | Where-Object {$_ -Like "jdk*"} | Sort-Object -Descending -Property Name | Select-Object -first 1 -expandproperty Name
}
$JAVA_HOME = "C:\Program Files\Amazon Corretto\$javaName"
# force install java21 while we work through path issues
- |
$javaName = "C:\Program Files\Amazon Corretto" | ForEach-Object {
ls $_ | Where-Object {$_ -Like "jdk*"} | Sort-Object -Descending -Property Name | Select-Object -first 1 -expandproperty Name
}
$JAVA_HOME = "C:\Program Files\Amazon Corretto\$javaName"
- |
if(-Not($Env:CODE_COV_TOKEN -eq $null)) {
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12;
Expand Down
2 changes: 1 addition & 1 deletion buildspec/windowsTestsForCore.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ env:
phases:
install:
commands:
# force install java21 while we work throuh path issues
# force install java21 while we work through path issues
- |
$javaName = "C:\Program Files\Amazon Corretto" | ForEach-Object {
ls $_ | Where-Object {$_ -Like "jdk*"} | Sort-Object -Descending -Property Name | Select-Object -first 1 -expandproperty Name
Expand Down
2 changes: 1 addition & 1 deletion buildspec/windowsTestsForToolkit.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ env:
phases:
install:
commands:
# force install java21 while we work throuh path issues
# force install java21 while we work through path issues
- |
$javaName = "C:\Program Files\Amazon Corretto" | ForEach-Object {
ls $_ | Where-Object {$_ -Like "jdk*"} | Sort-Object -Descending -Property Name | Select-Object -first 1 -expandproperty Name
Expand Down
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# SPDX-License-Identifier: Apache-2.0

# Toolkit Version
toolkitVersion=3.57-SNAPSHOT
toolkitVersion=3.58-SNAPSHOT

# Publish Settings
publishToken=
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ import software.aws.toolkits.core.utils.getLogger
import software.aws.toolkits.core.utils.info
import software.aws.toolkits.core.utils.warn
import software.aws.toolkits.jetbrains.isDeveloperMode
import software.aws.toolkits.jetbrains.services.amazonq.lsp.auth.DefaultAuthCredentialsService
import software.aws.toolkits.jetbrains.services.amazonq.lsp.encryption.JwtEncryptionManager
import software.aws.toolkits.jetbrains.services.amazonq.lsp.model.createExtendedClientMetadata
import software.aws.toolkits.jetbrains.services.amazonq.lsp.textdocument.TextDocumentServiceHandler
Expand Down Expand Up @@ -305,10 +306,8 @@ private class AmazonQServerInstance(private val project: Project, private val cs
languageServer.initialized(InitializedParams())
}

TextDocumentServiceHandler(
project,
this
)
DefaultAuthCredentialsService(project, encryptionManager, this)
TextDocumentServiceHandler(project, this)
}

override fun dispose() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,14 @@

package software.aws.toolkits.jetbrains.services.amazonq.lsp.auth

import com.intellij.openapi.Disposable
import com.intellij.openapi.project.Project
import org.eclipse.lsp4j.jsonrpc.messages.ResponseMessage
import software.aws.toolkits.core.TokenConnectionSettings
import software.aws.toolkits.jetbrains.core.credentials.ToolkitConnectionManager
import software.aws.toolkits.jetbrains.core.credentials.pinning.QConnection
import software.aws.toolkits.jetbrains.core.credentials.sso.bearer.BearerTokenProvider
import software.aws.toolkits.jetbrains.core.credentials.sso.bearer.BearerTokenProviderListener
import software.aws.toolkits.jetbrains.services.amazonq.lsp.AmazonQLspService
import software.aws.toolkits.jetbrains.services.amazonq.lsp.encryption.JwtEncryptionManager
import software.aws.toolkits.jetbrains.services.amazonq.lsp.model.aws.credentials.BearerCredentials
Expand All @@ -15,7 +21,31 @@ import java.util.concurrent.CompletableFuture
class DefaultAuthCredentialsService(
private val project: Project,
private val encryptionManager: JwtEncryptionManager,
) : AuthCredentialsService {
serverInstance: Disposable,
) : AuthCredentialsService,
BearerTokenProviderListener {
init {
project.messageBus.connect(serverInstance).subscribe(BearerTokenProviderListener.TOPIC, this)
}

override fun onChange(providerId: String, newScopes: List<String>?) {
val connection = ToolkitConnectionManager.getInstance(project)
.activeConnectionForFeature(QConnection.getInstance())
?: return

val provider = (connection.getConnectionSettings() as? TokenConnectionSettings)
?.tokenProvider
?.delegate as? BearerTokenProvider
?: return

provider.currentToken()?.accessToken?.let { token ->
updateTokenCredentials(token, false)
}
}

override fun invalidate(providerId: String) {
deleteTokenCredentials()
}

override fun updateTokenCredentials(accessToken: String, encrypted: Boolean): CompletableFuture<ResponseMessage> {
val token = if (encrypted) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,15 @@

package software.aws.toolkits.jetbrains.services.amazonq.lsp.auth

import com.intellij.openapi.Disposable
import com.intellij.openapi.components.serviceIfCreated
import com.intellij.openapi.project.Project
import com.intellij.util.messages.MessageBus
import com.intellij.util.messages.MessageBusConnection
import io.mockk.every
import io.mockk.just
import io.mockk.mockk
import io.mockk.runs
import io.mockk.verify
import org.eclipse.lsp4j.jsonrpc.messages.ResponseMessage
import org.junit.Before
Expand Down Expand Up @@ -42,7 +47,14 @@ class DefaultAuthCredentialsServiceTest {
func.invoke(mockLanguageServer)
}

sut = DefaultAuthCredentialsService(project, this.mockEncryptionManager)
// Mock message bus
val messageBus = mockk<MessageBus>()
every { project.messageBus } returns messageBus
val mockConnection = mockk<MessageBusConnection>()
every { messageBus.connect(any<Disposable>()) } returns mockConnection
every { mockConnection.subscribe(any(), any()) } just runs

sut = DefaultAuthCredentialsService(project, this.mockEncryptionManager, mockk())
}

@Test
Expand Down

0 comments on commit 370ecc5

Please sign in to comment.