src/vs/platform/instantiation/common/instantiation.ts

130 LOC · 128 covered · 2 uncovered · 13 ranges · 13296 concepts · 6 introducers · 6860 tests

File neighbourhood

The centred file is linked to every concept that introduces one of its ranges, every test that runs code from the file, and the gray connector concepts standing between those tests and the file's own introducer concepts. Undirected links join concepts to every file where they introduce source and concepts to the tests they introduce; arrows show specialization between the displayed concepts and bridge only concepts omitted from this view. Concept colors match the source ranges below; connector concepts have no source color and are shown in gray.

Focused file, its introducer and connector concepts, their introduced files, and tests that run code from the file

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 related-file, concept, and source links on this page.

Focused file, its introducer and connector concepts, their introduced files, and tests that run code from the fileagentService.ts ×2 · 4 introduced LOCagentService.ts ×2chatImageExtraction.ts ×2 · 9 introduced LOCchatImageExtraction.ts ×…mapSessionEvents.ts ×2 · 10 introduced LOCmapSessionEvents.ts ×2mime.ts ×1 · 4 introduced LOCmime.ts ×1agentHostGitService.ts ×59 · 259 introduced LOCagentHostGitService.ts ×…ahpJsonlLogger.ts ×15 · 119 introduced LOCahpJsonlLogger.ts ×15fileService.ts ×18 · 102 introduced LOCfileService.ts ×18inMemoryFilesystemProvider.ts ×7 · 56 introduced LOCinMemoryFilesystemProvid…agentHostGitService.ts ×3 · 342 introduced LOCagentHostGitService.ts ×…environment.ts ×1 · 165 introduced LOCenvironment.ts ×1instantiation.ts ×1 · 2 introduced LOCinstantiation.ts ×1instantiationService.test|title=Instantiation Service service collection, cannot overwrite|occurrence=1 · 0 introduced LOCinstantiationService.tes…instantiation.ts ×1 · 2 introduced LOCinstantiation.ts ×1files.ts ×41 · 1348 introduced LOCfiles.ts ×41instantiation.ts ×1 · 2 introduced LOCinstantiation.ts ×1productService.ts ×1 · 17 introduced LOCproductService.ts ×1instantiation.ts ×1 · 1 introduced LOCinstantiation.ts ×1workspaceTags.ts ×1 · 31 introduced LOCworkspaceTags.ts ×1configuration.ts ×12 · 203 introduced LOCconfiguration.ts ×12instantiation.ts ×4 · 10 introduced LOCinstantiation.ts ×4telemetry.ts ×3 · 115 introduced LOCtelemetry.ts ×3instantiation.ts ×5 · 111 introduced LOCinstantiation.ts ×5ahpJsonlLogger.test|title=AhpJsonlLogger stringifyAhpLogEntry leaves URI-shaped objects without $mid as plain objects|occurrence=1 · introduced test · mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/platform/agentHost/test/common/ahpJsonlLogger.test|title=AhpJsonlLogger stringifyAhpLogEntry leaves URI-shaped objects without $mid as plain objects|occurrence=1ahpJsonlLogger.test|titl…agentHostGitService.test|title=AgentHostGitService exports the well-known empty-tree object SHA|occurrence=1 · introduced test · mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/platform/agentHost/test/node/agentHostGitService.test|title=AgentHostGitService exports the well-known empty-tree object SHA|occurrence=1agentHostGitService.test…agentService.test|title=AgentService (node dispatcher) user-message attachment rewriting snapshots Resource attachments by reading the original file and rewriting to a local snapshot|occurrence=1 · introduced test · mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/platform/agentHost/test/node/agentService.test|title=AgentService (node dispatcher) user-message attachment rewriting snapshots Resource attachments by reading the original file and rewriting to a local snapshot|occurrence=1agentService.test|title=…mapSessionEvents.test|title=mapSessionEvents — history replay restores best-effort model, fallback agent, and attachments onto user messages|occurrence=1 · introduced test · mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/platform/agentHost/test/node/mapSessionEvents.test|title=mapSessionEvents — history replay restores best-effort model, fallback agent, and attachments onto user messages|occurrence=1mapSessionEvents.test|ti… integration tests is broken #105562|occurrence=1 · introduced test · mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/platform/instantiation/test/common/instantiationService.test|title=Instantiation Service Remote window / integration tests is broken #105562|occurrence=1 integration tests is br…instantiationService.test|title=Instantiation Service service collection, cannot overwrite|occurrence=1 · introduced test · mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/platform/instantiation/test/common/instantiationService.test|title=Instantiation Service service collection, cannot overwrite|occurrence=1instantiationService.tes…chatImageExtraction.test|title=extractImagesFromToolInvocationMessages skips non-image URIs|occurrence=1 · introduced test · mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/workbench/contrib/chat/test/common/chatImageExtraction.test|title=extractImagesFromToolInvocationMessages skips non-image URIs|occurrence=1chatImageExtraction.test…workspaceTags.test|title=Telemetry - WorkspaceTags Multiple remotes hashed|occurrence=1 · introduced test · mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/workbench/contrib/tags/test/node/workspaceTags.test|title=Telemetry - WorkspaceTags Multiple remotes hashed|occurrence=1workspaceTags.test|title…Focused file · src/vs/platform/instantiation/common/instantiation.ts · 130 LOCcommon/instantiation.ts

Graph controls are ready.

Interactive rendering requires JavaScript and WebGL. Use the related-file, concept, and source links on this page while the interactive map is unavailable.

