@@ -20,12 +20,7 @@ import { AmazonQInlineCompletionItemProvider, InlineCompletionManager } from '..
20
20
import { RecommendationService } from '../../../../../src/app/inline/recommendationService'
21
21
import { SessionManager } from '../../../../../src/app/inline/sessionManager'
22
22
import { createMockDocument , createMockTextEditor , getTestWindow , installFakeClock } from 'aws-core-vscode/test'
23
- import {
24
- noInlineSuggestionsMsg ,
25
- ReferenceHoverProvider ,
26
- ReferenceInlineProvider ,
27
- ReferenceLogViewProvider ,
28
- } from 'aws-core-vscode/codewhisperer'
23
+ import { noInlineSuggestionsMsg , ReferenceHoverProvider , ReferenceLogViewProvider } from 'aws-core-vscode/codewhisperer'
29
24
import { InlineGeneratingMessage } from '../../../../../src/app/inline/inlineGeneratingMessage'
30
25
import { LineTracker } from '../../../../../src/app/inline/stateTracker/lineTracker'
31
26
import { InlineTutorialAnnotation } from '../../../../../src/app/inline/tutorials/inlineTutorialAnnotation'
@@ -230,46 +225,6 @@ describe('InlineCompletionManager', () => {
230
225
assert ( registerProviderStub . calledTwice ) // Once in constructor, once after rejection
231
226
} )
232
227
} )
233
-
234
- describe ( 'previous command' , ( ) => {
235
- it ( 'should register and handle previous command correctly' , async ( ) => {
236
- const prevCommandCall = registerCommandStub
237
- . getCalls ( )
238
- . find ( ( call ) => call . args [ 0 ] === 'editor.action.inlineSuggest.showPrevious' )
239
-
240
- assert ( prevCommandCall , 'Previous command should be registered' )
241
-
242
- if ( prevCommandCall ) {
243
- const handler = prevCommandCall . args [ 1 ]
244
- await handler ( )
245
-
246
- assert ( executeCommandStub . calledWith ( 'editor.action.inlineSuggest.hide' ) )
247
- assert ( disposableStub . calledOnce )
248
- assert ( registerProviderStub . calledTwice )
249
- assert ( executeCommandStub . calledWith ( 'editor.action.inlineSuggest.trigger' ) )
250
- }
251
- } )
252
- } )
253
-
254
- describe ( 'next command' , ( ) => {
255
- it ( 'should register and handle next command correctly' , async ( ) => {
256
- const nextCommandCall = registerCommandStub
257
- . getCalls ( )
258
- . find ( ( call ) => call . args [ 0 ] === 'editor.action.inlineSuggest.showNext' )
259
-
260
- assert ( nextCommandCall , 'Next command should be registered' )
261
-
262
- if ( nextCommandCall ) {
263
- const handler = nextCommandCall . args [ 1 ]
264
- await handler ( )
265
-
266
- assert ( executeCommandStub . calledWith ( 'editor.action.inlineSuggest.hide' ) )
267
- assert ( disposableStub . calledOnce )
268
- assert ( registerProviderStub . calledTwice )
269
- assert ( executeCommandStub . calledWith ( 'editor.action.inlineSuggest.trigger' ) )
270
- }
271
- } )
272
- } )
273
228
} )
274
229
275
230
describe ( 'AmazonQInlineCompletionItemProvider' , ( ) => {
@@ -278,15 +233,13 @@ describe('InlineCompletionManager', () => {
278
233
let provider : AmazonQInlineCompletionItemProvider
279
234
let getAllRecommendationsStub : sinon . SinonStub
280
235
let recommendationService : RecommendationService
281
- let setInlineReferenceStub : sinon . SinonStub
282
236
let inlineTutorialAnnotation : InlineTutorialAnnotation
283
237
284
238
beforeEach ( ( ) => {
285
239
const lineTracker = new LineTracker ( )
286
240
const activeStateController = new InlineGeneratingMessage ( lineTracker )
287
241
inlineTutorialAnnotation = new InlineTutorialAnnotation ( lineTracker , mockSessionManager )
288
242
recommendationService = new RecommendationService ( mockSessionManager , activeStateController )
289
- setInlineReferenceStub = sandbox . stub ( ReferenceInlineProvider . instance , 'setInlineReference' )
290
243
291
244
mockSessionManager = {
292
245
getActiveSession : getActiveSessionStub ,
@@ -320,48 +273,21 @@ describe('InlineCompletionManager', () => {
320
273
assert ( getAllRecommendationsStub . calledOnce )
321
274
assert . deepStrictEqual ( items , mockSuggestions )
322
275
} ) ,
323
- it ( 'should not call recommendation service for existing sessions' , async ( ) => {
324
- provider = new AmazonQInlineCompletionItemProvider (
325
- languageClient ,
326
- recommendationService ,
327
- mockSessionManager ,
328
- inlineTutorialAnnotation ,
329
- false
330
- )
331
- const items = await provider . provideInlineCompletionItems (
332
- mockDocument ,
333
- mockPosition ,
334
- mockContext ,
335
- mockToken
336
- )
337
- assert ( getAllRecommendationsStub . notCalled )
338
- assert . deepStrictEqual ( items , mockSuggestions )
339
- } ) ,
340
276
it ( 'should handle reference if there is any' , async ( ) => {
341
277
provider = new AmazonQInlineCompletionItemProvider (
342
278
languageClient ,
343
279
recommendationService ,
344
280
mockSessionManager ,
345
- inlineTutorialAnnotation ,
346
- false
281
+ inlineTutorialAnnotation
347
282
)
348
283
await provider . provideInlineCompletionItems ( mockDocument , mockPosition , mockContext , mockToken )
349
- assert ( setInlineReferenceStub . calledOnce )
350
- assert (
351
- setInlineReferenceStub . calledWithExactly (
352
- mockPosition . line ,
353
- mockSuggestions [ 0 ] . insertText ,
354
- fakeReferences
355
- )
356
- )
357
284
} ) ,
358
285
it ( 'should add a range to the completion item when missing' , async function ( ) {
359
286
provider = new AmazonQInlineCompletionItemProvider (
360
287
languageClient ,
361
288
recommendationService ,
362
289
mockSessionManager ,
363
- inlineTutorialAnnotation ,
364
- true
290
+ inlineTutorialAnnotation
365
291
)
366
292
getActiveRecommendationStub . returns ( [
367
293
{
@@ -391,8 +317,7 @@ describe('InlineCompletionManager', () => {
391
317
languageClient ,
392
318
recommendationService ,
393
319
mockSessionManager ,
394
- inlineTutorialAnnotation ,
395
- true
320
+ inlineTutorialAnnotation
396
321
)
397
322
const expectedText = 'this is my text'
398
323
getActiveRecommendationStub . returns ( [
@@ -415,8 +340,7 @@ describe('InlineCompletionManager', () => {
415
340
languageClient ,
416
341
recommendationService ,
417
342
mockSessionManager ,
418
- inlineTutorialAnnotation ,
419
- true
343
+ inlineTutorialAnnotation
420
344
)
421
345
getActiveRecommendationStub . returns ( [ ] )
422
346
const messageShown = new Promise ( ( resolve ) =>
@@ -449,8 +373,7 @@ describe('InlineCompletionManager', () => {
449
373
languageClient ,
450
374
recommendationService ,
451
375
mockSessionManager ,
452
- inlineTutorialAnnotation ,
453
- false
376
+ inlineTutorialAnnotation
454
377
)
455
378
const p1 = provider . provideInlineCompletionItems ( mockDocument , mockPosition , mockContext , mockToken )
456
379
const p2 = provider . provideInlineCompletionItems ( mockDocument , mockPosition , mockContext , mockToken )
0 commit comments