Skip to content

Commit dbb56ad

Browse files
authored
Merge branch 'feature/q-lsp-chat' into manodnyb/addContextCommands
2 parents 06f4a99 + 2c607f8 commit dbb56ad

File tree

28 files changed

+131
-77
lines changed

28 files changed

+131
-77
lines changed
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
"type" : "bugfix",
3+
"description" : "Amazon Q: Fix issue where context menu items are not available after re-opening projects or restarting the IDE"
4+
}
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
"type" : "bugfix",
3+
"description" : "Fix LinkageError while attempting to do Amazon Q inline suggestions in certain environments"
4+
}

buildSrc/src/main/kotlin/software/aws/toolkits/gradle/changelog/ChangeLog.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ enum class ChangeType(val sectionTitle: String) {
3939

4040
class Serializer : StdSerializer<ChangeType>(ChangeType::class.java) {
4141
override fun serialize(value: ChangeType, gen: JsonGenerator?, provider: SerializerProvider?) {
42-
gen?.writeString(value.name.toLowerCase())
42+
gen?.writeString(value.name.lowercase())
4343
}
4444
}
4545
}

buildSrc/src/main/kotlin/software/aws/toolkits/gradle/changelog/tasks/NewChange.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ open class NewChange : ChangeLogTask() {
6565
)
6666
}
6767

