environmentVariableService.ts ×6

Frontier kind: Code frontier

unlabeled · c_cc70299f058d

4 tests · 24755 LOC · 134 files · introduces 0 tests · 275 LOC · 6 files

Introduces — evidence that enters the hierarchy at this concept

Code
16 ranges275 lines · 6 files
Tests
0 tests

Contains — complete concept membership

All code (extent)
2975 ranges24755 lines · 134 files · Browse complete extent
All tests (intent)
4 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.

6 files ranked by introduced lines: 275 introduced LOC across 16 ranges. Expand a file to inspect source; the > gutter marks introduced lines.

src/vs/workbench/services/history/common/history.ts 142 introduced LOC · 1 range

Open complete file

1 > /*--------------------------------------------------------------------------------------------- history.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 { createDecorator } from '../../../../platform/instantiation/common/instantiation.js';
7 > import { IResourceEditorInput } from '../../../../platform/editor/common/editor.js';
8 > import { GroupIdentifier } from '../../../common/editor.js';
9 > import { EditorInput } from '../../../common/editor/editorInput.js';
10 > import { URI } from '../../../../base/common/uri.js';
11 >
12 > export const IHistoryService = createDecorator<IHistoryService>('historyService');
13 >
14 > export const MOUSE_BACK_FORWARD_NAVIGATION_SETTING = 'workbench.editor.mouseBackForwardToNavigate';
15 >
16 > /**
17 > * Limit editor navigation to certain kinds.
18 > */
19 > export const enum GoFilter {
20 >
21 > /**
22 > * Navigate between editor navigation history
23 > * entries from any kind of navigation source.
24 > */
25 > NONE,
26 >
27 > /**
28 > * Only navigate between editor navigation history
29 > * entries that were resulting from edits.
30 > */
31 > EDITS,
32 >
33 > /**
34 > * Only navigate between editor navigation history
35 > * entries that were resulting from navigations, such
36 > * as "Go to definition".
37 > */
38 > NAVIGATION
39 > }
40 >
41 > /**
42 > * Limit editor navigation to certain scopes.
43 > */
44 > export const enum GoScope {
45 >
46 > /**
47 > * Navigate across all editors and editor groups.
48 > */
49 > DEFAULT,
50 >
51 > /**
52 > * Navigate only in editors of the active editor group.
53 > */
54 > EDITOR_GROUP,
55 >
56 > /**
57 > * Navigate only in the active editor.
58 > */
59 > EDITOR
60 > }
61 >
62 > export interface IHistoryService {
63 >
64 > readonly _serviceBrand: undefined;
65 >
66 > /**
67 > * Navigate forwards in editor navigation history.
68 > */
69 > goForward(filter?: GoFilter): Promise<void>;
70 >
71 > /**
72 > * Navigate backwards in editor navigation history.
73 > */
74 > goBack(filter?: GoFilter): Promise<void>;
75 >
76 > /**
77 > * Navigate between the current editor navigtion history entry
78 > * and the previous one that was navigated to. This commands is
79 > * like a toggle for `forward` and `back` to jump between 2 points
80 > * in editor navigation history.
81 > */
82 > goPrevious(filter?: GoFilter): Promise<void>;
83 >
84 > /**
85 > * Navigate to the last entry in editor navigation history.
86 > */
87 > goLast(filter?: GoFilter): Promise<void>;
88 >
89 > /**
90 > * Re-opens the last closed editor if any.
91 > */
92 > reopenLastClosedEditor(): Promise<void>;
93 >
94 > /**
95 > * Get the entire history of editors that were opened.
96 > */
97 > getHistory(): readonly (EditorInput | IResourceEditorInput)[];
98 >
99 > /**
100 > * Removes an entry from history.
101 > */
102 > removeFromHistory(input: EditorInput | IResourceEditorInput): void;
103 >
104 > /**
105 > * Looking at the editor history, returns the workspace root of the last file that was
106 > * inside the workspace and part of the editor history.
107 > *
108 > * @param schemeFilter filter to restrict roots by scheme.
109 > */
110 > getLastActiveWorkspaceRoot(schemeFilter?: string, authorityFilter?: string): URI | undefined;
111 >
112 > /**
113 > * Looking at the editor history, returns the resource of the last file that was opened.
114 > *
115 > * @param schemeFilter filter to restrict roots by scheme.
116 > */
117 > getLastActiveFile(schemeFilter: string, authorityFilter?: string): URI | undefined;
118 >
119 > /**
120 > * Opens the next used editor if any.
121 > *
122 > * @param group optional indicator to scope to a specific group.
123 > */
124 > openNextRecentlyUsedEditor(group?: GroupIdentifier): Promise<void>;
125 >
126 > /**
127 > * Opens the previously used editor if any.
128 > *
129 > * @param group optional indicator to scope to a specific group.
130 > */
131 > openPreviouslyUsedEditor(group?: GroupIdentifier): Promise<void>;
132 >
133 > /**
134 > * Clears all history.
135 > */
136 > clear(): void;
137 >
138 > /**
139 > * Clear list of recently opened editors.
140 > */
141 > clearRecentlyOpened(): void;
142 > }
src/vs/workbench/contrib/terminal/common/environmentVariableService.ts 93 introduced LOC · 6 ranges

