Skip to content

Commit e4f85dd

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

File tree

2 files changed

+11
-4
lines changed

2 files changed

+11
-4
lines changed

app/aws-lsp-codewhisperer-runtimes/webpack.config.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,11 @@ const webworkerConfig = {
8383
fs: path.resolve(__dirname, 'src/mock-fs.js'),
8484
child_process: false,
8585
vm: false,
86+
dns: false,
87+
zlib: false,
88+
net: false,
89+
tls: false,
90+
http2: false,
8691
},
8792
extensions: ['.ts', '.tsx', '.js', '.jsx'],
8893
},

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)