Skip to content

Commit 5a76578

Browse files
st0012ko1
authored andcommitted
Unify Breakpoint's initialization
By requiring all subclasses to pass cond, command, and path explicitly, it should reduce the chance to miss support on them (or new options).
1 parent 27de609 commit 5a76578

File tree

1 file changed

+13
-25
lines changed

1 file changed

+13
-25
lines changed

lib/debug/breakpoint.rb

Lines changed: 13 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,13 @@ class Breakpoint
88

99
attr_reader :key
1010

11-
def initialize do_enable = true
11+
def initialize cond, command, path, do_enable: true
1212
@deleted = false
1313

14+
@cond = cond
15+
@command = command
16+
@path = path
17+
1418
setup
1519
enable if do_enable
1620
end
@@ -111,7 +115,7 @@ def initialize iseq, events, oneshot: false
111115
@oneshot = oneshot
112116
@key = [:iseq, @iseq.path, @iseq.first_lineno].freeze
113117

114-
super()
118+
super(nil, nil, nil)
115119
end
116120

117121
def setup
@@ -130,20 +134,17 @@ class LineBreakpoint < Breakpoint
130134
attr_reader :path, :line, :iseq
131135

132136
def initialize path, line, cond: nil, oneshot: false, hook_call: true, command: nil
133-
@path = path
134137
@line = line
135-
@cond = cond
136138
@oneshot = oneshot
137139
@hook_call = hook_call
138-
@command = command
139140
@pending = false
140141

141142
@iseq = nil
142143
@type = nil
143144

144-
@key = [@path, @line].freeze
145+
@key = [path, @line].freeze
145146

146-
super()
147+
super(cond, command, path)
147148

148149
try_activate
149150
@pending = !@iseq
@@ -280,11 +281,7 @@ def initialize pat, cond: nil, command: nil, path: nil
280281
@key = [:catch, @pat].freeze
281282
@last_exc = nil
282283

283-
@cond = cond
284-
@command = command
285-
@path = path
286-
287-
super()
284+
super(cond, command, path)
288285
end
289286

290287
def setup
@@ -318,12 +315,9 @@ def description
318315

319316
class CheckBreakpoint < Breakpoint
320317
def initialize cond:, command: nil, path: nil
321-
@cond = cond
322-
@command = command
323-
@key = [:check, @cond].freeze
324-
@path = path
318+
@key = [:check, cond].freeze
325319

326-
super()
320+
super(cond, command, path)
327321
end
328322

329323
def setup
@@ -354,10 +348,7 @@ def initialize ivar, object, current, cond: nil, command: nil, path: nil
354348

355349
@current = current
356350

357-
@cond = cond
358-
@command = command
359-
@path = path
360-
super()
351+
super(cond, command, path)
361352
end
362353

363354
def watch_eval(tp)
@@ -407,13 +398,10 @@ def initialize b, klass_name, op, method_name, cond: nil, command: nil, path: ni
407398

408399
@klass = nil
409400
@method = nil
410-
@cond = cond
411401
@cond_class = nil
412-
@command = command
413-
@path = path
414402
@key = "#{klass_name}#{op}#{method_name}".freeze
415403

416-
super(false)
404+
super(cond, command, path, do_enable: false)
417405
end
418406

419407
def setup

0 commit comments

Comments
 (0)