Open complete file

1 > /*--------------------------------------------------------------------------------------------- environmentVariableService.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 { Event, Emitter } from '../../../../base/common/event.js';
7 > import { debounce, throttle } from '../../../../base/common/decorators.js';
8 > import { IStorageService, StorageScope, StorageTarget } from '../../../../platform/storage/common/storage.js';
9 > import { IExtensionService } from '../../../services/extensions/common/extensions.js';
10 > import { MergedEnvironmentVariableCollection } from '../../../../platform/terminal/common/environmentVariableCollection.js';
11 > import { deserializeEnvironmentDescriptionMap, deserializeEnvironmentVariableCollection, serializeEnvironmentDescriptionMap, serializeEnvironmentVariableCollection } from '../../../../platform/terminal/common/environmentVariableShared.js';
12 > import { IEnvironmentVariableCollectionWithPersistence, IEnvironmentVariableService } from './environmentVariable.js';
13 > import { TerminalStorageKeys } from './terminalStorageKeys.js';
14 > import { IMergedEnvironmentVariableCollection, ISerializableEnvironmentDescriptionMap, ISerializableEnvironmentVariableCollection } from '../../../../platform/terminal/common/environmentVariable.js';
15 > import { Disposable } from '../../../../base/common/lifecycle.js';
16 >
17 > interface ISerializableExtensionEnvironmentVariableCollection {
18 > extensionIdentifier: string;
19 > collection: ISerializableEnvironmentVariableCollection;
20 > description?: ISerializableEnvironmentDescriptionMap;
21 > }
22 >
23 > /**
24 > * Tracks and persists environment variable collections as defined by extensions.
25 > */
26 > export class EnvironmentVariableService extends Disposable implements IEnvironmentVariableService {
27 > declare readonly _serviceBrand: undefined;
28 >
29 > collections: Map<string, IEnvironmentVariableCollectionWithPersistence> = new Map();
30 > mergedCollection: IMergedEnvironmentVariableCollection;
31 >
32 > private readonly _onDidChangeCollections = this._register(new Emitter<IMergedEnvironmentVariableCollection>());
33 > get onDidChangeCollections(): Event<IMergedEnvironmentVariableCollection> { return this._onDidChangeCollections.event; }
34 >
35 > constructor(
36 > @IExtensionService private readonly _extensionService: IExtensionService,
37 > @IStorageService private readonly _storageService: IStorageService
38 > ) {
39 > super();
40 >
41 > this._storageService.remove(TerminalStorageKeys.DeprecatedEnvironmentVariableCollections, StorageScope.WORKSPACE);
42 > const serializedPersistedCollections = this._storageService.get(TerminalStorageKeys.EnvironmentVariableCollections, StorageScope.WORKSPACE);
43 > if (serializedPersistedCollections) {
44 const collectionsJson: ISerializableExtensionEnvironmentVariableCollection[] = JSON.parse(serializedPersistedCollections);
45 collectionsJson.forEach(c => this.collections.set(c.extensionIdentifier, {
54 this._invalidateExtensionCollections();
55 }
56 > this.mergedCollection = this._resolveMergedCollection(); environmentVariableService.ts
57 >
58 > // Listen for uninstalled/disabled extensions
59 > this._register(this._extensionService.onDidChangeExtensions(() => this._invalidateExtensionCollections()));
60 > }
61 >
62 > set(extensionIdentifier: string, collection: IEnvironmentVariableCollectionWithPersistence): void {
63 > this.collections.set(extensionIdentifier, collection);
64 > this._updateCollections();
65 > }
66 >
67 > delete(extensionIdentifier: string): void {
68 this.collections.delete(extensionIdentifier);
69 this._updateCollections();
70 }
72 > private _updateCollections(): void {
73 > this._persistCollectionsEventually();
74 > this.mergedCollection = this._resolveMergedCollection();
75 > this._notifyCollectionUpdatesEventually();
76 > }
77 >
78 > @throttle(1000)
79 > private _persistCollectionsEventually(): void {
80 > this._persistCollections();
81 > }
82 >
83 > protected _persistCollections(): void {
84 > const collectionsJson: ISerializableExtensionEnvironmentVariableCollection[] = [];
85 > this.collections.forEach((collection, extensionIdentifier) => {
86 > if (collection.persistent) {
87 > collectionsJson.push({
88 > extensionIdentifier,
89 > collection: serializeEnvironmentVariableCollection(this.collections.get(extensionIdentifier)!.map),
90 > description: serializeEnvironmentDescriptionMap(collection.descriptionMap)
91 > });
92 > }
93 > });
94 > const stringifiedJson = JSON.stringify(collectionsJson);
95 > this._storageService.store(TerminalStorageKeys.EnvironmentVariableCollections, stringifiedJson, StorageScope.WORKSPACE, StorageTarget.MACHINE);
96 > }
97 >
98 > @debounce(1000)
99 > private _notifyCollectionUpdatesEventually(): void {
100 this._notifyCollectionUpdates();
101 }
103 > protected _notifyCollectionUpdates(): void {
104 this._onDidChangeCollections.fire(this.mergedCollection);
105 }
107 > private _resolveMergedCollection(): IMergedEnvironmentVariableCollection {
108 > return new MergedEnvironmentVariableCollection(this.collections);
109 > }
110 >
111 > private async _invalidateExtensionCollections(): Promise<void> {
112 await this._extensionService.whenInstalledExtensionsRegistered();
113 const registeredExtensions = this._extensionService.extensions;
src/vs/workbench/contrib/terminal/common/terminalStorageKeys.ts 17 introduced LOC · 1 range

Open complete file

1 > /*--------------------------------------------------------------------------------------------- terminalStorageKeys.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 > export const enum TerminalStorageKeys {
7 > SuggestedRendererType = 'terminal.integrated.suggestedRendererType',
8 > TabsListWidthHorizontal = 'tabs-list-width-horizontal',
9 > TabsListWidthVertical = 'tabs-list-width-vertical',
10 > TabsShowDetailed = 'terminal.integrated.tabs.showDetailed',
11 > DeprecatedEnvironmentVariableCollections = 'terminal.integrated.environmentVariableCollections',
12 > EnvironmentVariableCollections = 'terminal.integrated.environmentVariableCollectionsV2',
13 > TerminalBufferState = 'terminal.integrated.bufferState',
14 > TerminalLayoutInfo = 'terminal.integrated.layoutInfo',
15 > PinnedRecentCommandsPrefix = 'terminal.pinnedRecentCommands',
16 > TerminalSuggestSize = 'terminal.integrated.suggestSize',
17 > }
src/vs/base/common/decorators.ts 11 introduced LOC · 3 ranges

Open complete file

69
70 return function (this: any, ...args: any[]) {
71 > if (!this[resultKey]) { decorators.ts
72 > this[resultKey] = initialValueProvider ? initialValueProvider() : undefined;
73 > }
74 >
75 > clearTimeout(this[timerKey]);
76 >
77 > if (reducer) {
78 this[resultKey] = reducer(this[resultKey], ...args);
79 args = [this[resultKey]];
80 }
82 > this[timerKey] = setTimeout(() => {
83 fn.apply(this, args);
84 this[resultKey] = initialValueProvider ? initialValueProvider() : undefined;
85 > }, delay); decorators.ts
86 > };
87 });
88 }
src/vs/platform/instantiation/test/common/instantiationServiceMock.ts 10 introduced LOC · 4 ranges

Open complete file

74 const stubObject = this._create(serviceMock, { stub: true }, service && !property);
75 if (property) {
76 > if (stubObject[property]) { instantiationServiceMock.ts
77 if (stubObject[property].hasOwnProperty('restore')) {
78 stubObject[property].restore();
87 return stub;
88 }
90 > stubObject[property] = value;
91 > }
92 > }
93 return stubObject;
94 }
123 const service: any = this._serviceCollection.get(serviceMock.id);
124 if (!reset && service) {
125 > if (opts.mock && service['sinonOptions'] && !!service['sinonOptions'].mock) { instantiationServiceMock.ts
126 return service;
127 }
128 > if (opts.stub && service['sinonOptions'] && !!service['sinonOptions'].stub) { instantiationServiceMock.ts
129 > return service;
130 > }
131 > }
132 return this._createService(serviceMock, opts);
133 }
src/vs/platform/terminal/common/environmentVariableShared.ts 2 introduced LOC · 1 range

Open complete file

13
14 export function serializeEnvironmentDescriptionMap(descriptionMap: ReadonlyMap<string, IEnvironmentVariableCollectionDescription> | undefined): ISerializableEnvironmentDescriptionMap {
15 > return descriptionMap ? [...descriptionMap.entries()] : []; environmentVariableShared.ts
16 > }
17
18 export function deserializeEnvironmentVariableCollection(