Skip to content

Commit bf90a9d

Browse files
author
Jiatong Li
committed
feat(amazonq): integrate workspace context with inline completion
1 parent 439e859 commit bf90a9d

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

server/aws-lsp-codewhisperer/src/language-server/inline-completion/codeWhispererServer.ts

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ import { getOrThrowBaseTokenServiceManager } from '../../shared/amazonQServiceMa
4949
import { AmazonQWorkspaceConfig } from '../../shared/amazonQServiceManager/configurationUtils'
5050
import { hasConnectionExpired } from '../../shared/utils'
5151
import { getOrThrowBaseIAMServiceManager } from '../../shared/amazonQServiceManager/AmazonQIAMServiceManager'
52-
// import { WorkspaceFolderManager } from '../workspaceContext/workspaceFolderManager'
52+
import { WorkspaceFolderManager } from '../workspaceContext/workspaceFolderManager'
5353
import path = require('path')
5454
import { getRelativePath } from '../workspaceContext/util'
5555
import { UserWrittenCodeTracker } from '../../shared/userWrittenCodeTracker'
@@ -346,8 +346,10 @@ export const CodewhispererServerFactory =
346346
const maxResults = isAutomaticLspTriggerKind ? 1 : 5
347347
const selectionRange = params.context.selectedCompletionInfo?.range
348348
const fileContext = getFileContext({ textDocument, inferredLanguageId, position: params.position })
349-
// const workspaceFolder = WorkspaceFolderManager.getInstance()?.getWorkspaceFolder(params.textDocument.uri)
350-
// const workspaceId = WorkspaceFolderManager.getInstance()?.getWorkspaceId(workspaceFolder)
349+
const workspaceState = WorkspaceFolderManager.getInstance()?.getWorkspaceState()
350+
const workspaceId = workspaceState?.webSocketClient?.isConnected()
351+
? workspaceState.workspaceId
352+
: undefined
351353
// TODO: Can we get this derived from a keyboard event in the future?
352354
// This picks the last non-whitespace character, if any, before the cursor
353355
const triggerCharacter = fileContext.leftFileContent.trim().at(-1) ?? ''
@@ -450,7 +452,7 @@ export const CodewhispererServerFactory =
450452
.slice(0, CONTEXT_CHARACTERS_LIMIT)
451453
.replaceAll('\r\n', '\n'),
452454
},
453-
// workspaceId: workspaceId,
455+
...(workspaceId ? { workspaceId: workspaceId } : {}),
454456
})
455457
.then(async suggestionResponse => {
456458
return processSuggestionResponse(suggestionResponse, newSession, true, selectionRange)

0 commit comments

Comments
 (0)