Class: Solargraph::Plugin::Process

Inherits:
Object
  • Object
show all
Defined in:
lib/solargraph/plugin/process.rb

Instance Method Summary collapse

Constructor Details

#initializeProcess

Returns a new instance of Process.



6
7
8
9
# File 'lib/solargraph/plugin/process.rb', line 6

def initialize
  @required = []
  post_initialize
end

Instance Method Details

#post_initializeObject



11
12
# File 'lib/solargraph/plugin/process.rb', line 11

def post_initialize
end

#runObject



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