35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
|
# File 'lib/nrepl-lazuli/connection.rb', line 35
def treat_msg(msg)
case msg['op']
when 'clone'
register_session(msg)
when 'describe'
describe_msg(msg)
when 'eval'
eval_op(msg, false)
when 'eval_pause'
eval_op(msg, true)
when 'last_exception'
ex = Server.class_variable_get(:@@last_exception)
send_msg(response_for(msg, { 'result' => ex.inspect, 'status' => ['done'] }))
when 'eval_resume'
msg['id'] ||= "eval_#{@counter += 1}"
stop_id = msg['stop_id']
clear_eval!(stop_id)
send_msg(response_for(msg, {
'status' => ['done'],
'op' => msg['op']
}))
when 'unwatch'
msg['id'] ||= "eval_#{@counter += 1}"
watch_id = msg['watch_id']
info = @bindings_by_id.delete(watch_id)
if(info)
file_info = @bindings.fetch(info[:file], {})
content = file_info.fetch(info[:row], {})
content.delete(watch_id)
file_info.delete(info[:row]) if(content.empty?)
@bindings.delete(info[:file]) if(file_info.empty?)
end
send_msg(response_for(msg, {
'status' => ['done'],
'op' => msg['op']
}))
when 'interrupt'
id = if(msg['interrupt-id'])
msg['interrupt-id']
else
@pending_evals.keys.first
end
pending = @pending_evals[id] || {}
thread = pending[:thread]
msg['id'] ||= (id || 'unknown')
if(thread)
thread.kill
clear_eval!(id)
send_msg(response_for(msg, {
'status' => ['done', 'interrupted'],
'op' => msg['op']
}))
else
send_msg(response_for(msg, {
'status' => ['done'],
'op' => msg['op']
}))
end
when 'watches_for_file'
msg['id'] ||= "eval_#{@counter += 1}"
file = msg['file']
rows_bindings = @bindings[file] || {}
send_msg(response_for(msg, {
'status' => ['done'],
'rows' => rows_bindings.keys.sort,
'op' => msg['op']
}))
else
send_msg(response_for(msg, {
'op' => msg['op'],
'status' => ['done', 'error'],
'error' => "unknown operation: #{msg['op'].inspect}"
}))
end
end
|