|
18 | 18 |
|
19 | 19 | import {
|
20 | 20 | LoggingDebugSession, DebugSession, Logger, logger, InitializedEvent, OutputEvent, Thread, Source,
|
21 |
| - StoppedEvent, ContinuedEvent, StackFrame, TerminatedEvent |
| 21 | + StoppedEvent, ContinuedEvent, StackFrame, TerminatedEvent, Breakpoint as AdapterBreakpoint |
22 | 22 | } from 'vscode-debugadapter';
|
23 | 23 | import { DebugProtocol } from 'vscode-debugprotocol';
|
24 | 24 | import * as Fs from 'fs';
|
@@ -230,8 +230,55 @@ class IotjsDebugSession extends LoggingDebugSession {
|
230 | 230 | protected setBreakPointsRequest(
|
231 | 231 | response: DebugProtocol.SetBreakpointsResponse, args: DebugProtocol.SetBreakpointsArguments
|
232 | 232 | ): void {
|
233 |
| - this.log('setBreakPointsRequest: Not implemented yet'); |
| 233 | + this.log('setBreakPointsRequest'); |
| 234 | + |
| 235 | + const filename = args.source.name; |
| 236 | + const clientLines = args.lines || []; |
| 237 | + |
| 238 | + try { |
| 239 | + const scriptId = this._protocolhandler.getScriptIdByName(filename); |
| 240 | + |
| 241 | + const activeBp = this._protocolhandler.getActiveBreakpointsByScriptId(scriptId); |
| 242 | + const activeBpLines = activeBp.map(b => b.line); |
| 243 | + const newBp = clientLines.filter(b => activeBpLines.indexOf(b) === -1); |
| 244 | + const removeBp = activeBpLines.filter(b => clientLines.indexOf(b) === -1); |
| 245 | + const persistingBp = clientLines.filter(b => newBp.indexOf(b) === -1); |
| 246 | + |
| 247 | + let newBreakpoints = []; |
| 248 | + try { |
| 249 | + newBreakpoints = newBp.map(b => { |
| 250 | + const breakpoint = this._protocolhandler.findBreakpoint(scriptId, b); |
| 251 | + this._protocolhandler.updateBreakpoint(breakpoint, true); |
| 252 | + return <DebugProtocol.Breakpoint> new AdapterBreakpoint(true, b); |
| 253 | + }); |
| 254 | + } catch (error) { |
| 255 | + this.log(error.message); |
| 256 | + } |
| 257 | + |
| 258 | + try { |
| 259 | + removeBp.forEach(b => { |
| 260 | + const breakpoint = this._protocolhandler.findBreakpoint(scriptId, b); |
| 261 | + this._protocolhandler.updateBreakpoint(breakpoint, false); |
| 262 | + }); |
| 263 | + } catch (error) { |
| 264 | + this.log(error.message); |
| 265 | + } |
234 | 266 |
|
| 267 | + let persistingBreakpoints = []; |
| 268 | + try { |
| 269 | + persistingBreakpoints = persistingBp.map(b => { |
| 270 | + return <DebugProtocol.Breakpoint> new AdapterBreakpoint(true, b); |
| 271 | + }); |
| 272 | + } catch (error) { |
| 273 | + this.log(error.message); |
| 274 | + } |
| 275 | + |
| 276 | + response.body = { |
| 277 | + breakpoints: [...persistingBreakpoints, ...newBreakpoints] |
| 278 | + }; |
| 279 | + } catch (error) { |
| 280 | + this.log(error.message); |
| 281 | + } |
235 | 282 | this.sendResponse(response);
|
236 | 283 | }
|
237 | 284 |
|
|
0 commit comments