environmentVariableCollection.ts ×11

Frontier kind: Code frontier

unlabeled · c_bf60383f551e

1083 tests · 3539 LOC · 21 files · introduces 0 tests · 48 LOC · 1 file

Introduces — evidence that enters the hierarchy at this concept

Code
11 ranges48 lines · 1 files
Tests
0 tests

Contains — complete concept membership

All code (extent)
498 ranges3539 lines · 21 files · Browse complete extent
All tests (intent)
1083 testsBrowse complete intent

Neighbourhood graph

The orange circle is the focus. Violet and green circles are every ancestor and descendant, broader and narrower, at any distance; blue squares and pink diamonds are the introduced files and exact introduced tests of every visible concept, not only the focus's. Arrows point from broader to narrower concepts and bridge only concepts omitted from this view. Undirected links show source or test introduction. Concept and file size follows LOC; exact test nodes use test-count units.

Introduced files, introduced tests, and structurally relevant concept specialization

In the embedded map, ordinary wheel input scrolls the page; use the visible controls to zoom and drag to pan. Open the full-screen map for canvas navigation: wheel pans, Ctrl/Command plus wheel zooms, and arrow keys pan when this region is focused. On touch screens, open the full-screen map to pan or pinch. If JavaScript or WebGL is unavailable, use the native relationship evidence on this page.

Graph controls are ready.

Interactive rendering requires JavaScript and WebGL. Use the native relationship evidence on this page while the interactive map is unavailable.

Native relationship evidence

Every exact file and test below is linked only from the concept that introduces it.

Introduced tests

Every collected test enters the hierarchy at exactly one concept.

No tests are introduced at this concept. Its intent tests are introduced by other concepts.

Introduced code

Every collected source range enters the hierarchy at exactly one concept.

1 file ranked by introduced lines: 48 introduced LOC across 11 ranges. Expand a file to inspect source; the > gutter marks introduced lines.

src/vs/platform/terminal/common/environmentVariableCollection.ts 48 introduced LOC · 11 ranges

Open complete file

1 > /*--------------------------------------------------------------------------------------------- environmentVariableCollection.ts
2 > * Copyright (c) Microsoft Corporation. All rights reserved.
3 > * Licensed under the MIT License. See License.txt in the project root for license information.
4 > *--------------------------------------------------------------------------------------------*/
5 >
6 > import { IProcessEnvironment, isWindows } from '../../../base/common/platform.js';
7 > import { EnvironmentVariableMutatorType, EnvironmentVariableScope, IEnvironmentVariableCollection, IExtensionOwnedEnvironmentDescriptionMutator, IExtensionOwnedEnvironmentVariableMutator, IMergedEnvironmentVariableCollection, IMergedEnvironmentVariableCollectionDiff } from './environmentVariable.js';
8 >
9 > type VariableResolver = (str: string) => Promise<string>;
10 >
11 > const mutatorTypeToLabelMap: Map<EnvironmentVariableMutatorType, string> = new Map([
12 > [EnvironmentVariableMutatorType.Append, 'APPEND'],
13 > [EnvironmentVariableMutatorType.Prepend, 'PREPEND'],
14 > [EnvironmentVariableMutatorType.Replace, 'REPLACE']
15 > ]);
16 > const PYTHON_ACTIVATION_VARS_PATTERN = /^VSCODE_PYTHON_(PWSH|ZSH|BASH|FISH)_ACTIVATE/;
17 > const PYTHON_ENV_EXTENSION_ID = 'ms-python.vscode-python-envs';
18 >
19 > export class MergedEnvironmentVariableCollection implements IMergedEnvironmentVariableCollection {
20 > private readonly map: Map<string, IExtensionOwnedEnvironmentVariableMutator[]> = new Map();
21 > private readonly descriptionMap: Map<string, IExtensionOwnedEnvironmentDescriptionMutator[]> = new Map();
22 >
23 > constructor(
24 readonly collections: ReadonlyMap<string, IEnvironmentVariableCollection>,
25 ) {
68 });
69 }
71 > async applyToProcessEnvironment(env: IProcessEnvironment, scope: EnvironmentVariableScope | undefined, variableResolver?: VariableResolver): Promise<void> {
72 let lowerToActualVariableNames: { [lowerKey: string]: string | undefined } | undefined;
73 if (isWindows) {
106 }
107 }
109 > private _encodeColons(value: string): string {
110 return value.replaceAll(':', '\\x3a');
111 }
113 > private blockPythonActivationVar(variable: string, extensionIdentifier: string): boolean {
114 // Only Python env extension can modify Python activate env var.
115 if (PYTHON_ACTIVATION_VARS_PATTERN.test(variable) && PYTHON_ENV_EXTENSION_ID !== extensionIdentifier) {
118 return false;
119 }
121 > diff(other: IMergedEnvironmentVariableCollection, scope: EnvironmentVariableScope | undefined): IMergedEnvironmentVariableCollectionDiff | undefined {
122 const added: Map<string, IExtensionOwnedEnvironmentVariableMutator[]> = new Map();
123 const changed: Map<string, IExtensionOwnedEnvironmentVariableMutator[]> = new Map();
157 return { added, changed, removed };
158 }
160 > getVariableMap(scope: EnvironmentVariableScope | undefined): Map<string, IExtensionOwnedEnvironmentVariableMutator[]> {
161 const result = new Map<string, IExtensionOwnedEnvironmentVariableMutator[]>();
162 for (const mutators of this.map.values()) {
169 return result;
170 }
172 > getDescriptionMap(scope: EnvironmentVariableScope | undefined): Map<string, string | undefined> {
173 const result = new Map<string, string | undefined>();
174 for (const mutators of this.descriptionMap.values()) {
180 return result;
181 }
183 > private populateDescriptionMap(collection: IEnvironmentVariableCollection, extensionIdentifier: string): void {
184 if (!collection.descriptionMap) {
185 return;
209
210 }
212 >
213 > /**
214 > * Returns whether a mutator matches with the scope provided.
215 > * @param mutator Mutator to filter
216 > * @param scope Scope to be used for querying
217 > * @param strictFilter If true, mutators with global scope is not returned when querying for workspace scope.
218 > * i.e whether mutator scope should always exactly match with query scope.
219 > */
220 function filterScope(
221 mutator: IExtensionOwnedEnvironmentVariableMutator | IExtensionOwnedEnvironmentDescriptionMutator,
236 return false;
237 }
239 function getMissingMutatorsFromArray(
240 current: IExtensionOwnedEnvironmentVariableMutator[],
260 return result.length === 0 ? undefined : result;
261 }
263 function getChangedMutatorsFromArray(
264 current: IExtensionOwnedEnvironmentVariableMutator[],