Skip to content

Commit ae74307

Browse files
committed
clean up code
1 parent d399b75 commit ae74307

File tree

2 files changed

+9
-11
lines changed

2 files changed

+9
-11
lines changed

packages/core/src/amazonq/lsp/lspClient.ts

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ import {
2323
GetUsageRequestType,
2424
IndexConfig,
2525
QueryInlineProjectContextRequestType,
26-
QueryRequestType,
26+
QueryVectorIndexRequestType,
2727
UpdateIndexV2RequestPayload,
2828
UpdateIndexV2RequestType,
2929
Usage,
@@ -71,7 +71,7 @@ export class LspClient {
7171
.encrypt(key)
7272
}
7373

74-
async indexFiles(paths: string[], rootPath: string, config: IndexConfig) {
74+
async buildIndex(paths: string[], rootPath: string, config: IndexConfig) {
7575
const payload: BuildIndexRequestPayload = {
7676
filePaths: paths,
7777
projectRoot: rootPath,
@@ -83,22 +83,22 @@ export class LspClient {
8383
const resp = await this.client?.sendRequest(BuildIndexRequestType, encryptedRequest)
8484
return resp
8585
} catch (e) {
86-
getLogger().error(`LspClient: indexFilesV2 error: ${e}`)
86+
getLogger().error(`LspClient: buildIndex error: ${e}`)
8787
return undefined
8888
}
8989
}
9090

91-
async query(request: string) {
91+
async queryVectorIndex(request: string) {
9292
try {
9393
const encryptedRequest = await this.encrypt(
9494
JSON.stringify({
9595
query: request,
9696
})
9797
)
98-
const resp = await this.client?.sendRequest(QueryRequestType, encryptedRequest)
98+
const resp = await this.client?.sendRequest(QueryVectorIndexRequestType, encryptedRequest)
9999
return resp
100100
} catch (e) {
101-
getLogger().error(`LspClient: query error: ${e}`)
101+
getLogger().error(`LspClient: queryVectorIndex error: ${e}`)
102102
return []
103103
}
104104
}
@@ -109,9 +109,7 @@ export class LspClient {
109109
query: query,
110110
filePath: path,
111111
})
112-
113112
const encrpted = await this.encrypt(request)
114-
115113
let resp: any = await this.client?.sendRequest(QueryInlineProjectContextRequestType, encrpted)
116114
return resp
117115
} catch (e) {
@@ -136,7 +134,7 @@ export class LspClient {
136134
const resp = await this.client?.sendRequest(UpdateIndexV2RequestType, encryptedRequest)
137135
return resp
138136
} catch (e) {
139-
getLogger().error(`LspClient: updateIndexV2 error: ${e}`)
137+
getLogger().error(`LspClient: updateIndex error: ${e}`)
140138
return undefined
141139
}
142140
}

packages/core/src/amazonq/lsp/lspController.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -281,7 +281,7 @@ export class LspController {
281281
}
282282

283283
async query(s: string): Promise<RelevantTextDocument[]> {
284-
const chunks: Chunk[] | undefined = await LspClient.instance.query(s)
284+
const chunks: Chunk[] | undefined = await LspClient.instance.queryVectorIndex(s)
285285
const resp: RelevantTextDocument[] = []
286286
chunks?.forEach((chunk) => {
287287
const text = chunk.context ? chunk.context : chunk.content
@@ -335,7 +335,7 @@ export class LspController {
335335
getLogger().info(`LspController: Found ${files.length} files in current project ${getProjectPaths()}`)
336336
const config = CodeWhispererSettings.instance.isLocalIndexEnabled() ? 'all' : 'default'
337337
const r = files.map((f) => f.fileUri.fsPath)
338-
const resp = await LspClient.instance.indexFiles(r, projRoot, config)
338+
const resp = await LspClient.instance.buildIndex(r, projRoot, config)
339339
if (resp) {
340340
getLogger().debug(`LspController: Finish building index of project`)
341341
const usage = await LspClient.instance.getLspServerUsage()

0 commit comments

Comments
 (0)