-
Notifications
You must be signed in to change notification settings - Fork 2
CHANGE: @W-17970149@: The beginnings of refactorings to start removin global state ... #188
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
…g global state and make the code more testable
31652f2
to
e453af1
Compare
let diagnosticCollection: vscode.DiagnosticCollection = null; | ||
|
||
let telemetryService: TelemetryServiceImpl = null; | ||
|
||
let customCancellationToken: vscode.CancellationTokenSource | null = null; | ||
|
||
let outputChannel: vscode.LogOutputChannel; | ||
|
||
let sfgeCachePath: string = null; | ||
|
||
let settingsManager: SettingsManager = null; | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The goal over time will be to remove all this global state slowly but surely.
this.coreTelemetryService.sendExtensionActivationEvent(hrStart); | ||
} | ||
|
||
sendCommandEvent(commandName: string, properties: Record<string, string>): void { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tomorrow I'll create a PR separately to fix the tabs vs spaces inconsistencies.
src/apexguru/apex-guru-service.ts
Outdated
@@ -56,7 +56,7 @@ export async function runApexGuruOnFile(selection: vscode.Uri, runInfo: RunInfo) | |||
// TODO: For testability, the diagnostic manager should probably be passed in, not instantiated here. | |||
new DiagnosticManagerImpl(diagnosticCollection).displayAsDiagnostics([selection.fsPath], convertibles); | |||
// TODO: For testability, the telemetry service should probably be passed in, not instantiated here. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
TODO can be removed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed.
src/extension.ts
Outdated
@@ -117,9 +134,10 @@ export async function activate(context: vscode.ExtensionContext): Promise<vscode | |||
throw new Error(messages.targeting.error.noFileSelected); | |||
} | |||
return _runAndDisplayScanner(Constants.COMMAND_RUN_ON_ACTIVE_FILE, [vscode.window.activeTextEditor.document.fileName], { | |||
telemetryService: telemetryService, | |||
telemetryService: await externalServiceProvider.getTelemetryService(), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there a reason not to use the telemetryService
you instantiate at line 99?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good catch. I was cleaning up my calls and missed this one.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed.
1b5a59c
to
e76f62d
Compare
… and make the code more testable
I'll have a part 2 refactoring in my next PR. But I don't want to overwhelm you both.