def process_case exp
if @ignore_ifs.nil?
@ignore_ifs = @tracker && @tracker.options[:ignore_ifs]
end
if @ignore_ifs
process_default exp
return exp
end
branch_scopes = []
was_inside = @inside_if
@inside_if = true
exp[1] = process exp[1] if exp[1]
case_value = if node_type? exp[1], :lvar, :ivar, :call
exp[1].deep_clone
end
exp.each_sexp do |e|
if node_type? e, :when
scope do
@branch_env = env.current
if case_value and simple_when? e
@branch_env[case_value] = e[1][1]
end
process_default e
branch_scopes << env.current
@branch_env = nil
end
end
end
if sexp? exp.last
scope do
@branch_env = env.current
process_default exp[-1]
branch_scopes << env.current
@branch_env = nil
end
end
@inside_if = was_inside
branch_scopes.each do |s|
merge_if_branch s
end
exp
end