Skip to content

Commit ad7baa8

Browse files
committed
cleanup
1 parent 96478cf commit ad7baa8

File tree

5 files changed

+9
-37
lines changed

5 files changed

+9
-37
lines changed

packages/amazonq/test/unit/amazonq/lsp/lspClient.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ describe('Amazon Q LSP client', function () {
2727
})
2828

2929
it('encrypts payload of index files ', async () => {
30-
await lspClient.indexFiles(['fileA'], 'path', false)
30+
await lspClient.indexFiles(['fileA'], 'path', 'all')
3131
assert.ok(encryptFunc.calledOnce)
3232
assert.ok(
3333
encryptFunc.calledWith(

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

Lines changed: 5 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ import {
2222
BuildIndexRequestType,
2323
GetUsageRequestType,
2424
IndexConfig,
25-
IndexRequestType,
2625
QueryInlineProjectContextRequestType,
2726
QueryRequestType,
2827
UpdateIndexV2RequestPayload,
@@ -72,24 +71,7 @@ export class LspClient {
7271
.encrypt(key)
7372
}
7473

75-
async indexFiles(request: string[], rootPath: string, refresh: boolean) {
76-
try {
77-
const encryptedRequest = await this.encrypt(
78-
JSON.stringify({
79-
filePaths: request,
80-
rootPath: rootPath,
81-
refresh: refresh,
82-
})
83-
)
84-
const resp = await this.client?.sendRequest(IndexRequestType, encryptedRequest)
85-
return resp
86-
} catch (e) {
87-
getLogger().error(`LspClient: indexFiles error: ${e}`)
88-
return undefined
89-
}
90-
}
91-
92-
async indexFilesV2(paths: string[], rootPath: string, config: IndexConfig) {
74+
async indexFiles(paths: string[], rootPath: string, config: IndexConfig) {
9375
const payload: BuildIndexRequestPayload = {
9476
filePaths: paths,
9577
projectRoot: rootPath,
@@ -144,9 +126,7 @@ export class LspClient {
144126
}
145127
}
146128

147-
// not yet account for file move
148-
// v2
149-
async updateIndexV2(filePath: string[], mode: 'update' | 'remove' | 'add') {
129+
async updateIndex(filePath: string[], mode: 'update' | 'remove' | 'add') {
150130
const payload: UpdateIndexV2RequestPayload = {
151131
filePaths: filePath,
152132
updateMode: mode,
@@ -247,17 +227,17 @@ export async function activate(extensionContext: ExtensionContext) {
247227
}),
248228
vscode.window.onDidChangeActiveTextEditor((editor) => {
249229
if (savedDocument && editor && editor.document.uri.fsPath !== savedDocument.fsPath) {
250-
void LspClient.instance.updateIndexV2([editor.document.uri.fsPath], 'update')
230+
void LspClient.instance.updateIndex([editor.document.uri.fsPath], 'update')
251231
}
252232
}),
253233
vscode.workspace.onDidCreateFiles((e) => {
254-
void LspClient.instance.updateIndexV2(
234+
void LspClient.instance.updateIndex(
255235
e.files.map((f) => f.fsPath),
256236
'add'
257237
)
258238
}),
259239
vscode.workspace.onDidDeleteFiles((e) => {
260-
void LspClient.instance.updateIndexV2(
240+
void LspClient.instance.updateIndex(
261241
e.files.map((f) => f.fsPath),
262242
'remove'
263243
)

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -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.indexFilesV2(r, projRoot, config)
338+
const resp = await LspClient.instance.indexFiles(r, projRoot, config)
339339
if (resp) {
340340
getLogger().debug(`LspController: Finish building index of project`)
341341
const usage = await LspClient.instance.getLspServerUsage()

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

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,6 @@ export type IndexRequestPayload = {
1111
refresh: boolean
1212
}
1313

14-
export type IndexRequest = string
15-
16-
export const IndexRequestType: RequestType<IndexRequest, any, any> = new RequestType('lsp/index')
17-
1814
export type ClearRequest = string
1915

2016
export const ClearRequestType: RequestType<ClearRequest, any, any> = new RequestType('lsp/clear')
@@ -23,10 +19,6 @@ export type QueryRequest = string
2319

2420
export const QueryRequestType: RequestType<QueryRequest, any, any> = new RequestType('lsp/query')
2521

26-
export type UpdateIndexRequest = string
27-
28-
export const UpdateIndexRequestType: RequestType<UpdateIndexRequest, any, any> = new RequestType('lsp/updateIndex')
29-
3022
export type GetUsageRequest = string
3123

3224
export const GetUsageRequestType: RequestType<GetUsageRequest, any, any> = new RequestType('lsp/getUsage')

packages/core/src/testInteg/buildIndex.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import assert from 'assert'
1010
import { LspClient, LspController } from '../amazonq'
1111
import { LanguageClient, ServerOptions } from 'vscode-languageclient'
1212
import { createTestWorkspace } from '../test/testUtil'
13-
import { GetUsageRequestType, IndexRequestType } from '../amazonq/lsp/types'
13+
import { GetUsageRequestType } from '../amazonq/lsp/types'
1414
import { getRandomString } from '../shared'
1515

1616
interface SetupResult {
@@ -19,7 +19,7 @@ interface SetupResult {
1919

2020
async function verifyResult(setup: SetupResult) {
2121
assert.ok(setup.clientReqStub.calledTwice)
22-
assert.ok(setup.clientReqStub.firstCall.calledWith(IndexRequestType))
22+
// assert.ok(setup.clientReqStub.firstCall.calledWith(IndexRequestType))
2323
assert.ok(setup.clientReqStub.secondCall.calledWith(GetUsageRequestType))
2424
}
2525

0 commit comments

Comments
 (0)