Skip to content

Commit 9da2042

Browse files
authored
(feat codewhisperer) change file fetching strategy to only open files #3615
Before: - Imported files - Same package files After: - Open files
1 parent 88a5acd commit 9da2042

File tree

3 files changed

+3
-23
lines changed

3 files changed

+3
-23
lines changed

src/codewhisperer/util/supplementalContext/crossFileContextUtil.ts

Lines changed: 1 addition & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -153,27 +153,9 @@ function splitFileToChunks(filePath: string, chunkSize: number): Chunk[] {
153153
* by referencing open files, imported files and same package files.
154154
*/
155155
async function getRelevantCrossFiles(editor: vscode.TextEditor, dependencyGraph: DependencyGraph): Promise<string[]> {
156-
const openedFilesInEditor = new Set(getOpenFilesInWindow())
157-
158-
let srcDependencies = await dependencyGraph.getSourceDependencies(editor.document.uri, editor.document.getText())
159-
srcDependencies = moveToFront(srcDependencies, openedFilesInEditor)
160-
161-
const samePackageFiles = await dependencyGraph.getSamePackageFiles(
162-
editor.document.uri,
163-
dependencyGraph.getProjectPath(editor.document.uri)
164-
)
165-
const samePackageRelevantFiles = samePackageFiles.filter(file => {
156+
return getOpenFilesInWindow().filter(file => {
166157
return isRelevant(editor.document.fileName, file, editor.document.languageId)
167158
})
168-
169-
const mergedCrossFileList = [...new Set([...srcDependencies, ...samePackageRelevantFiles])]
170-
171-
return mergedCrossFileList
172-
}
173-
174-
// Util to move selected files to the front of the input array if it exists
175-
function moveToFront<T>(arr: T[], picked: Set<T>) {
176-
return [...arr].sort((a, b) => (picked.has(b) ? 1 : 0) - (picked.has(a) ? 1 : 0))
177159
}
178160

179161
function getOpenFilesInWindow(): string[] {

src/shared/clients/iamClient.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -72,9 +72,7 @@ export class DefaultIamClient {
7272
public getFriendlyName(arn: string): string {
7373
const tokens = arn.split('/')
7474
if (tokens.length < 2) {
75-
throw new Error(
76-
`Invalid IAM role ARN (expected format: arn:aws:iam::{id}/{name}): ${arn}`
77-
)
75+
throw new Error(`Invalid IAM role ARN (expected format: arn:aws:iam::{id}/{name}): ${arn}`)
7876
}
7977
return tokens[tokens.length - 1]
8078
}

src/test/codewhisperer/util/authUtil.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ describe('AuthUtil', async function () {
5555
const ssoConn = await auth.createInvalidSsoConnection(
5656
createSsoProfile({ startUrl: enterpriseSsoStartUrl, scopes: [randomScope] })
5757
)
58-
58+
5959
// Method under test
6060
await authUtil.connectToEnterpriseSso(ssoConn.startUrl, 'us-east-1')
6161

0 commit comments

Comments
 (0)