tokens.ts 25 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030
  1. // Copyright (c) Jupyter Development Team.
  2. // Distributed under the terms of the Modified BSD License.
  3. import { CodeEditor, CodeEditorWrapper } from '@jupyterlab/codeeditor';
  4. import { KernelMessage, Session } from '@jupyterlab/services';
  5. import { ReadonlyJSONObject, Token } from '@lumino/coreutils';
  6. import { IObservableDisposable } from '@lumino/disposable';
  7. import { ISignal, Signal } from '@lumino/signaling';
  8. import { Widget } from '@lumino/widgets';
  9. import { DebugProtocol } from '@vscode/debugprotocol';
  10. import { DebuggerHandler } from './handler';
  11. /**
  12. * An interface describing an application's visual debugger.
  13. */
  14. export interface IDebugger {
  15. /**
  16. * Signal emitted for debug event messages.
  17. */
  18. readonly eventMessage: ISignal<IDebugger, IDebugger.ISession.Event>;
  19. /**
  20. * Whether the current debugger is started.
  21. */
  22. readonly isStarted: boolean;
  23. /**
  24. * Whether the session is pausing for exceptions.
  25. */
  26. readonly isPausingOnExceptions: boolean;
  27. /**
  28. * The debugger service's model.
  29. */
  30. readonly model: IDebugger.Model.IService;
  31. /**
  32. * The current debugger session.
  33. */
  34. session: IDebugger.ISession | null;
  35. /**
  36. * Signal emitted upon session changed.
  37. */
  38. readonly sessionChanged: ISignal<IDebugger, IDebugger.ISession | null>;
  39. /**
  40. * Removes all the breakpoints from the current notebook or console
  41. */
  42. clearBreakpoints(): Promise<void>;
  43. /**
  44. * Used to determine if kernel has pause on exception capabilities
  45. */
  46. pauseOnExceptionsIsValid(): boolean;
  47. /**
  48. * Handles enabling and disabling of Pause on Exception
  49. */
  50. pauseOnExceptions(enable: boolean): Promise<void>;
  51. /**
  52. * Continues the execution of the current thread.
  53. */
  54. continue(): Promise<void>;
  55. /**
  56. * Evaluate an expression.
  57. */
  58. evaluate(
  59. expression: string
  60. ): Promise<DebugProtocol.EvaluateResponse['body'] | null>;
  61. /**
  62. * Computes an id based on the given code.
  63. */
  64. getCodeId(code: string): string;
  65. /**
  66. * Retrieve the content of a source file.
  67. *
  68. * @param source The source object containing the path to the file.
  69. */
  70. getSource(source: DebugProtocol.Source): Promise<IDebugger.Source>;
  71. /**
  72. * Whether there exist a thread in stopped state.
  73. */
  74. hasStoppedThreads(): boolean;
  75. /**
  76. * Request variables for a given variable reference.
  77. *
  78. * @param variablesReference The variable reference to request.
  79. */
  80. inspectVariable(
  81. variablesReference: number
  82. ): Promise<DebugProtocol.Variable[]>;
  83. /**
  84. * Request rich representation of a variable.
  85. *
  86. * @param variableName The variable name to request
  87. * @param frameId The current frame id in which to request the variable
  88. * @returns The mime renderer data model
  89. */
  90. inspectRichVariable(
  91. variableName: string,
  92. frameId?: number
  93. ): Promise<IDebugger.IRichVariable>;
  94. /**
  95. * Requests all the defined variables and display them in the
  96. * table view.
  97. */
  98. displayDefinedVariables(): Promise<void>;
  99. /**
  100. * Request whether debugging is available for the given session connection.
  101. *
  102. * @param connection The session connection.
  103. */
  104. isAvailable(connection: Session.ISessionConnection): Promise<boolean>;
  105. /**
  106. * Makes the current thread run again for one step.
  107. */
  108. next(): Promise<void>;
  109. /**
  110. * Requests all the loaded modules and display them.
  111. */
  112. displayModules(): Promise<void>;
  113. /**
  114. * Restart the debugger.
  115. * Precondition: isStarted
  116. */
  117. restart(): Promise<void>;
  118. /**
  119. * Restore the state of a debug session.
  120. *
  121. * @param autoStart - when true, starts the debugger
  122. * if it has not been started yet.
  123. */
  124. restoreState(autoStart: boolean): Promise<void>;
  125. /**
  126. * Starts a debugger.
  127. * Precondition: !isStarted
  128. */
  129. start(): Promise<void>;
  130. /**
  131. * Makes the current thread step in a function / method if possible.
  132. */
  133. stepIn(): Promise<void>;
  134. /**
  135. * Makes the current thread step out a function / method if possible.
  136. */
  137. stepOut(): Promise<void>;
  138. /**
  139. * Stops the debugger.
  140. * Precondition: isStarted
  141. */
  142. stop(): Promise<void>;
  143. /**
  144. * Update all breakpoints of a cell at once.
  145. *
  146. * @param code - The code in the cell where the breakpoints are set.
  147. * @param breakpoints - The list of breakpoints to set.
  148. * @param path - Optional path to the file where to set the breakpoints.
  149. */
  150. updateBreakpoints(
  151. code: string,
  152. breakpoints: IDebugger.IBreakpoint[],
  153. path?: string
  154. ): Promise<void>;
  155. /**
  156. * Get the debugger state
  157. *
  158. * @returns Debugger state
  159. */
  160. getDebuggerState(): IDebugger.State;
  161. /**
  162. * Restore the debugger state
  163. *
  164. * @param state Debugger state
  165. * @returns Whether the state has been restored successfully or not
  166. */
  167. restoreDebuggerState(state: IDebugger.State): Promise<boolean>;
  168. }
  169. /**
  170. * A namespace for visual debugger types.
  171. */
  172. export namespace IDebugger {
  173. /**
  174. * The type for a source file.
  175. */
  176. export type Source = {
  177. /**
  178. * The content of the source.
  179. */
  180. content: string;
  181. /**
  182. * The mimeType of the source.
  183. */
  184. mimeType?: string;
  185. /**
  186. * The path of the source.
  187. */
  188. path: string;
  189. };
  190. /**
  191. * Single breakpoint in an editor.
  192. */
  193. export interface IBreakpoint extends DebugProtocol.Breakpoint {}
  194. /*
  195. * The state of the debugger, used for restoring a debugging session
  196. * after restarting the kernel.
  197. */
  198. export type State = {
  199. /**
  200. * List of cells to dump after the kernel has restarted
  201. */
  202. cells: string[];
  203. /**
  204. * Map of breakpoints to send back to the kernel after it has restarted
  205. */
  206. breakpoints: Map<string, IDebugger.IBreakpoint[]>;
  207. };
  208. /**
  209. * The type for a kernel source file.
  210. */
  211. export type KernelSource = {
  212. /**
  213. * The name of the source.
  214. */
  215. name: string;
  216. /**
  217. * The path of the source.
  218. */
  219. path: string;
  220. };
  221. /**
  222. * Debugger file and hashing configuration.
  223. */
  224. export interface IConfig {
  225. /**
  226. * Returns an id based on the given code.
  227. *
  228. * @param code The source code.
  229. * @param kernel The kernel name from current session.
  230. */
  231. getCodeId(code: string, kernel: string): string;
  232. /**
  233. * Sets the hash parameters for a kernel.
  234. *
  235. * @param params - Hashing parameters for a kernel.
  236. */
  237. setHashParams(params: IConfig.HashParams): void;
  238. /**
  239. * Sets the parameters used for the temp files (e.g. cells) for a kernel.
  240. *
  241. * @param params - Temporary file prefix and suffix for a kernel.
  242. */
  243. setTmpFileParams(params: IConfig.FileParams): void;
  244. /**
  245. * Gets the parameters used for the temp files (e.e. cells) for a kernel.
  246. *
  247. * @param kernel - The kernel name from current session.
  248. */
  249. getTmpFileParams(kernel: string): IConfig.FileParams;
  250. }
  251. /**
  252. * An interface for debugger handler.
  253. */
  254. export interface IHandler extends DebuggerHandler.IHandler {}
  255. /**
  256. * An interface for a scope.
  257. */
  258. export interface IScope {
  259. /**
  260. * The name of the scope.
  261. */
  262. name: string;
  263. /**
  264. * The list of variables.
  265. */
  266. variables: IVariable[];
  267. }
  268. /**
  269. * A visual debugger session.
  270. */
  271. export interface ISession extends IObservableDisposable {
  272. /**
  273. * The API session connection to connect to a debugger.
  274. */
  275. connection: Session.ISessionConnection | null;
  276. /*
  277. * Returns the initialize response .
  278. */
  279. readonly capabilities: DebugProtocol.Capabilities | undefined;
  280. /**
  281. * Whether the debug session is started.
  282. */
  283. readonly isStarted: boolean;
  284. /**
  285. * Whether the debug session is pausing on exceptions.
  286. */
  287. pausingOnExceptions: string[];
  288. /**
  289. * Whether the debug session is pausing on exceptions.
  290. */
  291. exceptionPaths: string[];
  292. /**
  293. * Get exception filters and default values.
  294. */
  295. exceptionBreakpointFilters:
  296. | DebugProtocol.ExceptionBreakpointsFilter[]
  297. | undefined;
  298. /**
  299. * Signal emitted for debug event messages.
  300. */
  301. readonly eventMessage: ISignal<
  302. IDebugger.ISession,
  303. IDebugger.ISession.Event
  304. >;
  305. /**
  306. * Restore the state of a debug session.
  307. */
  308. restoreState(): Promise<IDebugger.ISession.Response['debugInfo']>;
  309. /**
  310. * Send a debug request to the kernel.
  311. */
  312. sendRequest<K extends keyof IDebugger.ISession.Request>(
  313. command: K,
  314. args: IDebugger.ISession.Request[K]
  315. ): Promise<IDebugger.ISession.Response[K]>;
  316. /**
  317. * Start a new debug session.
  318. */
  319. start(): Promise<void>;
  320. /**
  321. * Stop a running debug session.
  322. */
  323. stop(): Promise<void>;
  324. }
  325. /**
  326. * A utility to find text editors used by the debugger.
  327. */
  328. export interface ISources {
  329. /**
  330. * Returns an array of editors for a source matching the current debug
  331. * session by iterating through all the widgets in each of the supported
  332. * debugger types (i.e., consoles, files, notebooks).
  333. *
  334. * @param params - The editor find parameters.
  335. */
  336. find(params: ISources.FindParams): CodeEditor.IEditor[];
  337. /**
  338. * Open a read-only editor in the main area.
  339. *
  340. * @param params - The editor open parameters.
  341. */
  342. open(params: ISources.OpenParams): void;
  343. }
  344. /**
  345. * The type for a stack frame
  346. */
  347. export interface IStackFrame extends DebugProtocol.StackFrame {}
  348. /**
  349. * A reply to an rich inspection request.
  350. */
  351. export interface IRichVariable {
  352. /**
  353. * The MIME bundle data returned from an rich inspection request.
  354. */
  355. data: ReadonlyJSONObject;
  356. /**
  357. * Any metadata that accompanies the MIME bundle returning from a rich inspection request.
  358. */
  359. metadata: ReadonlyJSONObject;
  360. }
  361. /**
  362. * An interface for a variable.
  363. */
  364. export interface IVariable extends DebugProtocol.Variable {
  365. /**
  366. * Whether the variable is expanded.
  367. */
  368. expanded?: boolean;
  369. }
  370. /**
  371. * Debugger file and hashing configuration.
  372. */
  373. export namespace IConfig {
  374. /**
  375. * Temporary file prefix and suffix for a kernel.
  376. */
  377. export type FileParams = {
  378. /**
  379. * The kernel name.
  380. */
  381. kernel: string;
  382. /**
  383. * Prefix added to temporary files created by the kernel per cell.
  384. */
  385. prefix: string;
  386. /**
  387. * Suffix added temporary files created by the kernel per cell.
  388. */
  389. suffix: string;
  390. };
  391. /**
  392. * Hashing parameters for a kernel.
  393. */
  394. export type HashParams = {
  395. /**
  396. * The kernel name.
  397. */
  398. kernel: string;
  399. /**
  400. * The hashing method.
  401. */
  402. method: string;
  403. /**
  404. * An optional hashing seed provided by the kernel.
  405. */
  406. seed?: any;
  407. };
  408. }
  409. export namespace ISession {
  410. /**
  411. * A generic debug event.
  412. */
  413. export type Event = DebugProtocol.Event;
  414. /**
  415. * Expose all the debug requests types.
  416. */
  417. export type Request = {
  418. attach: DebugProtocol.AttachRequestArguments;
  419. completions: DebugProtocol.CompletionsArguments;
  420. configurationDone: DebugProtocol.ConfigurationDoneArguments;
  421. continue: DebugProtocol.ContinueArguments;
  422. debugInfo: {};
  423. disconnect: DebugProtocol.DisconnectArguments;
  424. dumpCell: IDumpCellArguments;
  425. evaluate: DebugProtocol.EvaluateArguments;
  426. exceptionInfo: DebugProtocol.ExceptionInfoArguments;
  427. goto: DebugProtocol.GotoArguments;
  428. gotoTargets: DebugProtocol.GotoTargetsArguments;
  429. initialize: DebugProtocol.InitializeRequestArguments;
  430. inspectVariables: {};
  431. launch: DebugProtocol.LaunchRequestArguments;
  432. loadedSources: DebugProtocol.LoadedSourcesArguments;
  433. modules: DebugProtocol.ModulesArguments;
  434. next: DebugProtocol.NextArguments;
  435. pause: DebugProtocol.PauseArguments;
  436. restart: DebugProtocol.RestartArguments;
  437. restartFrame: DebugProtocol.RestartFrameArguments;
  438. reverseContinue: DebugProtocol.ReverseContinueArguments;
  439. richInspectVariables: IRichVariablesArguments;
  440. scopes: DebugProtocol.ScopesArguments;
  441. setBreakpoints: DebugProtocol.SetBreakpointsArguments;
  442. setExceptionBreakpoints: DebugProtocol.SetExceptionBreakpointsArguments;
  443. setExpression: DebugProtocol.SetExpressionArguments;
  444. setFunctionBreakpoints: DebugProtocol.SetFunctionBreakpointsArguments;
  445. setVariable: DebugProtocol.SetVariableArguments;
  446. source: DebugProtocol.SourceArguments;
  447. stackTrace: DebugProtocol.StackTraceArguments;
  448. stepBack: DebugProtocol.StepBackArguments;
  449. stepIn: DebugProtocol.StepInArguments;
  450. stepInTargets: DebugProtocol.StepInTargetsArguments;
  451. stepOut: DebugProtocol.StepOutArguments;
  452. terminate: DebugProtocol.TerminateArguments;
  453. terminateThreads: DebugProtocol.TerminateThreadsArguments;
  454. threads: {};
  455. variables: DebugProtocol.VariablesArguments;
  456. };
  457. /**
  458. * Expose all the debug response types.
  459. */
  460. export type Response = {
  461. attach: DebugProtocol.AttachResponse;
  462. completions: DebugProtocol.CompletionsResponse;
  463. configurationDone: DebugProtocol.ConfigurationDoneResponse;
  464. continue: DebugProtocol.ContinueResponse;
  465. debugInfo: IDebugInfoResponse;
  466. disconnect: DebugProtocol.DisconnectResponse;
  467. dumpCell: IDumpCellResponse;
  468. evaluate: DebugProtocol.EvaluateResponse;
  469. exceptionInfo: DebugProtocol.ExceptionInfoResponse;
  470. goto: DebugProtocol.GotoResponse;
  471. gotoTargets: DebugProtocol.GotoTargetsResponse;
  472. initialize: DebugProtocol.InitializeResponse;
  473. inspectVariables: IInspectVariablesResponse;
  474. launch: DebugProtocol.LaunchResponse;
  475. loadedSources: DebugProtocol.LoadedSourcesResponse;
  476. modules: DebugProtocol.ModulesResponse;
  477. next: DebugProtocol.NextResponse;
  478. pause: DebugProtocol.PauseResponse;
  479. restart: DebugProtocol.RestartResponse;
  480. restartFrame: DebugProtocol.RestartFrameResponse;
  481. reverseContinue: DebugProtocol.ReverseContinueResponse;
  482. richInspectVariables: IRichVariablesResponse;
  483. scopes: DebugProtocol.ScopesResponse;
  484. setBreakpoints: DebugProtocol.SetBreakpointsResponse;
  485. setExceptionBreakpoints: DebugProtocol.SetExceptionBreakpointsResponse;
  486. setExpression: DebugProtocol.SetExpressionResponse;
  487. setFunctionBreakpoints: DebugProtocol.SetFunctionBreakpointsResponse;
  488. setVariable: DebugProtocol.SetVariableResponse;
  489. source: DebugProtocol.SourceResponse;
  490. stackTrace: DebugProtocol.StackTraceResponse;
  491. stepBack: DebugProtocol.StepBackResponse;
  492. stepIn: DebugProtocol.StepInResponse;
  493. stepInTargets: DebugProtocol.StepInTargetsResponse;
  494. stepOut: DebugProtocol.StepOutResponse;
  495. terminate: DebugProtocol.TerminateResponse;
  496. terminateThreads: DebugProtocol.TerminateThreadsResponse;
  497. threads: DebugProtocol.ThreadsResponse;
  498. variables: DebugProtocol.VariablesResponse;
  499. };
  500. /**
  501. * List of breakpoints in a source file.
  502. */
  503. export interface IDebugInfoBreakpoints {
  504. source: string;
  505. breakpoints: DebugProtocol.SourceBreakpoint[];
  506. }
  507. /**
  508. * Response to 'debugInfo' request.
  509. * This is an addition to the Debug Adapter Protocol to be able
  510. * to retrieve the debugger state when restoring a session.
  511. */
  512. export interface IDebugInfoResponse extends DebugProtocol.Response {
  513. body: {
  514. breakpoints: IDebugInfoBreakpoints[];
  515. hashMethod: string;
  516. hashSeed: number;
  517. isStarted: boolean;
  518. /**
  519. * Whether the kernel supports variable rich rendering or not.
  520. */
  521. richRendering?: boolean;
  522. tmpFilePrefix: string;
  523. tmpFileSuffix: string;
  524. stoppedThreads: number[];
  525. exceptionPaths: string[];
  526. };
  527. }
  528. /**
  529. * Arguments for 'dumpCell' request.
  530. * This is an addition to the Debug Adapter Protocol to support
  531. * setting breakpoints for cells.
  532. */
  533. export interface IDumpCellArguments {
  534. code: string;
  535. }
  536. /**
  537. * Response to 'dumpCell' request.
  538. * This is an addition to the Debug Adapter Protocol to support
  539. * setting breakpoints for cells.
  540. */
  541. export interface IDumpCellResponse extends DebugProtocol.Response {
  542. body: {
  543. sourcePath: string;
  544. };
  545. }
  546. export interface IInspectVariablesResponse extends DebugProtocol.Response {
  547. body: {
  548. variables: DebugProtocol.Variable[];
  549. };
  550. }
  551. /**
  552. * Arguments for 'richVariables' request
  553. *
  554. * This is an addition to the Debug Adapter Protocol to support
  555. * render rich variable representation.
  556. */
  557. export interface IRichVariablesArguments {
  558. /**
  559. * Variable name
  560. */
  561. variableName: string;
  562. /**
  563. * Frame Id
  564. */
  565. frameId?: number;
  566. }
  567. /**
  568. * Arguments for 'richVariables' request
  569. *
  570. * This is an addition to the Debug Adapter Protocol to support
  571. * rich rendering of variables.
  572. */
  573. export interface IRichVariablesResponse extends DebugProtocol.Response {
  574. /**
  575. * Variable mime type data
  576. */
  577. body: IRichVariable;
  578. }
  579. /**
  580. * Response to the 'kernel_info_request' request.
  581. * This interface extends the IInfoReply by adding the `debugger` key
  582. * that isn't part of the protocol yet.
  583. * See this pull request for more info: https://github.com/jupyter/jupyter_client/pull/486
  584. */
  585. export interface IInfoReply extends KernelMessage.IInfoReply {
  586. debugger: boolean;
  587. }
  588. }
  589. /**
  590. * Select variable in the variables explorer.
  591. *
  592. * @hidden
  593. *
  594. * #### Notes
  595. * This is experimental API
  596. */
  597. export interface IVariableSelection
  598. extends Pick<
  599. DebugProtocol.Variable,
  600. 'name' | 'type' | 'variablesReference' | 'value'
  601. > {}
  602. /**
  603. * Debugger sidebar interface.
  604. */
  605. export interface ISidebar extends Widget {
  606. /**
  607. * Add item at the end of the sidebar.
  608. */
  609. addItem(widget: Widget): void;
  610. /**
  611. * Insert item at a specified index.
  612. */
  613. insertItem(index: number, widget: Widget): void;
  614. /**
  615. * Return all items that were added to sidebar.
  616. */
  617. readonly items: readonly Widget[];
  618. }
  619. /**
  620. * A utility to find text editors used by the debugger.
  621. */
  622. export namespace ISources {
  623. /**
  624. * Unified parameters for the find method
  625. */
  626. export type FindParams = {
  627. /**
  628. * Extra flag to focus on the parent widget of the editor.
  629. */
  630. focus: boolean;
  631. /**
  632. * Name of current kernel.
  633. */
  634. kernel: string;
  635. /**
  636. * Path of session connection.
  637. */
  638. path: string;
  639. /**
  640. * Source path
  641. */
  642. source: string;
  643. };
  644. /**
  645. * Unified parameters for the open method
  646. */
  647. export type OpenParams = {
  648. /**
  649. * The caption for the read-only editor.
  650. */
  651. caption: string;
  652. /**
  653. * The code editor wrapper to add to the main area.
  654. */
  655. editorWrapper: CodeEditorWrapper;
  656. /**
  657. * The label for the read-only editor.
  658. */
  659. label: string;
  660. };
  661. }
  662. /**
  663. * A namespace for UI model definitions.
  664. */
  665. export namespace Model {
  666. /**
  667. * The breakpoints UI model.
  668. */
  669. export interface IBreakpoints {
  670. /**
  671. * Get all the breakpoints.
  672. */
  673. readonly breakpoints: Map<string, IDebugger.IBreakpoint[]>;
  674. /**
  675. * Signal emitted when the model changes.
  676. */
  677. readonly changed: ISignal<this, IDebugger.IBreakpoint[]>;
  678. /**
  679. * Signal emitted when a breakpoint is clicked.
  680. */
  681. readonly clicked: Signal<this, IDebugger.IBreakpoint>;
  682. /**
  683. * Signal emitted when the breakpoints are restored.
  684. */
  685. readonly restored: ISignal<this, void>;
  686. /**
  687. * Get the breakpoints for a given id (path).
  688. *
  689. * @param id The code id (path).
  690. */
  691. getBreakpoints(id: string): IBreakpoint[];
  692. /**
  693. * Restore a map of breakpoints.
  694. *
  695. * @param breakpoints The map of breakpoints
  696. */
  697. restoreBreakpoints(breakpoints: Map<string, IBreakpoint[]>): void;
  698. /**
  699. * Set the breakpoints for a given id (path).
  700. *
  701. * @param id The code id (path).
  702. * @param breakpoints The list of breakpoints.
  703. */
  704. setBreakpoints(id: string, breakpoints: IBreakpoint[]): void;
  705. }
  706. /**
  707. * The callstack UI model.
  708. */
  709. export interface ICallstack {
  710. /**
  711. * Signal emitted when the current frame has changed.
  712. */
  713. readonly currentFrameChanged: ISignal<this, IDebugger.IStackFrame | null>;
  714. /**
  715. * The current frame.
  716. */
  717. frame: IDebugger.IStackFrame | null;
  718. /**
  719. * The frames for the callstack.
  720. */
  721. frames: IDebugger.IStackFrame[];
  722. /**
  723. * Signal emitted when the frames have changed.
  724. */
  725. readonly framesChanged: ISignal<this, IDebugger.IStackFrame[]>;
  726. }
  727. /**
  728. * The data model for the debugger service.
  729. */
  730. export interface IService {
  731. /**
  732. * The breakpoints UI model.
  733. */
  734. readonly breakpoints: IBreakpoints;
  735. /**
  736. * The callstack UI model.
  737. */
  738. readonly callstack: ICallstack;
  739. /**
  740. * Whether the kernel support rich variable rendering based on mime type.
  741. */
  742. hasRichVariableRendering: boolean;
  743. /**
  744. * The variables UI model.
  745. */
  746. readonly variables: IVariables;
  747. /**
  748. * The sources UI model.
  749. */
  750. readonly sources: ISources;
  751. /**
  752. * The kernel sources UI model.
  753. */
  754. readonly kernelSources: IKernelSources;
  755. /**
  756. * The set of threads in stopped state.
  757. */
  758. stoppedThreads: Set<number>;
  759. /**
  760. * The current debugger title.
  761. */
  762. title: string;
  763. /**
  764. * A signal emitted when the title changes.
  765. */
  766. titleChanged: ISignal<this, string>;
  767. /**
  768. * Clear the model.
  769. */
  770. clear(): void;
  771. }
  772. /**
  773. * The sources UI model.
  774. */
  775. export interface ISources {
  776. /**
  777. * Signal emitted when the current frame changes.
  778. */
  779. readonly currentFrameChanged: ISignal<
  780. IDebugger.Model.ICallstack,
  781. IDebugger.IStackFrame | null
  782. >;
  783. /**
  784. * Return the current source.
  785. */
  786. currentSource: IDebugger.Source | null;
  787. /**
  788. * Signal emitted when the current source changes.
  789. */
  790. readonly currentSourceChanged: ISignal<
  791. IDebugger.Model.ISources,
  792. IDebugger.Source | null
  793. >;
  794. /**
  795. * Signal emitted when a source should be open in the main area.
  796. */
  797. readonly currentSourceOpened: ISignal<
  798. IDebugger.Model.ISources,
  799. IDebugger.Source | null
  800. >;
  801. /**
  802. * Open a source in the main area.
  803. */
  804. open(): void;
  805. }
  806. /**
  807. * The kernel sources UI model.
  808. */
  809. export interface IKernelSources {
  810. /**
  811. * The kernel source.
  812. */
  813. kernelSources: IDebugger.KernelSource[] | null;
  814. /**
  815. * The filter to apply.
  816. */
  817. filter: string;
  818. /**
  819. * Signal emitted when the kernel sources have changed.
  820. */
  821. readonly changed: ISignal<
  822. IDebugger.Model.IKernelSources,
  823. IDebugger.KernelSource[] | null
  824. >;
  825. /**
  826. * Signal emitted when a kernel source has be opened in the main area.
  827. */
  828. readonly kernelSourceOpened: ISignal<
  829. IDebugger.Model.IKernelSources,
  830. IDebugger.Source | null
  831. >;
  832. /**
  833. * Open a source in the main area.
  834. */
  835. open(source: IDebugger.Source): void;
  836. }
  837. /**
  838. * The variables UI model.
  839. */
  840. export interface IVariables {
  841. /**
  842. * Signal emitted when the current variable has changed.
  843. */
  844. readonly changed: ISignal<this, void>;
  845. /**
  846. * The variable scopes.
  847. */
  848. scopes: IDebugger.IScope[];
  849. /**
  850. * Signal emitted when the current variable has been expanded.
  851. */
  852. readonly variableExpanded: ISignal<this, IDebugger.IVariable>;
  853. /**
  854. * Selected variable in the variables explorer.
  855. */
  856. selectedVariable: IVariableSelection | null;
  857. /**
  858. * Expand a variable.
  859. *
  860. * @param variable The variable to expand.
  861. */
  862. expandVariable(variable: IDebugger.IVariable): void;
  863. }
  864. }
  865. }
  866. /**
  867. * The visual debugger token.
  868. */
  869. export const IDebugger = new Token<IDebugger>('@jupyterlab/debugger:IDebugger');
  870. /**
  871. * The debugger configuration token.
  872. */
  873. export const IDebuggerConfig = new Token<IDebugger.IConfig>(
  874. '@jupyterlab/debugger:IDebuggerConfig'
  875. );
  876. /**
  877. * The debugger sources utility token.
  878. */
  879. export const IDebuggerSources = new Token<IDebugger.ISources>(
  880. '@jupyterlab/debugger:IDebuggerSources'
  881. );
  882. /**
  883. * The debugger configuration token.
  884. */
  885. export const IDebuggerSidebar = new Token<IDebugger.ISidebar>(
  886. '@jupyterlab/debugger:IDebuggerSidebar'
  887. );
  888. /**
  889. * The debugger handler token.
  890. */
  891. export const IDebuggerHandler = new Token<IDebugger.IHandler>(
  892. '@jupyterlab/debugger:IDebuggerHandler'
  893. );