MCPcopy Create free account
hub / github.com/deepnote/vscode-deepnote / constructor

Function constructor

src/notebooks/debugger/kernelDebugAdapterBase.ts:66–141  ·  view source on GitHub ↗
(
        protected session: DebugSession,
        protected notebookDocument: NotebookDocument,
        protected readonly jupyterSession: IKernelSession,
        private readonly kernel: IKernel | undefined,
        private readonly platformService: IPlatformService,
        private readonly debugService: IDebugService
    )

Source from the content-addressed store, hash-verified

64 public readonly debugCell: NotebookCell | undefined;
65 private disconnected: boolean = false;
66 constructor(
67 protected session: DebugSession,
68 protected notebookDocument: NotebookDocument,
69 protected readonly jupyterSession: IKernelSession,
70 private readonly kernel: IKernel | undefined,
71 private readonly platformService: IPlatformService,
72 private readonly debugService: IDebugService
73 ) {
74 logger.ci(`Creating kernel debug adapter for debugging notebooks`);
75 const configuration = this.session.configuration;
76 assertIsDebugConfig(configuration);
77 this.configuration = configuration;
78 this.debugCell = notebookDocument.cellAt(configuration.__cellIndex!);
79
80 this.addDebuggingDelegates([new ResetKernelController(this)]);
81
82 this.jupyterSession.kernel?.iopubMessage.connect(this.onIOPubMessage, this);
83 this.disposables.push(
84 new Disposable(() => this.jupyterSession.kernel?.iopubMessage.disconnect(this.onIOPubMessage, this))
85 );
86
87 if (this.kernel) {
88 this.kernel.addHook('willRestart', () => this.disconnect(), this, this.disposables);
89 this.kernel.addHook('interruptCompleted', () => this.disconnect(), this, this.disposables);
90 this.disposables.push(
91 this.kernel.onDisposed(() => {
92 if (!this.disconnected) {
93 debug.stopDebugging(this.session).then(noop, noop);
94 this.disconnect().catch(noop);
95 sendTelemetryEvent(DebuggingTelemetry.endedSession, undefined, { reason: 'onKernelDisposed' });
96 }
97 })
98 );
99 }
100
101 this.disposables.push(
102 notebookCellExecutions.onDidChangeNotebookCellExecutionState(
103 (cellStateChange: NotebookCellExecutionStateChangeEvent) => {
104 // If a cell has moved to idle, stop the debug session
105 if (
106 this.configuration.__cellIndex === cellStateChange.cell.index &&
107 cellStateChange.state === NotebookCellExecutionState.Idle &&
108 !this.disconnected
109 ) {
110 sendTelemetryEvent(DebuggingTelemetry.endedSession, undefined, { reason: 'normally' });
111 this.disconnect().catch(noop);
112 }
113 },
114 this,
115 this.disposables
116 )
117 );
118
119 this.disposables.push(
120 workspace.onDidChangeNotebookDocument(
121 (e) => {
122 e.contentChanges.forEach((change) => {
123 change.removedCells.forEach((cell: NotebookCell) => {

Callers

nothing calls this directly

Calls 13

assertIsDebugConfigFunction · 0.90
sendTelemetryEventFunction · 0.90
cellAtMethod · 0.80
addHookMethod · 0.80
ciMethod · 0.65
connectMethod · 0.65
pushMethod · 0.65
disconnectMethod · 0.65
onDisposedMethod · 0.45
forEachMethod · 0.45

Tested by

no test coverage detected