configurationResolverExpression.ts ×18

Frontier kind: Code frontier

unlabeled · c_24f02932265e

2 tests · 42192 LOC · 197 files · introduces 0 tests · 125 LOC · 4 files

Introduces — evidence that enters the hierarchy at this concept

Code
29 ranges125 lines · 4 files
Tests
0 tests

Contains — complete concept membership

All code (extent)
3806 ranges42192 lines · 197 files · Browse complete extent
All tests (intent)
2 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.

4 files ranked by introduced lines: 125 introduced LOC across 29 ranges. Expand a file to inspect source; the > gutter marks introduced lines.

src/vs/workbench/services/configurationResolver/common/configurationResolverExpression.ts 84 introduced LOC · 18 ranges

Open complete file

76
77 private constructor(object: T) {
78 > // If the input is a string, wrap it in an object so we can use the same logic configurationResolverExpression.ts
79 > if (typeof object === 'string') {
80 this.stringRoot = true;
81 // eslint-disable-next-line local/code-no-any-casts
82 this.root = { value: object } as any;
84 > this.stringRoot = false;
85 > this.root = structuredClone(object);
86 > }
87 > }
88
89 /**
93 */
94 public static parse<T>(object: T): ConfigurationResolverExpression<T> {
95 > if (object instanceof ConfigurationResolverExpression) { configurationResolverExpression.ts
96 > return object;
97 > }
98 >
99 > const expr = new ConfigurationResolverExpression<T>(object);
100 > expr.applyPlatformSpecificKeys();
101 > expr.parseObject(expr.root);
102 > return expr;
103 > }
104
105 private applyPlatformSpecificKeys() {
106 > // eslint-disable-next-line local/code-no-any-casts configurationResolverExpression.ts
107 > const config = this.root as any; // already cloned by ctor, safe to change
108 > const key = isWindows ? 'windows' : isMacintosh ? 'osx' : isLinux ? 'linux' : undefined;
109 >
110 > if (key && config && typeof config === 'object' && config.hasOwnProperty(key)) {
111 Object.keys(config[key]).forEach(k => config[k] = config[key][k]);
112 }
114 > delete config.windows;
115 > delete config.osx;
116 > delete config.linux;
117 > }
118
119 private parseVariable(str: string, start: number): { replacement: Replacement; end: number } | undefined {
159
160 private parseObject(obj: any): void {
161 > if (typeof obj !== 'object' || obj === null) { configurationResolverExpression.ts
162 > return;
163 > }
164 >
165 > if (Array.isArray(obj)) {
166 > for (let i = 0; i < obj.length; i++) {
167 const value = obj[i];
168 if (typeof value === 'string') {
172 }
173 }
175 > }
176 >
177 > for (const [key, value] of Object.entries(obj)) {
178 > this.parseString(obj, key, key, true); // parse key
179 >
180 > if (typeof value === 'string') {
181 > this.parseString(obj, key, value);
182 > } else {
183 > this.parseObject(value);
184 > }
185 > }
186 > }
187
188 private parseString(object: any, propertyName: string | number, value: string, replaceKeyName?: boolean, replacementPath?: string[]): void {
190 > while (pos < value.length) {
191 > const match = value.indexOf('${', pos);
192 > if (match === -1) {
193 > break;
194 > }
195 const parsed = this.parseVariable(value, match);
196 if (parsed) {
213 pos = match + 2;
214 }
216 > }
217
218 public *unresolved(): Iterable<Replacement> {
219 > const newReplacements = new Map<string, Replacement>(); configurationResolverExpression.ts
220 > const notifier = (replacement: Replacement) => {
221 newReplacements.set(replacement.id, replacement);
222 };
224 > for (const location of this.locations.values()) {
225 if (location.resolved === undefined) {
226 newReplacements.set(location.replacement.id, location.replacement);
227 }
228 }
230 > this.newReplacementNotifiers.add(notifier);
231 >
232 > while (true) {
233 > const next = Iterable.first(newReplacements);
234 > if (!next) {
235 > break;
236 > }
237
238 const [key, value] = next;
240 newReplacements.delete(key);
241 }
243 > this.newReplacementNotifiers.delete(notifier);
244 > }
245
246 public resolved(): Iterable<[Replacement, IResolvedValue]> {
247 > return Iterable.map(Iterable.filter(this.locations.values(), l => !!l.resolved), l => [l.replacement, l.resolved!]); configurationResolverExpression.ts
248 > }
249
250 public resolve(replacement: Replacement, data: string | IResolvedValue): void {
251 > if (typeof data !== 'object') { configurationResolverExpression.ts
252 > data = { value: String(data) };
253 > }
254 >
255 > const location = this.locations.get(replacement.id);
256 > if (!location) {
257 > return;
258 > }
259
260 location.resolved = data;
265 }
266 }
268
269 private _resolveAtLocation(replacement: Replacement, { replaceKeyName, propertyName, object }: PropertyLocation, data: IResolvedValue, path: string[] = []) {
src/vs/workbench/contrib/mcp/common/mcpRegistry.ts 36 introduced LOC · 8 ranges

Open complete file

166
167 private _getInputStorage(scope: StorageScope): McpRegistryInputStorage {
168 > return scope === StorageScope.WORKSPACE ? this._workspaceStorage.value : this._profileStorage.value; mcpRegistry.ts
169 > }
170
171 private _getInputStorageInConfigTarget(configTarget: ConfigurationTarget): McpRegistryInputStorage {
172 > return this._getInputStorage( mcpRegistry.ts
173 > configTarget === ConfigurationTarget.WORKSPACE || configTarget === ConfigurationTarget.WORKSPACE_FOLDER
174 > ? StorageScope.WORKSPACE
175 : StorageScope.PROFILE
176 > ); mcpRegistry.ts
177 > }
178
179 public async clearSavedInputs(scope: StorageScope, inputId?: string) {
434
435 private async _updateStorageWithExpressionInputs(inputStorage: McpRegistryInputStorage, expr: ConfigurationResolverExpression<unknown>): Promise<void> {
436 > const secrets: Record<string, IResolvedValue> = {}; mcpRegistry.ts
437 > const inputs: Record<string, IResolvedValue> = {};
438 > for (const [replacement, resolved] of expr.resolved()) {
439 if (resolved.input?.type === 'promptString' && resolved.input.password) {
440 secrets[replacement.id] = resolved;
443 }
444 }
446 > inputStorage.setPlainText(inputs);
447 > await inputStorage.setSecrets(secrets);
448 > this._onDidChangeInputs.fire();
449 > }
450
451 private async _replaceVariablesInLaunch(delegate: IMcpHostDelegate, definition: McpServerDefinition, launch: McpServerLaunch, errorOnUserInteraction?: boolean) {
453 return launch;
454 }
456 > const { section, target, folder } = definition.variableReplacement;
457 > const inputStorage = this._getInputStorageInConfigTarget(target);
458 > const [previouslyStored, withRemoteFilled] = await Promise.all([
459 > inputStorage.getMap(),
460 > delegate.substituteVariables(definition, launch),
461 > ]);
462 >
463 > // pre-fill the variables we already resolved to avoid extra prompting
464 > const expr = ConfigurationResolverExpression.parse(withRemoteFilled);
465 > for (const replacement of expr.unresolved()) {
466 if (previouslyStored.hasOwnProperty(replacement.id)) {
467 expr.resolve(replacement, previouslyStored[replacement.id]);
468 }
469 }
471 > // Check if there are still unresolved variables that would require interaction
472 > if (errorOnUserInteraction) {
473 const unresolved = Array.from(expr.unresolved());
474 if (unresolved.length > 0) {
476 }
477 }
478 > // resolve variables requiring user input mcpRegistry.ts
479 > await this._configurationResolverService.resolveWithInteraction(folder, expr, section, undefined, target);
480 >
481 > await this._updateStorageWithExpressionInputs(inputStorage, expr);
482 >
483 > // resolve other non-interactive variables, returning the final object
484 > return await this._configurationResolverService.resolveAsync(folder, expr);
485 }
486
src/vs/workbench/contrib/mcp/common/mcpRegistryInputStorage.ts 3 introduced LOC · 1 range

Open complete file

131 return this._secretsSealerSequencer.queue(async () => {
132 if (!this._record.value.unsealedSecrets || isEmptyObject(this._record.value.unsealedSecrets)) {
133 > this._record.value.secrets = undefined; mcpRegistryInputStorage.ts
134 > return;
135 > }
136
137 const toSeal = JSON.stringify(this._record.value.unsealedSecrets);
src/vs/base/common/iterator.ts 2 introduced LOC · 2 ranges

Open complete file

82 export function filter<T>(iterable: Iterable<T>, predicate: (t: T) => boolean): Iterable<T>;
83 export function* filter<T>(iterable: Iterable<T>, predicate: (t: T) => boolean): Iterable<T> {
84 > for (const element of iterable) { iterator.ts
85 if (predicate(element)) {
86 yield element;
87 }
88 }
89 > } iterator.ts
90
91 export function* map<T, R>(iterable: Iterable<T>, fn: (t: T, index: number) => R): Iterable<R> {