in src/mockDebug.ts [74:125]
public constructor(fileAccessor: FileAccessor) {
super("mock-debug.txt");
// this debugger uses zero-based lines and columns
this.setDebuggerLinesStartAt1(false);
this.setDebuggerColumnsStartAt1(false);
this._runtime = new MockRuntime(fileAccessor);
// setup event handlers
this._runtime.on('stopOnEntry', () => {
this.sendEvent(new StoppedEvent('entry', MockDebugSession.threadID));
});
this._runtime.on('stopOnStep', () => {
this.sendEvent(new StoppedEvent('step', MockDebugSession.threadID));
});
this._runtime.on('stopOnBreakpoint', () => {
this.sendEvent(new StoppedEvent('breakpoint', MockDebugSession.threadID));
});
this._runtime.on('stopOnDataBreakpoint', () => {
this.sendEvent(new StoppedEvent('data breakpoint', MockDebugSession.threadID));
});
this._runtime.on('stopOnInstructionBreakpoint', () => {
this.sendEvent(new StoppedEvent('instruction breakpoint', MockDebugSession.threadID));
});
this._runtime.on('stopOnException', (exception) => {
if (exception) {
this.sendEvent(new StoppedEvent(`exception(${exception})`, MockDebugSession.threadID));
} else {
this.sendEvent(new StoppedEvent('exception', MockDebugSession.threadID));
}
});
this._runtime.on('breakpointValidated', (bp: IRuntimeBreakpoint) => {
this.sendEvent(new BreakpointEvent('changed', { verified: bp.verified, id: bp.id } as DebugProtocol.Breakpoint));
});
this._runtime.on('output', (text, filePath, line, column) => {
const e: DebugProtocol.OutputEvent = new OutputEvent(`${text}\n`);
if (text === 'start' || text === 'startCollapsed' || text === 'end') {
e.body.group = text;
e.body.output = `group-${text}\n`;
}
e.body.source = this.createSource(filePath);
e.body.line = this.convertDebuggerLineToClient(line);
e.body.column = this.convertDebuggerColumnToClient(column);
this.sendEvent(e);
});
this._runtime.on('end', () => {
this.sendEvent(new TerminatedEvent());
});
}