Skip to content

Commit ccfc0ff

Browse files
authored
update crossfile context code chunks number from 60 to 3000 (#3743)
1 parent 68dec10 commit ccfc0ff

File tree

2 files changed

+18
-7
lines changed

2 files changed

+18
-7
lines changed

jetbrains-core/src/software/aws/toolkits/jetbrains/services/codewhisperer/util/CodeWhispererConstants.kt

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,4 +75,13 @@ object CodeWhispererConstants {
7575
val Sigv4ClientRegion = Region.US_EAST_1
7676
val BearerClientRegion = Region.US_EAST_1
7777
}
78+
79+
object CrossFile {
80+
const val CHUNK_SIZE = 3000
81+
}
82+
83+
object Utg {
84+
const val UTG_SEGMENT_SIZE = 10200
85+
const val UTG_PREFIX = "UTG\n"
86+
}
7887
}

jetbrains-core/src/software/aws/toolkits/jetbrains/services/codewhisperer/util/CodeWhispererFileContextProvider.kt

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -162,15 +162,15 @@ class DefaultCodeWhispererFileContextProvider(private val project: Project) : Fi
162162
val relativePath = runReadAction { contentRootPathProvider.getPathToElement(project, file, null) ?: file.path }
163163
chunks.addAll(file.toCodeChunk(relativePath))
164164
hasUsed.add(file)
165-
if (chunks.size > CHUNK_SIZE) {
165+
if (chunks.size > CodeWhispererConstants.CrossFile.CHUNK_SIZE) {
166166
LOG.debug { "finish fetching 60 chunks in ${System.currentTimeMillis() - parseFilesStart} ms" }
167-
return chunks.take(CHUNK_SIZE)
167+
return chunks.take(CodeWhispererConstants.CrossFile.CHUNK_SIZE)
168168
}
169169
}
170170
}
171171

172172
LOG.debug { "finish fetching 60 chunks in ${System.currentTimeMillis() - parseFilesStart} ms" }
173-
return chunks.take(CHUNK_SIZE)
173+
return chunks.take(CodeWhispererConstants.CrossFile.CHUNK_SIZE)
174174
}
175175

176176
override fun isTestFile(psiFile: PsiFile) = when (psiFile.programmingLanguage()) {
@@ -232,7 +232,12 @@ class DefaultCodeWhispererFileContextProvider(private val project: Project) : Fi
232232
val relativePath = contentRootPathProvider.getPathToElement(project, file, null) ?: file.path
233233
listOf(
234234
Chunk(
235-
content = UTG_PREFIX + file.content().let { it.substring(0, minOf(it.length, UTG_SEGMENT_SIZE)) },
235+
content = CodeWhispererConstants.Utg.UTG_PREFIX + file.content().let {
236+
it.substring(
237+
0,
238+
minOf(it.length, CodeWhispererConstants.Utg.UTG_SEGMENT_SIZE)
239+
)
240+
},
236241
path = relativePath
237242
)
238243
)
@@ -241,8 +246,5 @@ class DefaultCodeWhispererFileContextProvider(private val project: Project) : Fi
241246

242247
companion object {
243248
private val LOG = getLogger<DefaultCodeWhispererFileContextProvider>()
244-
private const val CHUNK_SIZE = 60
245-
private const val UTG_SEGMENT_SIZE = 10200
246-
private const val UTG_PREFIX = "UTG\n"
247249
}
248250
}

0 commit comments

Comments
 (0)