Skip to content
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

fix: renamed context to extensionContext #4165

Conversation

jeffb-sfdc
Copy link
Contributor

@jeffb-sfdc jeffb-sfdc commented May 27, 2022

What does this PR do?

This PR renames instances of "context" to "extensionContext" to avoid confusion between ExtensionContext and WorkspaceContext variables.

What issues does this PR fix or reference?

#@W-11171762@

Functionality Before / Functionality After

No functionality change

@jeffb-sfdc jeffb-sfdc requested a review from a team as a code owner May 27, 2022 13:05
@@ -11,8 +11,7 @@ import { expect } from 'chai';
import * as path from 'path';
import { createSandbox, SinonStub } from 'sinon';
import { LibrarySourceRetrieveManifestExecutor } from '../../../src/commands/forceSourceRetrieveManifest';
import { workspaceContext } from '../../../src/context';
import { nls } from '../../../src/messages';
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jeffb-sfdc was NLS meant to be removed here too?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nls isn't used, so I removed it since workspaceContext (also not used) was removed.

@@ -80,7 +80,7 @@ class MockEnvironmentVariableCollection
}
}

export class MockContext implements ExtensionContext {
export class MockExtensionContext implements ExtensionContext {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I actually do really like this change here - much clearer what/why we're mocking 👍

@@ -4,24 +4,26 @@ import * as vscode from 'vscode';
import sinon, { stubInterface, stubObject } from 'ts-sinon';
import * as sinonChai from 'sinon-chai';
import { shared as lspCommon } from '@salesforce/lightning-lsp-common';
import { MockContext } from './MockContext';
import { MockExtensionContext } from './MockExtensionContext';
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just checking that the directory was renamed here as well? This was the case for all of the MockContext's?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, just the file was renamed. The path is packages/salesforcedx-vscode-lwc/test/vscode-integration/activation/MockExtensionContext.ts, and the parent directory, activation was not changed, just the filename.

Copy link
Contributor

@randi274 randi274 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Those are all my questions - I think refactoring here makes it much easier to understand the different type of contexts used, especially as folks onboard to the product. Perhaps it was clearer to previous maintainers what the differences were, but I'm supportive of changes that make we think will make it easier to develop going forward! Given that builds are working and tests are passing, I'm ok approving once @klewis-sfdc has reviewed them with you as well. Maybe we can plan for a larger spot check during next week's release too?

Copy link
Contributor

@klewis-sfdc klewis-sfdc left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the PR, Jeff! Overall, I really like the changes from

  • 👍🏽 "context" --> "extensionContext" and
  • 👍🏽 "MockContext" --> "MockExtensionContext",

but I'm not as in agreement with the changes to

  • ⚠️ add "Instance" into var names.

"Instance" is a technical implementation detail that IMO does not belong in the var name. I actually prefer the expression on the left side here:
image
I would prefer not to establish or continue this naming convention. Let me know what you think and how strongly you feel about wanting that change. Happy to discuss more in standup today!

@jeffb-sfdc
Copy link
Contributor Author

jeffb-sfdc commented Jun 2, 2022

but I'm not as in agreement with the changes to

  • ⚠️ add "Instance" into var names.

@klewis-sfdc done

Copy link
Contributor

@klewis-sfdc klewis-sfdc left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These changes look great @jeffb-sfdc. Thank you!

@jeffb-sfdc jeffb-sfdc merged commit c8edf0f into develop Jun 2, 2022
@jeffb-sfdc jeffb-sfdc deleted the jb/refactor-context-to-ExtensionContext-and-WorkspaceContext branch June 2, 2022 20:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants