| 81 | * @see https://microsoft.github.io/debug-adapter-protocol/overview for control flows |
| 82 | */ |
| 83 | export class Binder implements IDisposable { |
| 84 | private readonly _disposables = new DisposableList(); |
| 85 | private _dap: Dap.Api; |
| 86 | private _targetOrigin: ITargetOrigin; |
| 87 | private _launchParams?: AnyLaunchConfiguration; |
| 88 | private _asyncStackPolicy?: IAsyncStackPolicy; |
| 89 | private _serviceTree = new WeakMap<ITarget, Container>(); |
| 90 | |
| 91 | /** Root of the session tree. Undefined until a launch/attach request is received. */ |
| 92 | private _root = new TreeNode(undefined); |
| 93 | |
| 94 | constructor( |
| 95 | private readonly _delegate: IBinderDelegate, |
| 96 | connection: DapConnection, |
| 97 | private readonly _rootServices: Container, |
| 98 | targetOrigin: ITargetOrigin, |
| 99 | ) { |
| 100 | this._dap = connection.dap(); |
| 101 | this._targetOrigin = targetOrigin; |
| 102 | this._disposables.callback(() => disposeContainer(_rootServices)); |
| 103 | this._disposables.push( |
| 104 | installUnhandledErrorReporter( |
| 105 | _rootServices.get(ILogger), |
| 106 | _rootServices.get(ITelemetryReporter), |
| 107 | _rootServices.get(IsVSCode), |
| 108 | ), |
| 109 | ); |
| 110 | |
| 111 | connection.attachTelemetry(_rootServices.get(ITelemetryReporter)); |
| 112 | |
| 113 | const dap = this._dap; |
| 114 | let lastBreakpointId = 0; |
| 115 | let selfProfile: SelfProfile | undefined; |
| 116 | |
| 117 | dap.on('initialize', async clientCapabilities => { |
| 118 | this._rootServices.bind(IInitializeParams).toConstantValue(clientCapabilities); |
| 119 | const capabilities = DebugAdapter.capabilities(); |
| 120 | if (clientCapabilities.clientID === 'vscode') { |
| 121 | filterErrorsReportedToTelemetry(); |
| 122 | } |
| 123 | |
| 124 | setTimeout(() => dap.initialized({}), 0); |
| 125 | return capabilities; |
| 126 | }); |
| 127 | dap.on('setExceptionBreakpoints', async () => ({})); |
| 128 | dap.on('setBreakpoints', async params => { |
| 129 | if (params.breakpoints?.length) { |
| 130 | _rootServices.get(DiagnosticToolSuggester).notifyHadBreakpoint(); |
| 131 | } |
| 132 | |
| 133 | return { |
| 134 | breakpoints: params.breakpoints?.map(() => ({ |
| 135 | id: ++lastBreakpointId, |
| 136 | verified: false, |
| 137 | message: l10n.t('Unbound breakpoint'), |
| 138 | })) ?? [], |
| 139 | }; |
| 140 | }); |
nothing calls this directly
no test coverage detected