1 > /*--------------------------------------------------------------------------------------------- instantiation.ts ×5
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 { DisposableStore } from '../../../base/common/lifecycle.js';
7 > import * as descriptors from './descriptors.js';
8 > import { ServiceCollection } from './serviceCollection.js';
9 >
10 > // ------ internal util
11 >
12 > export namespace _util {
13 >
14 > export const serviceIds = new Map<string, ServiceIdentifier<any>>();
15 >
16 > export const DI_TARGET = '$di$target';
17 > export const DI_DEPENDENCIES = '$di$dependencies';
18 >
19 > export function getServiceDependencies(ctor: DI_TARGET_OBJ): { id: ServiceIdentifier<any>; index: number }[] {
20 > return ctor[DI_DEPENDENCIES] || []; instantiation.ts ×1
21 > }
23 > export interface DI_TARGET_OBJ extends Function {
24 > [DI_TARGET]: Function;
25 > [DI_DEPENDENCIES]: { id: ServiceIdentifier<any>; index: number }[];
26 > }
27 > }
28 >
29 > // --- interfaces ------
30 >
31 > export type BrandedService = { _serviceBrand: undefined };
32 >
33 > export interface IConstructorSignature<T, Args extends any[] = []> {
34 > new <Services extends BrandedService[]>(...args: [...Args, ...Services]): T;
35 > }
36 >
37 > export interface ServicesAccessor {
38 > get<T>(id: ServiceIdentifier<T>): T;
39 > }
40 >
41 > export const IInstantiationService = createDecorator<IInstantiationService>('instantiationService');
42 >
43 > /**
44 > * Given a list of arguments as a tuple, attempt to extract the leading, non-service arguments
45 > * to their own tuple.
46 > */
47 > export type GetLeadingNonServiceArgs<TArgs extends any[]> =
48 > TArgs extends [] ? []
49 > : TArgs extends [...infer TFirst, BrandedService] ? GetLeadingNonServiceArgs<TFirst>
50 > : TArgs;
51 >
52 > export interface IInstantiationService {
53 >
54 > readonly _serviceBrand: undefined;
55 >
56 > /**
57 > * Synchronously creates an instance that is denoted by the descriptor
58 > */
59 > createInstance<T>(descriptor: descriptors.SyncDescriptor0<T>): T;
60 > createInstance<Ctor extends new (...args: any[]) => unknown, R extends InstanceType<Ctor>>(ctor: Ctor, ...args: GetLeadingNonServiceArgs<ConstructorParameters<Ctor>>): R;
61 >
62 > /**
63 > * Calls a function with a service accessor.
64 > */
65 > invokeFunction<R, TS extends any[] = []>(fn: (accessor: ServicesAccessor, ...args: TS) => R, ...args: TS): R;
66 >
67 > /**
68 > * Creates a child of this service which inherits all current services
69 > * and adds/overwrites the given services.
70 > *
71 > * NOTE that the returned child is `disposable` and should be disposed when not used
72 > * anymore. This will also dispose all the services that this service has created.
73 > */
74 > createChild(services: ServiceCollection, store?: DisposableStore): IInstantiationService;
75 >
76 > /**
77 > * Disposes this instantiation service.
78 > *
79 > * - Will dispose all services that this instantiation service has created.
80 > * - Will dispose all its children but not its parent.
81 > * - Will NOT dispose services-instances that this service has been created with
82 > * - Will NOT dispose consumer-instances this service has created
83 > */
84 > dispose(): void;
85 > }
86 >
87 >
88 > /**
89 > * Identifies a service of type `T`.
90 > */
91 > export interface ServiceIdentifier<T> {
92 > (...args: any[]): void;
93 > type: T;
94 > }
95 >
96 >
97 > function storeServiceDependency(id: ServiceIdentifier<unknown>, target: Function, index: number): void { instantiation.ts ×4
98 > if ((target as _util.DI_TARGET_OBJ)[_util.DI_TARGET] === target) {
99 > (target as _util.DI_TARGET_OBJ)[_util.DI_DEPENDENCIES].push({ id, index }); instantiation.ts ×1
100 > } else { instantiation.ts ×4
101 > (target as _util.DI_TARGET_OBJ)[_util.DI_DEPENDENCIES] = [{ id, index }];
102 > (target as _util.DI_TARGET_OBJ)[_util.DI_TARGET] = target;
103 > }
104 > }
106 > /**
107 > * The *only* valid way to create a {{ServiceIdentifier}}.
108 > */
109 > export function createDecorator<T>(serviceId: string): ServiceIdentifier<T> {
110 >
111 > if (_util.serviceIds.has(serviceId)) {
112 > return _util.serviceIds.get(serviceId)!; instantiation.ts ×1
113 > }
115 > const id = function (target: Function, key: string, index: number) {
116 > if (arguments.length !== 3) { instantiation.ts ×4
117 throw new Error('@IServiceName-decorator can only be used to decorate a parameter');
118 }
119 > storeServiceDependency(id, target, index); instantiation.ts ×4
120 > } as ServiceIdentifier<T>;
122 > id.toString = () => serviceId;
123 >
124 > _util.serviceIds.set(serviceId, id);
125 > return id;
126 > }
127 >
128 > export function refineServiceDecorator<T1, T extends T1>(serviceIdentifier: ServiceIdentifier<T1>): ServiceIdentifier<T> {
129 > return <ServiceIdentifier<T>>serviceIdentifier; instantiation.ts ×1
130 > }