Skip to content

Commit 91ae00e

Browse files
committed
move InlineBm25Chunk to LspMessage.kt
1 parent f911b3d commit 91ae00e

File tree

4 files changed

+20
-19
lines changed

4 files changed

+20
-19
lines changed

plugins/amazonq/chat/jetbrains-community/tst/software/aws/toolkits/jetbrains/services/amazonq/workspace/context/ProjectContextProviderTest.kt

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ import org.mockito.kotlin.verify
3333
import org.mockito.kotlin.whenever
3434
import software.aws.toolkits.jetbrains.services.amazonq.project.EncoderServer
3535
import software.aws.toolkits.jetbrains.services.amazonq.project.IndexRequest
36+
import software.aws.toolkits.jetbrains.services.amazonq.project.IndexUpdateMode
3637
import software.aws.toolkits.jetbrains.services.amazonq.project.InlineBm25Chunk
3738
import software.aws.toolkits.jetbrains.services.amazonq.project.LspMessage
3839
import software.aws.toolkits.jetbrains.services.amazonq.project.ProjectContextProvider
@@ -188,8 +189,8 @@ class ProjectContextProviderTest {
188189

189190
@Test
190191
fun `updateIndex should send correct encrypted request to lsp`() {
191-
sut.updateIndex(listOf("foo.java"), ProjectContextProvider.IndexUpdateMode.UPDATE)
192-
val request = UpdateIndexRequest(listOf("foo.java"), ProjectContextProvider.IndexUpdateMode.UPDATE.value)
192+
sut.updateIndex(listOf("foo.java"), IndexUpdateMode.UPDATE)
193+
val request = UpdateIndexRequest(listOf("foo.java"), IndexUpdateMode.UPDATE.command)
193194
val requestJson = mapper.writeValueAsString(request)
194195

195196
assertThat(mapper.readTree(requestJson)).isEqualTo(mapper.readTree("""{ "filePaths": ["foo.java"], "mode": "update" }"""))

plugins/amazonq/shared/jetbrains-community/src/software/aws/toolkits/jetbrains/services/amazonq/project/InlineBm25Chunk.kt

Lines changed: 0 additions & 10 deletions
This file was deleted.

plugins/amazonq/shared/jetbrains-community/src/software/aws/toolkits/jetbrains/services/amazonq/project/LspMessage.kt

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,8 +59,20 @@ data class LspResponse(
5959
val responseBody: String,
6060
)
6161

62-
enum class IndexUpdateMode(val value: String) {
62+
enum class IndexUpdateMode(val command: String) {
6363
UPDATE("update"),
6464
REMOVE("remove"),
6565
ADD("add"),
6666
}
67+
68+
enum class IndexOption(val command: String) {
69+
ALL("all"),
70+
DEFAULT("default"),
71+
}
72+
73+
// TODO: unify with [software.aws.toolkits.jetbrains.services.codewhisperer.model.Chunk]
74+
data class InlineBm25Chunk(
75+
val content: String,
76+
val filePath: String,
77+
val score: Double,
78+
)

plugins/amazonq/shared/jetbrains-community/src/software/aws/toolkits/jetbrains/services/amazonq/project/ProjectContextProvider.kt

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@ class ProjectContextProvider(val project: Project, private val encoderServer: En
6161
val fileSize: Int,
6262
)
6363

64+
// TODO: move to LspMessage.kt
6465
data class Usage(
6566
@JsonIgnoreProperties(ignoreUnknown = true)
6667
@JsonProperty("memoryUsage")
@@ -69,6 +70,7 @@ class ProjectContextProvider(val project: Project, private val encoderServer: En
6970
val cpuUsage: Int? = null,
7071
)
7172

73+
// TODO: move to LspMessage.kt
7274
data class Chunk(
7375
@JsonIgnoreProperties(ignoreUnknown = true)
7476
@JsonProperty("filePath")
@@ -133,7 +135,7 @@ class ProjectContextProvider(val project: Project, private val encoderServer: En
133135
logger.debug { "time elapsed to collect project context files: ${duration}ms, collected ${filesResult.files.size} files" }
134136

135137
val indexOption = if (CodeWhispererSettings.getInstance().isProjectContextEnabled()) IndexOption.ALL else IndexOption.DEFAULT
136-
val encrypted = encryptRequest(IndexRequest(filesResult.files, projectRoot, indexOption, ""))
138+
val encrypted = encryptRequest(IndexRequest(filesResult.files, projectRoot, indexOption.command, ""))
137139
val response = sendMsgToLsp(LspMessage.Index, encrypted)
138140

139141
duration = (System.currentTimeMillis() - indexStartTime).toDouble()
@@ -185,7 +187,7 @@ class ProjectContextProvider(val project: Project, private val encoderServer: En
185187
}
186188

187189
fun updateIndex(filePaths: List<String>, mode: IndexUpdateMode) {
188-
val encrypted = encryptRequest(UpdateIndexRequest(filePaths, mode.value))
190+
val encrypted = encryptRequest(UpdateIndexRequest(filePaths, mode.command))
189191
sendMsgToLsp(LspMessage.UpdateIndex, encrypted)
190192
}
191193

@@ -329,9 +331,5 @@ class ProjectContextProvider(val project: Project, private val encoderServer: En
329331

330332
companion object {
331333
private val logger = getLogger<ProjectContextProvider>()
332-
private object IndexOption {
333-
const val ALL = "all"
334-
const val DEFAULT = "default"
335-
}
336334
}
337335
}

0 commit comments

Comments
 (0)