Skip to content

Commit 980079e

Browse files
committed
Use Session#request_tc to replace manual 'tc <<' calls
We should pass tc (ThreadClient)'s data in the Session in a uniformed way: either all with ivar or all with local variable. And since the local variable approach has been rejects (#293), we may want to go with @ivar. This change for unification is needed for later changes.
1 parent b22fca3 commit 980079e

File tree

3 files changed

+63
-61
lines changed

3 files changed

+63
-61
lines changed

lib/debug/server_cdp.rb

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -572,13 +572,13 @@ def fail_response req, **result
572572
def process_protocol_request req
573573
case req['method']
574574
when 'Debugger.stepOver', 'Debugger.stepInto', 'Debugger.stepOut', 'Debugger.resume', 'Debugger.enable'
575-
@tc << [:cdp, :backtrace, req]
575+
request_tc [:cdp, :backtrace, req]
576576
when 'Debugger.evaluateOnCallFrame'
577577
frame_id = req.dig('params', 'callFrameId')
578578
group = req.dig('params', 'objectGroup')
579579
if fid = @frame_map[frame_id]
580580
expr = req.dig('params', 'expression')
581-
@tc << [:cdp, :evaluate, req, fid, expr, group]
581+
request_tc [:cdp, :evaluate, req, fid, expr, group]
582582
else
583583
fail_response req,
584584
code: INVALID_PARAMS,
@@ -591,9 +591,9 @@ def process_protocol_request req
591591
when 'local'
592592
frame_id = ref[1]
593593
fid = @frame_map[frame_id]
594-
@tc << [:cdp, :scope, req, fid]
594+
request_tc [:cdp, :scope, req, fid]
595595
when 'properties'
596-
@tc << [:cdp, :properties, req, oid]
596+
request_tc [:cdp, :properties, req, oid]
597597
when 'script', 'global'
598598
# TODO: Support script and global types
599599
@ui.respond req, result: []

lib/debug/server_dap.rb

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -432,15 +432,15 @@ def process_protocol_request req
432432
case req['command']
433433
when 'stepBack'
434434
if @tc.recorder&.can_step_back?
435-
@tc << [:step, :back]
435+
request_tc [:step, :back]
436436
else
437437
fail_response req, message: 'cancelled'
438438
end
439439

440440
when 'stackTrace'
441441
tid = req.dig('arguments', 'threadId')
442442
if tc = find_waiting_tc(tid)
443-
tc << [:dap, :backtrace, req]
443+
request_tc [:dap, :backtrace, req]
444444
else
445445
fail_response req
446446
end
@@ -449,7 +449,7 @@ def process_protocol_request req
449449
if @frame_map[frame_id]
450450
tid, fid = @frame_map[frame_id]
451451
if tc = find_waiting_tc(tid)
452-
tc << [:dap, :scopes, req, fid]
452+
request_tc [:dap, :scopes, req, fid]
453453
else
454454
fail_response req
455455
end
@@ -481,7 +481,7 @@ def process_protocol_request req
481481
tid, fid = @frame_map[frame_id]
482482

483483
if tc = find_waiting_tc(tid)
484-
tc << [:dap, :scope, req, fid]
484+
request_tc [:dap, :scope, req, fid]
485485
else
486486
fail_response req
487487
end
@@ -490,7 +490,7 @@ def process_protocol_request req
490490
tid, vid = ref[1], ref[2]
491491

492492
if tc = find_waiting_tc(tid)
493-
tc << [:dap, :variable, req, vid]
493+
request_tc [:dap, :variable, req, vid]
494494
else
495495
fail_response req
496496
end
@@ -508,7 +508,7 @@ def process_protocol_request req
508508
tid, fid = @frame_map[frame_id]
509509
expr = req.dig('arguments', 'expression')
510510
if tc = find_waiting_tc(tid)
511-
tc << [:dap, :evaluate, req, fid, expr, context]
511+
request_tc [:dap, :evaluate, req, fid, expr, context]
512512
else
513513
fail_response req
514514
end
@@ -534,7 +534,7 @@ def process_protocol_request req
534534
if col = req.dig('arguments', 'column')
535535
text = text.split(/\n/)[line.to_i - 1][0...(col.to_i - 1)]
536536
end
537-
tc << [:dap, :completions, req, fid, text]
537+
request_tc [:dap, :completions, req, fid, text]
538538
else
539539
fail_response req
540540
end

0 commit comments

Comments
 (0)