Skip to content

Commit 260ff6f

Browse files
Merge master into feature/q-transform-staging
2 parents 14ab116 + e6d9b50 commit 260ff6f

File tree

3 files changed

+27
-12
lines changed

3 files changed

+27
-12
lines changed
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
"type": "Feature",
3+
"description": "Update cross file context config for Q inline suggestion"
4+
}

packages/core/src/codewhisperer/models/constants.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -591,9 +591,9 @@ export const codeFixAppliedFailedMessage = 'Failed to apply suggested code fix.'
591591
export const runSecurityScanButtonTitle = 'Run security scan'
592592

593593
export const crossFileContextConfig = {
594-
numberOfChunkToFetch: 60,
595-
topK: 3,
596-
numberOfLinesEachChunk: 10,
594+
numberOfChunkToFetch: 200,
595+
topK: 10,
596+
numberOfLinesEachChunk: 50,
597597
}
598598

599599
export const utgConfig = {

packages/core/src/test/codewhisperer/util/crossFileContextUtil.test.ts

Lines changed: 20 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -38,19 +38,30 @@ describe('crossFileContextUtil', function () {
3838
tempFolder = (await createTestWorkspaceFolder()).uri.fsPath
3939
})
4040

41-
describe('should fetch 3 chunks and each chunk should contains 10 lines', function () {
41+
describe('should fetch 10 chunks and each chunk should contains 50 lines', function () {
4242
async function assertCorrectCodeChunk() {
43-
await openATextEditorWithText(sampleFileOf60Lines, 'CrossFile.java', tempFolder, { preview: false })
43+
await openATextEditorWithText(sampleFileOf60Lines.repeat(10), 'CrossFile.java', tempFolder, {
44+
preview: false,
45+
})
4446
const myCurrentEditor = await openATextEditorWithText('', 'TargetFile.java', tempFolder, {
4547
preview: false,
4648
})
4749
const actual = await crossFile.fetchSupplementalContextForSrc(myCurrentEditor, fakeCancellationToken)
4850
assert.ok(actual)
49-
assert.ok(actual.supplementalContextItems.length === 3)
50-
51-
assert.strictEqual(actual.supplementalContextItems[0].content.split('\n').length, 10)
52-
assert.strictEqual(actual.supplementalContextItems[1].content.split('\n').length, 10)
53-
assert.strictEqual(actual.supplementalContextItems[2].content.split('\n').length, 10)
51+
assert.ok(actual.supplementalContextItems.length === crossFileContextConfig.topK)
52+
53+
assert.strictEqual(
54+
actual.supplementalContextItems[0].content.split('\n').length,
55+
crossFileContextConfig.numberOfLinesEachChunk
56+
)
57+
assert.strictEqual(
58+
actual.supplementalContextItems[1].content.split('\n').length,
59+
crossFileContextConfig.numberOfLinesEachChunk
60+
)
61+
assert.strictEqual(
62+
actual.supplementalContextItems[2].content.split('\n').length,
63+
crossFileContextConfig.numberOfLinesEachChunk
64+
)
5465
}
5566

5667
it('control group', async function () {
@@ -267,12 +278,12 @@ describe('crossFileContextUtil', function () {
267278
assert.strictEqual(chunks[1].content, 'line_6\nline_7')
268279
})
269280

270-
it('codewhisperer crossfile config should use 10 lines', async function () {
281+
it('codewhisperer crossfile config should use 50 lines', async function () {
271282
const filePath = path.join(tempFolder, 'file.txt')
272283
await toFile(sampleFileOf60Lines, filePath)
273284

274285
const chunks = await crossFile.splitFileToChunks(filePath, crossFileContextConfig.numberOfLinesEachChunk)
275-
assert.strictEqual(chunks.length, 6)
286+
assert.strictEqual(chunks.length, 2)
276287
})
277288
})
278289
})

0 commit comments

Comments
 (0)