@@ -31,7 +31,12 @@ import {
31
31
LSPErrorCodes ,
32
32
updateConfigurationRequestType ,
33
33
} from '@aws/language-server-runtimes/protocol'
34
- import { AuthUtil , CodeWhispererSettings , getSelectedCustomization } from 'aws-core-vscode/codewhisperer'
34
+ import {
35
+ AuthUtil ,
36
+ CodeWhispererSettings ,
37
+ getSelectedCustomization ,
38
+ TelemetryHelper ,
39
+ } from 'aws-core-vscode/codewhisperer'
35
40
import {
36
41
Settings ,
37
42
createServerOptions ,
@@ -46,13 +51,20 @@ import {
46
51
openUrl ,
47
52
getClientId ,
48
53
extensionVersion ,
54
+ Commands ,
49
55
} from 'aws-core-vscode/shared'
50
56
import { processUtils } from 'aws-core-vscode/shared'
51
57
import { activate as activateChat } from './chat/activation'
58
+ import { activate as activeInlineChat } from '../inlineChat/activation'
52
59
import { AmazonQResourcePaths } from './lspInstaller'
53
60
import { auth2 } from 'aws-core-vscode/auth'
54
61
import { ConfigSection , isValidConfigSection , pushConfigUpdate , toAmazonQLSPLogLevel } from './config'
55
62
import { telemetry } from 'aws-core-vscode/telemetry'
63
+ import { SessionManager } from '../app/inline/sessionManager'
64
+ import { LineTracker } from '../app/inline/stateTracker/lineTracker'
65
+ import { InlineChatTutorialAnnotation } from '../app/inline/tutorials/inlineChatTutorialAnnotation'
66
+ import { InlineTutorialAnnotation } from '../app/inline/tutorials/inlineTutorialAnnotation'
67
+ import { InlineCompletionManager } from '../app/inline/completion'
56
68
57
69
const localize = nls . loadMessageBundle ( )
58
70
const logger = getLogger ( 'amazonqLsp.lspClient' )
@@ -181,7 +193,7 @@ export async function startLanguageServer(
181
193
*/
182
194
await initializeAuth ( client )
183
195
184
- await postStartLanguageServer ( client , resourcePaths , toDispose )
196
+ await postStartLanguageServer ( extensionContext , client , resourcePaths , toDispose )
185
197
186
198
return client
187
199
@@ -210,7 +222,60 @@ export async function startLanguageServer(
210
222
}
211
223
}
212
224
225
+ async function setupInline (
226
+ extensionContext : vscode . ExtensionContext ,
227
+ client : LanguageClient ,
228
+ toDispose : vscode . Disposable [ ]
229
+ ) {
230
+ const sessionManager = new SessionManager ( )
231
+ const lineTracker = new LineTracker ( )
232
+ const inlineTutorialAnnotation = new InlineTutorialAnnotation ( lineTracker , sessionManager )
233
+ const inlineChatTutorialAnnotation = new InlineChatTutorialAnnotation ( inlineTutorialAnnotation )
234
+
235
+ const inlineManager = new InlineCompletionManager ( client , sessionManager , lineTracker , inlineTutorialAnnotation )
236
+
237
+ inlineManager . registerInlineCompletion ( )
238
+
239
+ activeInlineChat ( extensionContext , client , encryptionKey , inlineChatTutorialAnnotation )
240
+
241
+ toDispose . push (
242
+ inlineManager ,
243
+ Commands . register ( { id : 'aws.amazonq.invokeInlineCompletion' , autoconnect : true } , async ( ) => {
244
+ await vscode . commands . executeCommand ( 'editor.action.inlineSuggest.trigger' )
245
+ } ) ,
246
+ Commands . register ( 'aws.amazonq.refreshAnnotation' , async ( forceProceed : boolean ) => {
247
+ telemetry . record ( {
248
+ traceId : TelemetryHelper . instance . traceId ,
249
+ } )
250
+
251
+ const editor = vscode . window . activeTextEditor
252
+ if ( editor ) {
253
+ if ( forceProceed ) {
254
+ await inlineTutorialAnnotation . refresh ( editor , 'codewhisperer' , true )
255
+ } else {
256
+ await inlineTutorialAnnotation . refresh ( editor , 'codewhisperer' )
257
+ }
258
+ }
259
+ } ) ,
260
+ Commands . register ( 'aws.amazonq.dismissTutorial' , async ( ) => {
261
+ const editor = vscode . window . activeTextEditor
262
+ if ( editor ) {
263
+ inlineTutorialAnnotation . clear ( )
264
+ try {
265
+ telemetry . ui_click . emit ( { elementId : `dismiss_${ inlineTutorialAnnotation . currentState . id } ` } )
266
+ } catch ( _ ) { }
267
+ await inlineTutorialAnnotation . dismissTutorial ( )
268
+ getLogger ( ) . debug ( `codewhisperer: user dismiss tutorial.` )
269
+ }
270
+ } ) ,
271
+ vscode . workspace . onDidCloseTextDocument ( async ( ) => {
272
+ await vscode . commands . executeCommand ( 'aws.amazonq.rejectCodeSuggestion' )
273
+ } )
274
+ )
275
+ }
276
+
213
277
async function postStartLanguageServer (
278
+ extensionContext : vscode . ExtensionContext ,
214
279
client : LanguageClient ,
215
280
resourcePaths : AmazonQResourcePaths ,
216
281
toDispose : vscode . Disposable [ ]
@@ -308,23 +373,12 @@ async function postStartLanguageServer(
308
373
)
309
374
} )
310
375
311
- // if (Experiments.instance.get('amazonqLSPInline', false)) {
312
- // const inlineManager = new InlineCompletionManager(client)
313
- // inlineManager.registerInlineCompletion()
314
- // toDispose.push(
315
- // inlineManager,
316
- // Commands.register({ id: 'aws.amazonq.invokeInlineCompletion', autoconnect: true }, async () => {
317
- // await vscode.commands.executeCommand('editor.action.inlineSuggest.trigger')
318
- // }),
319
- // vscode.workspace.onDidCloseTextDocument(async () => {
320
- // await vscode.commands.executeCommand('aws.amazonq.rejectCodeSuggestion')
321
- // })
322
- // )
323
- // }
324
376
if ( Experiments . instance . get ( 'amazonqChatLSP' , true ) ) {
325
377
await activateChat ( client , encryptionKey , resourcePaths . ui )
326
378
}
327
379
380
+ await setupInline ( extensionContext , client , toDispose )
381
+
328
382
toDispose . push (
329
383
AuthUtil . instance . regionProfileManager . onDidChangeRegionProfile ( sendProfileToLsp ) ,
330
384
vscode . commands . registerCommand ( 'aws.amazonq.getWorkspaceId' , async ( ) => {
0 commit comments