14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
|
# File 'lib/solargraph/plugin/process.rb', line 14
def run
until STDIN.closed?
input = gets
break if input.nil?
args = nil
begin
args = JSON.parse(input)
case args['command']
when 'require'
STDOUT.puts do_require args['paths']
when 'methods'
STDOUT.puts get_methods args['params']
when 'constants'
STDOUT.puts get_constants args['params']
when 'fqns'
STDOUT.puts get_fqns args['params']
else
STDOUT.puts respond_err "Unrecognized command #{args['command']}"
end
rescue JSON::ParserError => e
STDOUT.puts respond_err "Error parsing input: #{e.message}"
rescue Exception => e
STDOUT.puts respond_err "Error processing input: #{e.message}\n#{e.backtrace}"
end
STDOUT.flush
end
end
|