| 150 | * Gets the container for a single target within a session. |
| 151 | */ |
| 152 | export const createTargetContainer = ( |
| 153 | parent: Container, |
| 154 | target: ITarget, |
| 155 | dap: Dap.Api, |
| 156 | cdp: Cdp.Api, |
| 157 | ) => { |
| 158 | const container = new Container(); |
| 159 | container.parent = parent; |
| 160 | container.bind(AnyLaunchConfiguration).toConstantValue(target.launchConfig); |
| 161 | container.bind(IContainer).toConstantValue(container); |
| 162 | container.bind(IDapApi).toConstantValue(dap); |
| 163 | container.bind(ICdpApi).toConstantValue(cdp); |
| 164 | container.bind(ITarget).toConstantValue(target); |
| 165 | container.bind(ITargetOrigin).toConstantValue(target.targetOrigin()); |
| 166 | container.bind(IResourceProvider).to(StatefulResourceProvider).inSingletonScope(); |
| 167 | container.bind(IClientCapabilies).to(ClientCapabilities).inSingletonScope(); |
| 168 | container.bind(ISourceMapFactory).to(SourceMapFactory).inSingletonScope(); |
| 169 | container.bind(IBreakpointConditionFactory).to(BreakpointConditionFactory).inSingletonScope(); |
| 170 | container.bind(LogPointCompiler).toSelf().inSingletonScope(); |
| 171 | |
| 172 | if (target.sourcePathResolver) { |
| 173 | container.bind(ISourcePathResolver).toConstantValue(target.sourcePathResolver); |
| 174 | } |
| 175 | |
| 176 | container.bind(PerformanceProviderFactory).toSelf(); |
| 177 | container |
| 178 | .bind(IPerformanceProvider) |
| 179 | .toDynamicValue(ctx => ctx.container.get(PerformanceProviderFactory).create()) |
| 180 | .inSingletonScope(); |
| 181 | |
| 182 | // nested children only run targeted search |
| 183 | if (target.parent()) { |
| 184 | container.bind(IBreakpointsPredictor).to(BreakpointsPredictor).inSingletonScope(); |
| 185 | container.bind(BreakpointSearch).to(TargetedBreakpointSearch).inSingletonScope(); |
| 186 | } |
| 187 | |
| 188 | container |
| 189 | .bind(ITelemetryReporter) |
| 190 | .to(process.env.DA_TEST_DISABLE_TELEMETRY ? NullTelemetryReporter : DapTelemetryReporter) |
| 191 | .inSingletonScope() |
| 192 | .onActivation(trackDispose); |
| 193 | |
| 194 | container.bind(BreakpointManager).toSelf().inSingletonScope(); |
| 195 | container.bind(SourceContainer).toSelf().inSingletonScope(); |
| 196 | container.bind(Diagnostics).toSelf().inSingletonScope(); |
| 197 | |
| 198 | container.bind(IScriptSkipper).to(ScriptSkipper).inSingletonScope().onActivation(trackDispose); |
| 199 | container.bind(SmartStepper).toSelf().inSingletonScope(); |
| 200 | container.bind(IExceptionPauseService).to(ExceptionPauseService).inSingletonScope(); |
| 201 | container.bind(ICompletions).to(Completions).inSingletonScope(); |
| 202 | container.bind(IEvaluator).to(Evaluator).inSingletonScope(); |
| 203 | container.bind(IConsole).to(Console).inSingletonScope(); |
| 204 | container.bind(IShutdownParticipants).to(ShutdownParticipants).inSingletonScope(); |
| 205 | container |
| 206 | .bind(IWasmSymbolProvider) |
| 207 | .to(WasmSymbolProvider) |
| 208 | .inSingletonScope() |
| 209 | .onActivation(trackDispose); |