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

Updates to environment collection workspace API #182238

Merged
merged 21 commits into from
May 18, 2023
Merged

Conversation

karrtikr
Copy link
Contributor

For #182069

@karrtikr karrtikr requested a review from Tyriar May 12, 2023 22:33
src/vs/workbench/api/common/extHostTerminalService.ts Outdated Show resolved Hide resolved
src/vs/workbench/api/common/extHostTerminalService.ts Outdated Show resolved Hide resolved
src/vs/workbench/api/common/extHostTerminalService.ts Outdated Show resolved Hide resolved
Comment on lines 832 to 836
return {
...collection.getScopedEnvironmentVariableCollection(undefined), getScopedEnvironmentVariableCollection(scope) {
return collection!.getScopedEnvironmentVariableCollection(scope);
},
};
Copy link
Member

Choose a reason for hiding this comment

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

I think it would be simpler if you kept EnvironmentVariableCollection (or DefaultEnvironmentVariableCollection) and ScopedEnvironmentVariableCollection separate, instead of trying to keep them all maintained in a single class. So maintain a Map<extId, Map<scope, ScopedEnvironmentVariableCollection>> in BaseExtHostTerminalService

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Perhaps I misunderstand, but that would require to change how we consume it all around the codebase, so I'm not fond of the idea. For eg.

readonly collections: ReadonlyMap<string, IEnvironmentVariableCollection>,

Everywhere it is assumed collections is Map<extId, UnifiedExtensionCollectionObject> instead of Map<extId, Map<scope, ScopedEnvironmentVariableCollection>>.

Copy link
Member

Choose a reason for hiding this comment

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

Let’s keep going with what you’ve done. This is just the way I would have done it from the start but it looks like it would take a bunch of re-work. Let's make sure to have a bunch of tests around merging the scopes collections if they don't already exist.

}

replace(variable: string, value: string, scope?: vscode.EnvironmentVariableScope): void {
replace(variable: string, value: string, scope: vscode.EnvironmentVariableScope | undefined): void {
Copy link
Member

Choose a reason for hiding this comment

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

Guessing you just haven't got around to removing the scope??

Copy link
Contributor Author

@karrtikr karrtikr May 12, 2023

Choose a reason for hiding this comment

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

Let me clarify my design, where I have no plans of removing scope internally.

EnvironmentVariableCollection class is used only created once for each extension and then is passed around, that carries information for all the scopes. As scope is not present in constructor, it is present in each method in the class as a parameter; We should probably rename it to ExtensionOwnedEnvVarCollection.

The external vscode.EnvironmentVariableCollection is different from this, it does not have scope as a parameter.

Copy link
Member

Choose a reason for hiding this comment

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

We should probably rename it to ExtensionOwnedEnvVarCollection

Little confusing as they are by definition owned by an extension

Copy link
Contributor Author

@karrtikr karrtikr May 15, 2023

Choose a reason for hiding this comment

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

We can go something like the following if it's already clear that they're for a specific extension:

  • MergedExtensionEnvVarCollection
  • GlobalEnvironmentVariableCollection
  • ExtensionSpecificEnvironmentVariableCollection

Basically we want to indicate that it is a unified environment variable collection carrying information for all scopes, for a specific extension.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

ExtensionOwnedEnvVarCollection seemed appropriate as it is being used exactly that way in here:

private readonly map: Map<string, IExtensionOwnedEnvironmentVariableMutator[]> = new Map();

IExtensionOwnedEnvironmentVariableMutator(s) came from ExtensionOwnedEnvVarCollection.

Copy link
Member

Choose a reason for hiding this comment

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

IExtensionOwnedEnvironmentVariableMutator is just a mutator object but with the extension id attached. The environment variable collection is extension owned, but the mutator objects are owned by the collection and usually lack this property.

UnifiedEnvironmentVariableCollection is my favorite, but I'm not sure we should be renaming it as I believe it's only not-unified in the extension API. Adding "unified" throughout all usages wouldn't add much

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I like MergedExtensionEnvVarCollection because that's what it is, but I agree it probably wouldn't add much. I'll add comments clarifying where it is defined.

Copy link
Member

Choose a reason for hiding this comment

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

That's confusing though, merged environment variable collection is already a thing and the merging there means there is only a single value per mutator type + variable.

Copy link
Contributor Author

@karrtikr karrtikr May 18, 2023

Choose a reason for hiding this comment

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

We could remove the "Merge" part, ExtensionEnvironmentVariableCollection. I'll add comments regardless clarifying.

@karrtikr karrtikr requested a review from Tyriar May 18, 2023 19:12
@karrtikr karrtikr marked this pull request as ready for review May 18, 2023 19:12
@karrtikr karrtikr merged commit a1cccc5 into main May 18, 2023
@karrtikr karrtikr deleted the kartik/puzzled-harrier branch May 18, 2023 19:36
@github-actions github-actions bot locked and limited conversation to collaborators Jul 2, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants