Skip to content

Commit 028b435

Browse files
committed
remove the usage of global variable
1 parent f6cdb18 commit 028b435

File tree

2 files changed

+18
-2
lines changed

2 files changed

+18
-2
lines changed

packages/amazonq/src/autoDebug/activation.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import { getLogger } from 'aws-core-vscode/shared'
88
import { AutoDebugCommands } from './commands'
99
import { AutoDebugCodeActionsProvider } from './codeActionsProvider'
1010
import { AutoDebugController } from './controller'
11+
import { registerAutoDebugFeature } from '../lsp/client'
1112

1213
/**
1314
* Auto Debug feature activation for Amazon Q
@@ -75,5 +76,9 @@ export class AutoDebugFeature implements vscode.Disposable {
7576
export async function activateAutoDebug(context: vscode.ExtensionContext): Promise<AutoDebugFeature> {
7677
const feature = new AutoDebugFeature(context)
7778
await feature.activate()
79+
80+
// Register the feature with the module-level registry
81+
registerAutoDebugFeature(feature)
82+
7883
return feature
7984
}

packages/amazonq/src/lsp/client.ts

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,17 @@ import { InlineTutorialAnnotation } from '../app/inline/tutorials/inlineTutorial
5252
import { InlineChatTutorialAnnotation } from '../app/inline/tutorials/inlineChatTutorialAnnotation'
5353
import { AutoDebugFeature } from '../autoDebug'
5454

55+
// Module-level registry for AutoDebug feature
56+
let registeredAutoDebugFeature: AutoDebugFeature | undefined
57+
58+
export function registerAutoDebugFeature(feature: AutoDebugFeature) {
59+
registeredAutoDebugFeature = feature
60+
}
61+
62+
export function getRegisteredAutoDebugFeature(): AutoDebugFeature | undefined {
63+
return registeredAutoDebugFeature
64+
}
65+
5566
const localize = nls.loadMessageBundle()
5667
const logger = getLogger('amazonqLsp.lspClient')
5768

@@ -299,9 +310,9 @@ async function onLanguageServerReady(
299310

300311
await retryWithExponentialBackoff(
301312
() => {
302-
const autoDebugFeature = (global as any).autoDebugFeature as AutoDebugFeature | undefined
313+
const autoDebugFeature = getRegisteredAutoDebugFeature()
303314
if (!autoDebugFeature) {
304-
throw new Error('AutoDebug feature not available')
315+
throw new Error('AutoDebug feature not registered')
305316
}
306317
const controller = autoDebugFeature.getController()
307318
if (!controller) {

0 commit comments

Comments
 (0)