68-
private fun newFile(changeType: ChangeType) = nextReleaseDirectory.file("${changeType.name.toLowerCase()}-${UUID.randomUUID()}.json").get().asFile.apply {
68+
private fun newFile(changeType: ChangeType) = nextReleaseDirectory.file("${changeType.name.lowercase()}-${UUID.randomUUID()}.json").get().asFile.apply {
6969
parentFile?.mkdirs()
7070
createNewFile()
7171
}

buildSrc/src/main/kotlin/toolkit-intellij-subplugin.gradle.kts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -48,9 +48,11 @@ configurations {
4848

4949
// Exclude dependencies that ship with iDE
5050
exclude(group = "org.slf4j")
51-
// we want kotlinx-coroutines-debug and kotlinx-coroutines-test
52-
exclude(group = "org.jetbrains.kotlinx", "kotlinx-coroutines-core-jvm")
53-
exclude(group = "org.jetbrains.kotlinx", "kotlinx-coroutines-core")
51+
if (!name.startsWith("kotlinCompiler") && !name.startsWith("generateModels") && !name.startsWith("rdGen")) {
52+
// we want kotlinx-coroutines-debug and kotlinx-coroutines-test
53+
exclude(group = "org.jetbrains.kotlinx", "kotlinx-coroutines-core-jvm")
54+
exclude(group = "org.jetbrains.kotlinx", "kotlinx-coroutines-core")
55+
}
5456

5557
resolutionStrategy.eachDependency {
5658
if (requested.group == "org.jetbrains.kotlinx" && requested.name.startsWith("kotlinx-coroutines")) {

buildSrc/src/main/kotlin/toolkit-publishing-conventions.gradle.kts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,8 @@ configurations {
5454

5555
// Make sure we exclude stuff we either A) ships with IDE, B) we don't use to cut down on size
5656
runtimeClasspath {
57-
exclude(group = "org.slf4j")
57+
exclude(group = "com.google.code.gson")
58+
exclude(group = "org.slf4j", module = "slf4j-jdk14")
5859
exclude(group = "org.jetbrains.kotlin")
5960
exclude(group = "org.jetbrains.kotlinx")
6061
}

gradle/libs.versions.toml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,10 @@ junit4 = "4.13.2"
1919
junit5 = "5.11.0"
2020
# https://plugins.jetbrains.com/docs/intellij/kotlin.html#adding-kotlin-support
2121
# https://kotlinlang.org/docs/releases.html#release-details
22-
kotlin = "2.0.0"
22+
kotlin = "2.1.20"
2323
# set in <root>/settings.gradle.kts
2424
kotlinCoroutines = "1.8.0"
25+
lsp4j = "0.24.0"
2526
mockito = "5.12.0"
2627
mockitoKotlin = "5.4.0"
2728
mockk = "1.13.17"
@@ -105,6 +106,7 @@ kotlin-coroutinesTest = { module = "org.jetbrains.kotlinx:kotlinx-coroutines-tes
105106
kotlin-reflect = { module = "org.jetbrains.kotlin:kotlin-reflect", version.ref = "kotlin" }
106107
kotlin-stdLibJdk8 = { module = "org.jetbrains.kotlin:kotlin-stdlib-jdk8", version.ref = "kotlin" }
107108
kotlin-test = { module = "org.jetbrains.kotlin:kotlin-test-junit", version.ref = "kotlin" }
109+
lsp4j = { module = "org.eclipse.lsp4j:org.eclipse.lsp4j", version.ref = "lsp4j" }
108110
mockito-core = { module = "org.mockito:mockito-core", version.ref = "mockito" }
109111
mockito-junit-jupiter = { module = "org.mockito:mockito-junit-jupiter", version.ref = "mockito" }
110112
mockito-kotlin = { module = "org.mockito.kotlin:mockito-kotlin", version.ref = "mockitoKotlin" }

plugins/amazonq/build.gradle.kts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ dependencies {
3636
implementation(project(":plugin-amazonq:codewhisperer"))
3737
implementation(project(":plugin-amazonq:mynah-ui"))
3838
implementation(project(":plugin-amazonq:shared"))
39+
implementation(libs.lsp4j)
3940

4041
testImplementation(project(":plugin-core"))
4142
}

plugins/amazonq/codewhisperer/jetbrains-community/tst/software/aws/toolkits/jetbrains/services/codewhisperer/QRegionProfileManagerTest.kt

Lines changed: 27 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -191,20 +191,6 @@ class QRegionProfileManagerTest {
191191

192192
@Test
193193
fun `validateProfile should cross validate selected profile with latest API response for current project and remove it if its not longer accessible`() {
194-
val client = clientRule.create<CodeWhispererRuntimeClient>()
195-
val mockResponse: SdkIterable<Profile> = SdkIterable<Profile> {
196-
listOf(
197-
Profile.builder().profileName("foo").arn("foo-arn-v2").build(),
198-
Profile.builder().profileName("bar").arn("bar-arn").build(),
199-
).toMutableList().iterator()
200-
}
201-
val iterable: ListAvailableProfilesIterable = mock {
202-
on { it.profiles() } doReturn mockResponse
203-
}
204-
client.stub {
205-
onGeneric { listAvailableProfilesPaginator(any<Consumer<ListAvailableProfilesRequest.Builder>>()) } doReturn iterable
206-
}
207-
208194
val activeConn =
209195
ToolkitConnectionManager.getInstance(project).activeConnectionForFeature(QConnection.getInstance()) ?: fail("connection shouldn't be null")
210196
val anotherConn = authRule.createConnection(ManagedSsoProfile(ssoRegion = "us-east-1", startUrl = "anotherUrl", scopes = Q_SCOPES))
@@ -214,6 +200,15 @@ class QRegionProfileManagerTest {
214200
this.connectionIdToActiveProfile[activeConn.id] = fooProfile
215201
this.connectionIdToActiveProfile[anotherConn.id] = barProfile
216202
}
203+
resourceCache.addEntry(
204+
activeConn.getConnectionSettings(),
205+
QProfileResources.LIST_REGION_PROFILES,
206+
listOf(
207+
QRegionProfile("foo", "foo-arn-v2"),
208+
QRegionProfile("bar", "bar-arn"),
209+
)
210+
)
211+
217212
sut.loadState(state)
218213
assertThat(sut.activeProfile(project)).isEqualTo(fooProfile)
219214

@@ -222,6 +217,24 @@ class QRegionProfileManagerTest {
222217
assertThat(sut.state.connectionIdToActiveProfile).isEqualTo(mapOf(anotherConn.id to barProfile))
223218
}
224219

220+
@Test
221+
fun `validateProfile does not clear profile if profiles cannot be listed`() {
222+
val activeConn =
223+
ToolkitConnectionManager.getInstance(project).activeConnectionForFeature(QConnection.getInstance()) ?: fail("connection shouldn't be null")
224+
val anotherConn = authRule.createConnection(ManagedSsoProfile(ssoRegion = "us-east-1", startUrl = "anotherUrl", scopes = Q_SCOPES))
225+
val fooProfile = QRegionProfile("foo", "foo-arn")
226+
val barProfile = QRegionProfile("bar", "bar-arn")
227+
val state = QProfileState().apply {
228+
this.connectionIdToActiveProfile[activeConn.id] = fooProfile
229+
this.connectionIdToActiveProfile[anotherConn.id] = barProfile
230+
}
231+
sut.loadState(state)
232+
assertThat(sut.activeProfile(project)).isEqualTo(fooProfile)
233+
234+
sut.validateProfile(project)
235+
assertThat(sut.activeProfile(project)).isEqualTo(fooProfile)
236+
}
237+
225238
@Test
226239
fun `clientSettings should return the region Q profile specify`() {
227240
MockClientManager.useRealImplementations(disposableRule.disposable)

plugins/amazonq/codewhisperer/jetbrains-community/tstFixtures/software/aws/toolkits/jetbrains/services/codewhisperer/CodeWhispererTestUtil.kt

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -172,10 +172,10 @@ object CodeWhispererTestUtil {
172172
const val leftContext_success_Iac = "# Create an S3 Bucket named CodeWhisperer in CloudFormation"
173173
const val leftContext_failure_Iac = "Create an S3 Bucket named CodeWhisperer"
174174

175-
internal fun pythonResponseWithToken(token: String): GenerateCompletionsResponse =
175+
fun pythonResponseWithToken(token: String): GenerateCompletionsResponse =
176176
pythonResponse.toBuilder().nextToken(token).build()
177177

178-
internal fun generateMockCompletionDetail(content: String): Completion {
178+
fun generateMockCompletionDetail(content: String): Completion {
179179
val referenceInfo = getReferenceInfo()
180180
return Completion.builder().content(content)
181181
.references(
@@ -184,9 +184,9 @@ object CodeWhispererTestUtil {
184184
.build()
185185
}
186186

187-
internal fun getReferenceInfo() = testReferenceInfoPair[Random.nextInt(testReferenceInfoPair.size)]
187+
fun getReferenceInfo() = testReferenceInfoPair[Random.nextInt(testReferenceInfoPair.size)]
188188

189-
internal fun generateMockCompletionDetail(
189+
fun generateMockCompletionDetail(
190190
content: String,
191191
licenseName: String,
192192
repository: String,

0 commit comments

Comments
 (0)