@@ -10,7 +10,6 @@ import * as EditorContext from './util/editorContext'
10
10
import * as CodeWhispererConstants from './models/constants'
11
11
import { getCompletionItems } from './service/completionProvider'
12
12
import { vsCodeState , ConfigurationEntry } from './models/model'
13
- import { InlineCompletion } from './service/inlineCompletion'
14
13
import { invokeRecommendation } from './commands/invokeRecommendation'
15
14
import { acceptSuggestion } from './commands/onInlineAcceptance'
16
15
import { resetIntelliSenseState } from './util/globalStateUtil'
@@ -32,7 +31,6 @@ import {
32
31
showFreeTierLimit ,
33
32
updateReferenceLog ,
34
33
showIntroduction ,
35
- showAccessTokenErrorLearnMore ,
36
34
reconnect ,
37
35
refreshStatusBar ,
38
36
} from './commands/basicCommands'
@@ -48,8 +46,6 @@ import { InlineCompletionService } from './service/inlineCompletionService'
48
46
import { isInlineCompletionEnabled } from './util/commonUtil'
49
47
import { CodeWhispererCodeCoverageTracker } from './tracker/codewhispererCodeCoverageTracker'
50
48
import { AuthUtil } from './util/authUtil'
51
- import { Auth } from '../credentials/auth'
52
- import globals from '../shared/extensionGlobals'
53
49
import { ImportAdderProvider } from './service/importAdderProvider'
54
50
import { TelemetryHelper } from './util/telemetryHelper'
55
51
@@ -161,8 +157,6 @@ export async function activate(context: ExtContext): Promise<void> {
161
157
reconnect . register ( ) ,
162
158
// learn more about CodeWhisperer
163
159
showLearnMore . register ( ) ,
164
- // learn more about CodeWhisperer access token migration
165
- showAccessTokenErrorLearnMore . register ( ) ,
166
160
// show free tier limit
167
161
showFreeTierLimit . register ( ) ,
168
162
// update reference log instance
@@ -230,63 +224,6 @@ export async function activate(context: ExtContext): Promise<void> {
230
224
}
231
225
}
232
226
233
- async function showAccessTokenMigrationDialogue ( ) {
234
- // TODO: Change the color of the buttons
235
- const accessTokenExpired =
236
- context . extensionContext . globalState . get < boolean > ( CodeWhispererConstants . accessTokenExpriedKey ) || false
237
-
238
- if ( AuthUtil . instance . hasAccessToken ( ) ) {
239
- await Auth . instance . tryAutoConnect ( )
240
- await globals . context . globalState . update ( CodeWhispererConstants . accessToken , undefined )
241
- await globals . context . globalState . update ( CodeWhispererConstants . accessTokenExpriedKey , true )
242
- await vscode . commands . executeCommand ( 'aws.codeWhisperer.refreshRootNode' )
243
- maybeShowTokenMigrationError ( )
244
- } else if ( accessTokenExpired ) {
245
- maybeShowTokenMigrationError ( )
246
- }
247
- }
248
-
249
- function maybeShowTokenMigrationError ( ) {
250
- const migrationErrordoNotShowAgain =
251
- context . extensionContext . globalState . get < boolean > (
252
- CodeWhispererConstants . accessTokenExpiredDoNotShowAgainKey
253
- ) || false
254
- const migrationErrorLastShown : number =
255
- context . extensionContext . globalState . get < number | undefined > (
256
- CodeWhispererConstants . accessTokenExpiredDoNotShowLastShown
257
- ) || 1
258
-
259
- //Add 7 days to notificationLastShown to determine whether warn message should show
260
- if ( migrationErrordoNotShowAgain || migrationErrorLastShown + 1000 * 60 * 60 * 24 * 7 >= Date . now ( ) ) {
261
- return
262
- }
263
-
264
- vscode . window
265
- . showErrorMessage (
266
- CodeWhispererConstants . accessTokenMigrationErrorMessage ,
267
- CodeWhispererConstants . accessTokenMigrationErrorButtonMessage ,
268
- CodeWhispererConstants . accessTokenMigrationLearnMore ,
269
- CodeWhispererConstants . DoNotShowAgain
270
- )
271
- . then ( async resp => {
272
- if ( resp === CodeWhispererConstants . accessTokenMigrationErrorButtonMessage ) {
273
- await vscode . commands . executeCommand ( 'aws.codeWhisperer.refresh' )
274
- await showSsoSignIn . execute ( )
275
- } else if ( resp === CodeWhispererConstants . DoNotShowAgain ) {
276
- await context . extensionContext . globalState . update (
277
- CodeWhispererConstants . accessTokenExpiredDoNotShowAgainKey ,
278
- true
279
- )
280
- } else if ( resp === CodeWhispererConstants . accessTokenMigrationLearnMore ) {
281
- await vscode . commands . executeCommand ( 'aws.codeWhisperer.accessTokenErrorLearnMore' )
282
- }
283
- } )
284
- context . extensionContext . globalState . update (
285
- CodeWhispererConstants . accessTokenExpiredDoNotShowLastShown ,
286
- Date . now ( )
287
- )
288
- }
289
-
290
227
function getAutoTriggerStatus ( ) : boolean {
291
228
return context . extensionContext . globalState . get < boolean > ( CodeWhispererConstants . autoTriggerEnabledKey ) || false
292
229
}
@@ -312,11 +249,6 @@ export async function activate(context: ExtContext): Promise<void> {
312
249
} else if ( isInlineCompletionEnabled ( ) ) {
313
250
await setSubscriptionsforInlineCompletion ( )
314
251
await vscode . commands . executeCommand ( 'setContext' , 'CODEWHISPERER_ENABLED' , true )
315
- } else {
316
- await setSubscriptionsforVsCodeInline ( )
317
- }
318
- if ( ! isCloud9 ( ) ) {
319
- showAccessTokenMigrationDialogue ( )
320
252
}
321
253
322
254
async function setSubscriptionsforInlineCompletion ( ) {
@@ -379,106 +311,6 @@ export async function activate(context: ExtContext): Promise<void> {
379
311
)
380
312
}
381
313
382
- async function setSubscriptionsforVsCodeInline ( ) {
383
- /**
384
- * Automated trigger
385
- */
386
- context . extensionContext . subscriptions . push (
387
- vscode . workspace . onDidChangeTextDocument ( async e => {
388
- /**
389
- * CodeWhisperer security panel dynamic handling
390
- */
391
- if ( e . document === vscode . window . activeTextEditor ?. document ) {
392
- if ( isCloud9 ( ) ) {
393
- securityPanelViewProvider . disposeSecurityPanelItem ( e , vscode . window . activeTextEditor )
394
- } else {
395
- disposeSecurityDiagnostic ( e )
396
- }
397
- }
398
-
399
- const codeCoverageTracker = CodeWhispererCodeCoverageTracker . getTracker ( e . document . languageId )
400
- codeCoverageTracker ?. countTotalTokens ( e )
401
-
402
- /**
403
- * Handle this keystroke event only when
404
- * 1. It is in current active editor with cwspr supported file types
405
- * 2. It is not a backspace
406
- * 3. It is not caused by CodeWhisperer editing
407
- * 4. It is not from undo/redo.
408
- */
409
- if (
410
- e . document === vscode . window . activeTextEditor ?. document &&
411
- runtimeLanguageContext . isLanguageSupported ( e . document . languageId ) &&
412
- e . contentChanges . length != 0 &&
413
- ! vsCodeState . isCodeWhispererEditing &&
414
- ! JSON . stringify ( e ) . includes ( 'reason' )
415
- ) {
416
- vsCodeState . lastUserModificationTime = performance . now ( )
417
- /**
418
- * Important: Doing this sleep(10) is to make sure
419
- * 1. this event is processed by vs code first
420
- * 2. editor.selection.active has been successfully updated by VS Code
421
- * Then this event can be processed by our code.
422
- */
423
- await sleep ( CodeWhispererConstants . vsCodeCursorUpdateDelay )
424
- if ( InlineCompletion . instance . getIsActive ) {
425
- await InlineCompletion . instance . setTypeAheadRecommendations ( vscode . window . activeTextEditor , e )
426
- } else {
427
- await KeyStrokeHandler . instance . processKeyStroke (
428
- e ,
429
- vscode . window . activeTextEditor ,
430
- client ,
431
- await getConfigEntry ( )
432
- )
433
- }
434
- }
435
- } ) ,
436
-
437
- /**
438
- * On recommendation rejection
439
- */
440
- vscode . window . onDidChangeVisibleTextEditors ( async e => {
441
- await InlineCompletion . instance . rejectRecommendation ( vscode . window . activeTextEditor , false , true )
442
- } ) ,
443
- vscode . window . onDidChangeActiveTextEditor ( async e => {
444
- await InlineCompletion . instance . rejectRecommendation ( vscode . window . activeTextEditor )
445
- if ( vscode . window . activeTextEditor ) {
446
- CodeWhispererCodeCoverageTracker . getTracker (
447
- vscode . window . activeTextEditor . document . languageId
448
- ) ?. updateAcceptedTokensCount ( vscode . window . activeTextEditor )
449
- }
450
- } ) ,
451
- vscode . window . onDidChangeTextEditorSelection ( async e => {
452
- if ( e . kind === TextEditorSelectionChangeKind . Mouse && vscode . window . activeTextEditor ) {
453
- await InlineCompletion . instance . rejectRecommendation ( vscode . window . activeTextEditor )
454
- }
455
- } ) ,
456
- /**
457
- * Recommendation navigation
458
- */
459
- Commands . register ( 'aws.codeWhisperer.nextCodeSuggestion' , async ( ) => {
460
- if ( vscode . window . activeTextEditor ) {
461
- InlineCompletion . instance . navigateRecommendation ( vscode . window . activeTextEditor , true )
462
- }
463
- } ) ,
464
- Commands . register ( 'aws.codeWhisperer.previousCodeSuggestion' , async ( ) => {
465
- if ( vscode . window . activeTextEditor ) {
466
- InlineCompletion . instance . navigateRecommendation ( vscode . window . activeTextEditor , false )
467
- }
468
- } ) ,
469
- /**
470
- * Recommendation acceptance
471
- */
472
- Commands . register ( 'aws.codeWhisperer.acceptCodeSuggestion' , async ( ) => {
473
- if ( vscode . window . activeTextEditor ) {
474
- await InlineCompletion . instance . acceptRecommendation ( vscode . window . activeTextEditor )
475
- }
476
- } )
477
- )
478
-
479
- InlineCompletion . instance . setCodeWhispererStatusBarOk ( )
480
- }
481
-
482
314
function setSubscriptionsforCloud9 ( ) {
483
315
/**
484
316
* Manual trigger
@@ -567,10 +399,6 @@ export async function shutdown() {
567
399
}
568
400
if ( isInlineCompletionEnabled ( ) ) {
569
401
await InlineCompletionService . instance . clearInlineCompletionStates ( vscode . window . activeTextEditor )
570
- } else {
571
- if ( vscode . window . activeTextEditor ) {
572
- await InlineCompletion . instance . resetInlineStates ( vscode . window . activeTextEditor )
573
- }
574
402
}
575
403
CodeWhispererTracker . getTracker ( ) . shutdown ( )
576
404
}
0 commit comments