Skip to content

Commit bd3abcc

Browse files
committed
fix(amazonq): Fix conflicts from merge with master
1 parent dca9b6b commit bd3abcc

File tree

5 files changed

+20
-17
lines changed

5 files changed

+20
-17
lines changed

packages/amazonq/test/unit/codewhisperer/region/regionProfileManager.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ describe('RegionProfileManager', function () {
6161
}
6262
const createClientStub = sinon.stub(regionProfileManager, 'createQClient').resolves(mockClient)
6363

64-
const r = await regionProfileManager.listRegionProfiles()
64+
const r = await regionProfileManager.listRegionProfile()
6565

6666
assert.strictEqual(r.length, 2)
6767
assert.deepStrictEqual(r, [
@@ -177,7 +177,7 @@ describe('RegionProfileManager', function () {
177177
})
178178

179179
it(`restoreRegionProfile`, async function () {
180-
sinon.stub(regionProfileManager, 'listRegionProfiles').resolves([profileFoo])
180+
sinon.stub(regionProfileManager, 'listRegionProfile').resolves([profileFoo])
181181
await setupConnection('idc')
182182
if (!AuthUtil.instance.isConnected()) {
183183
fail('connection should not be undefined')

packages/core/src/codewhisperer/activation.ts

Lines changed: 12 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -105,8 +105,6 @@ export async function activate(context: ExtContext): Promise<void> {
105105
// Import old CodeWhisperer settings into Amazon Q
106106
await CodeWhispererSettings.instance.importSettings()
107107

108-
const auth = AuthUtil.instance
109-
110108
// TODO: is this indirection useful?
111109
registerDeclaredCommands(
112110
context.extensionContext.subscriptions,
@@ -157,7 +155,7 @@ export async function activate(context: ExtContext): Promise<void> {
157155

158156
if (configurationChangeEvent.affectsConfiguration('amazonQ.showCodeWithReferences')) {
159157
ReferenceLogViewProvider.instance.update()
160-
if (auth.isIdcConnection()) {
158+
if (AuthUtil.instance.isIdcConnection()) {
161159
await vscode.window
162160
.showInformationMessage(
163161
CodeWhispererConstants.ssoConfigAlertMessage,
@@ -172,7 +170,7 @@ export async function activate(context: ExtContext): Promise<void> {
172170
}
173171

174172
if (configurationChangeEvent.affectsConfiguration('amazonQ.shareContentWithAWS')) {
175-
if (auth.isIdcConnection()) {
173+
if (AuthUtil.instance.isIdcConnection()) {
176174
await vscode.window
177175
.showInformationMessage(
178176
CodeWhispererConstants.ssoConfigAlertMessageShareData,
@@ -342,7 +340,7 @@ export async function activate(context: ExtContext): Promise<void> {
342340
SecurityIssueCodeActionProvider.instance
343341
),
344342
vscode.commands.registerCommand('aws.amazonq.openEditorAtRange', openEditorAtRange),
345-
auth.regionProfileManager.onDidChangeRegionProfile(() => {
343+
AuthUtil.instance.regionProfileManager.onDidChangeRegionProfile(() => {
346344
// Validate user still has access to the selected customization.
347345
const selectedCustomization = getSelectedCustomization()
348346
// No need to validate base customization which has empty arn.
@@ -367,27 +365,27 @@ export async function activate(context: ExtContext): Promise<void> {
367365
// run the auth startup code with context for telemetry
368366
await telemetry.function_call.run(
369367
async () => {
370-
if (auth.isConnectionExpired()) {
371-
auth.showReauthenticatePrompt().catch((e) => {
368+
if (AuthUtil.instance.isConnectionExpired()) {
369+
AuthUtil.instance.showReauthenticatePrompt().catch((e) => {
372370
const defaulMsg = localize('AWS.generic.message.error', 'Failed to reauth:')
373371
void logAndShowError(localize, e, 'showReauthenticatePrompt', defaulMsg)
374372
})
375-
if (auth.isIdcConnection()) {
376-
await auth.notifySessionConfiguration()
373+
if (AuthUtil.instance.isIdcConnection()) {
374+
await AuthUtil.instance.notifySessionConfiguration()
377375
}
378376
}
379377

380-
if (auth.requireProfileSelection()) {
378+
if (AuthUtil.instance.regionProfileManager.requireProfileSelection()) {
381379
await notifySelectDeveloperProfile()
382380
}
383381
},
384382
{ emit: false, functionId: { name: 'activateCwCore' } }
385383
)
386384

387-
if (auth.isIdcConnection() && auth.isConnected()) {
385+
if (AuthUtil.instance.isIdcConnection() && AuthUtil.instance.isConnected()) {
388386
await notifyNewCustomizations()
389387
}
390-
if (auth.isBuilderIdConnection()) {
388+
if (AuthUtil.instance.isBuilderIdConnection()) {
391389
await CodeScansState.instance.setScansEnabled(false)
392390
}
393391

@@ -402,8 +400,8 @@ export async function activate(context: ExtContext): Promise<void> {
402400
return (
403401
(isScansEnabled ?? CodeScansState.instance.isScansEnabled()) &&
404402
!CodeScansState.instance.isMonthlyQuotaExceeded() &&
405-
auth.isConnected() &&
406-
!auth.isBuilderIdConnection() &&
403+
AuthUtil.instance.isConnected() &&
404+
!AuthUtil.instance.isBuilderIdConnection() &&
407405
editor &&
408406
editor.document.uri.scheme === 'file' &&
409407
securityScanLanguageContext.isLanguageSupported(editor.document.languageId)

packages/core/src/codewhisperer/region/regionProfileManager.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -369,6 +369,10 @@ export class RegionProfileManager {
369369
return this.authProvider.isIdcConnection() && this.activeRegionProfile === undefined
370370
}
371371

372+
async clearCache() {
373+
await this.cache.clearCache()
374+
}
375+
372376
async createQClient(region: string, endpoint: string): Promise<CodeWhispererUserClient> {
373377
const token = await this.authProvider.getToken()
374378
const serviceOption: ServiceOptions = {

packages/core/src/codewhisperer/ui/statusBarMenu.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ function getAmazonQCodeWhispererNodes() {
8585
}
8686

8787
export function getQuickPickItems(): DataQuickPickItem<string>[] {
88-
const isUsingEnterpriseSso = AuthUtil.instance.isValidEnterpriseSsoInUse()
88+
const isUsingEnterpriseSso = AuthUtil.instance.isIdcConnection()
8989
const regionProfile = AuthUtil.instance.regionProfileManager.activeRegionProfile
9090

9191
const children = [

packages/core/src/shared/settings-toolkit.gen.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ export const toolkitSettings = {
4242
},
4343
"aws.experiments": {
4444
"jsonResourceModification": {},
45+
"amazonqLSP": {},
4546
"amazonqLSPInline": {},
4647
"amazonqChatLSP": {}
4748
},

0 commit comments

Comments
 (0)