Skip to content

Commit b4ec2d7

Browse files
arikako1
authored andcommitted
suppress warnings about deprecated global variables
1 parent ec5ae5a commit b4ec2d7

File tree

3 files changed

+18
-7
lines changed

3 files changed

+18
-7
lines changed

lib/debug/server_cdp.rb

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -696,6 +696,8 @@ def puts result
696696
end
697697

698698
class Session
699+
include GlobalVariablesHelper
700+
699701
# FIXME: unify this method with ThreadClient#propertyDescriptor.
700702
def get_type obj
701703
case obj
@@ -750,7 +752,7 @@ def process_protocol_request req
750752
fid = @frame_map[frame_id]
751753
request_tc [:cdp, :scope, req, fid]
752754
when 'global'
753-
vars = global_variables.sort.map do |name|
755+
vars = safe_global_variables.sort.map do |name|
754756
gv = eval(name.to_s)
755757
prop = {
756758
name: name,
@@ -1040,7 +1042,7 @@ def process_cdp args
10401042
case expr
10411043
# Chrome doesn't read instance variables
10421044
when /\A\$\S/
1043-
global_variables.each{|gvar|
1045+
safe_global_variables.each{|gvar|
10441046
if gvar.to_s == expr
10451047
result = eval(gvar.to_s)
10461048
break false

lib/debug/server_dap.rb

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -516,6 +516,8 @@ def event type, *args
516516
end
517517

518518
class Session
519+
include GlobalVariablesHelper
520+
519521
def find_waiting_tc id
520522
@th_clients.each{|th, tc|
521523
return tc if tc.id == id && tc.waiting?
@@ -562,7 +564,7 @@ def process_protocol_request req
562564
if ref = @var_map[varid]
563565
case ref[0]
564566
when :globals
565-
vars = global_variables.sort.map do |name|
567+
vars = safe_global_variables.sort.map do |name|
566568
gv = eval(name.to_s)
567569
{
568570
name: name,
@@ -800,7 +802,7 @@ def process_dap args
800802
name: 'Global variables',
801803
presentationHint: 'globals',
802804
variablesReference: 1, # GLOBAL
803-
namedVariables: global_variables.size,
805+
namedVariables: safe_global_variables.size,
804806
indexedVariables: 0,
805807
expensive: false,
806808
}]
@@ -887,7 +889,7 @@ def process_dap args
887889
message = "Error: Not defined instance variable: #{expr.inspect}"
888890
end
889891
when /\A\$\S/
890-
global_variables.each{|gvar|
892+
safe_global_variables.each{|gvar|
891893
if gvar.to_s == expr
892894
result = eval(gvar.to_s)
893895
break false

lib/debug/thread_client.rb

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,13 @@ def skip_location?(loc)
3838
end
3939
end
4040

41+
module GlobalVariablesHelper
42+
SKIP_GLOBAL_LIST = %i[$= $KCODE $-K $SAFE].freeze
43+
def safe_global_variables
44+
global_variables.reject{|name| SKIP_GLOBAL_LIST.include? name }
45+
end
46+
end
47+
4148
class ThreadClient
4249
def self.current
4350
if thc = Thread.current[:DEBUGGER__ThreadClient]
@@ -50,6 +57,7 @@ def self.current
5057

5158
include Color
5259
include SkipPathHelper
60+
include GlobalVariablesHelper
5361

5462
attr_reader :thread, :id, :recorder, :check_bp_fulfillment_map
5563

@@ -636,9 +644,8 @@ def show_consts pat, expr = nil, only_self: false
636644
end
637645
end
638646

639-
SKIP_GLOBAL_LIST = %i[$= $KCODE $-K $SAFE].freeze
640647
def show_globals pat
641-
global_variables.sort.each{|name|
648+
safe_global_variables.sort.each{|name|
642649
next if SKIP_GLOBAL_LIST.include? name
643650

644651
value = eval(name.to_s)

0 commit comments

Comments
 (0)