6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
|
# File 'lib/byebug/commands/enable_disable.rb', line 6
def enable_disable_breakpoints(is_enable, args)
return errmsg('No breakpoints have been set') if Breakpoint.none?
all_breakpoints = Byebug.breakpoints.sort_by { |b| b.id }
if args.empty?
selected_breakpoints = all_breakpoints
else
selected_ids = []
args.each do |pos|
last_id = all_breakpoints.last.id
pos, err = get_int(pos, "#{is_enable} breakpoints", 1, last_id)
return errmsg(err) unless pos
selected_ids << pos
end
selected_breakpoints = all_breakpoints.select do
|b| selected_ids.include?(b.id)
end
end
selected_breakpoints.each do |b|
enabled = ('enable' == is_enable)
if enabled && !syntax_valid?(b.expr)
return errmsg("Expression \"#{b.expr}\" syntactically incorrect; " \
'breakpoint remains disabled.')
end
b.enabled = enabled
end
end
|