Skip to content

Commit 00ec229

Browse files
st0012ko1
authored andcommitted
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 49514f6 commit 00ec229

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
@@ -435,15 +435,15 @@ def process_protocol_request req
435435
case req['command']
436436
when 'stepBack'
437437
if @tc.recorder&.can_step_back?
438-
@tc << [:step, :back]
438+
request_tc [:step, :back]
439439
else
440440
fail_response req, message: 'cancelled'
441441
end
442442

443443
when 'stackTrace'
444444
tid = req.dig('arguments', 'threadId')
445445
if tc = find_waiting_tc(tid)
446-
tc << [:dap, :backtrace, req]
446+
request_tc [:dap, :backtrace, req]
447447
else
448448
fail_response req
449449
end
@@ -452,7 +452,7 @@ def process_protocol_request req
452452
if @frame_map[frame_id]
453453
tid, fid = @frame_map[frame_id]
454454
if tc = find_waiting_tc(tid)
455-
tc << [:dap, :scopes, req, fid]
455+
request_tc [:dap, :scopes, req, fid]
456456
else
457457
fail_response req
458458
end
@@ -484,7 +484,7 @@ def process_protocol_request req
484484
tid, fid = @frame_map[frame_id]
485485

486486
if tc = find_waiting_tc(tid)
487-
tc << [:dap, :scope, req, fid]
487+
request_tc [:dap, :scope, req, fid]
488488
else
489489
fail_response req
490490
end
@@ -493,7 +493,7 @@ def process_protocol_request req
493493
tid, vid = ref[1], ref[2]
494494

495495
if tc = find_waiting_tc(tid)
496-
tc << [:dap, :variable, req, vid]
496+
request_tc [:dap, :variable, req, vid]
497497
else
498498
fail_response req
499499
end
@@ -511,7 +511,7 @@ def process_protocol_request req
511511
tid, fid = @frame_map[frame_id]
512512
expr = req.dig('arguments', 'expression')
513513
if tc = find_waiting_tc(tid)
514-
tc << [:dap, :evaluate, req, fid, expr, context]
514+
request_tc [:dap, :evaluate, req, fid, expr, context]
515515
else
516516
fail_response req
517517
end
@@ -537,7 +537,7 @@ def process_protocol_request req
537537
if col = req.dig('arguments', 'column')
538538
text = text.split(/\n/)[line.to_i - 1][0...(col.to_i - 1)]
539539
end
540-
tc << [:dap, :completions, req, fid, text]
540+
request_tc [:dap, :completions, req, fid, text]
541541
else
542542
fail_response req
543543
end

0 commit comments

Comments
 (0)