Skip to content

Commit 916454b

Browse files
committed
circurlar dependency
1 parent 2189b27 commit 916454b

File tree

2 files changed

+26
-26
lines changed

2 files changed

+26
-26
lines changed

packages/core/src/codewhisperer/activation.ts

Lines changed: 26 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,12 @@ import { AuthUtil } from './util/authUtil'
7272
import { ImportAdderProvider } from './service/importAdderProvider'
7373
import { TelemetryHelper } from './util/telemetryHelper'
7474
import { openUrl } from '../shared/utilities/vsCodeUtils'
75-
import { notifyNewCustomizations } from './util/customizationUtil'
75+
import {
76+
getAvailableCustomizationsList,
77+
getSelectedCustomization,
78+
notifyNewCustomizations,
79+
switchToBaseCustomizationAndNotify,
80+
} from './util/customizationUtil'
7681
import { CodeWhispererCommandBackend, CodeWhispererCommandDeclarations } from './commands/gettingStartedPageCommands'
7782
import { SecurityIssueHoverProvider } from './service/securityIssueHoverProvider'
7883
import { SecurityIssueCodeActionProvider } from './service/securityIssueCodeActionProvider'
@@ -337,7 +342,26 @@ export async function activate(context: ExtContext): Promise<void> {
337342
[...CodeWhispererConstants.securityScanLanguageIds],
338343
SecurityIssueCodeActionProvider.instance
339344
),
340-
vscode.commands.registerCommand('aws.amazonq.openEditorAtRange', openEditorAtRange)
345+
vscode.commands.registerCommand('aws.amazonq.openEditorAtRange', openEditorAtRange),
346+
auth.regionProfileManager.onDidChangeRegionProfile(() => {
347+
// validate user's still has access to the selected customization
348+
const selectedCustomization = getSelectedCustomization()
349+
// no need to validate base customization which has empty arn
350+
if (selectedCustomization.arn.length > 0) {
351+
getAvailableCustomizationsList()
352+
.then((customizations) => {
353+
const r = customizations.find((it) => it.arn === selectedCustomization.arn)
354+
if (!r) {
355+
void switchToBaseCustomizationAndNotify().then()
356+
}
357+
})
358+
.catch((e) => {
359+
getLogger().error(
360+
`encounter error while validating selected customization on profile change: ${(e as Error).message}`
361+
)
362+
})
363+
}
364+
})
341365
)
342366

343367
// run the auth startup code with context for telemetry

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

Lines changed: 0 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -28,11 +28,6 @@ import { parse } from '@aws-sdk/util-arn-parser'
2828
import { isAwsError, ToolkitError } from '../../shared/errors'
2929
import { telemetry } from '../../shared/telemetry/telemetry'
3030
import { localize } from '../../shared/utilities/vsCodeUtils'
31-
import {
32-
getAvailableCustomizationsList,
33-
getSelectedCustomization,
34-
switchToBaseCustomizationAndNotify,
35-
} from '../util/customizationUtil'
3631

3732
// TODO: is there a better way to manage all endpoint strings in one place?
3833
export const defaultServiceConfig: CodeWhispererConfig = {
@@ -41,7 +36,6 @@ export const defaultServiceConfig: CodeWhispererConfig = {
4136
}
4237

4338
// Hack until we have a single discovery endpoint. We will call each endpoint one by one to fetch profile before then.
44-
// TODO: update correct endpoint and region
4539
const endpoints = createConstantMap({
4640
'us-east-1': 'https://q.us-east-1.amazonaws.com/',
4741
'eu-central-1': 'https://q.eu-central-1.amazonaws.com/',
@@ -224,24 +218,6 @@ export class RegionProfileManager {
224218

225219
// persist to state
226220
await this.persistSelectRegionProfile()
227-
228-
// validate user's still has access to the selected customization
229-
const selectedCustomization = getSelectedCustomization()
230-
// no need to validate base customization which has empty arn
231-
if (selectedCustomization.arn.length > 0) {
232-
getAvailableCustomizationsList()
233-
.then((customizations) => {
234-
const r = customizations.find((it) => it.arn === selectedCustomization.arn)
235-
if (!r) {
236-
void switchToBaseCustomizationAndNotify().then()
237-
}
238-
})
239-
.catch((e) => {
240-
RegionProfileManager.logger.error(
241-
`encounter error while validating selected customization on profile change: ${(e as Error).message}`
242-
)
243-
})
244-
}
245221
}
246222

247223
restoreProfileSelection = once(async () => {

0 commit comments

Comments
 (0)