Class: Steep::Drivers::Query
Constant Summary collapse
- LSP =
LanguageServer::Protocol
Instance Attribute Summary collapse
-
#stderr ⇒ Object
readonly
Returns the value of attribute stderr.
-
#stdout ⇒ Object
readonly
Returns the value of attribute stdout.
Instance Method Summary collapse
-
#initialize(stdout:, stderr:) ⇒ Query
constructor
A new instance of Query.
- #run_definition(names:) ⇒ Object
- #run_hover(locations:) ⇒ Object
Constructor Details
#initialize(stdout:, stderr:) ⇒ Query
Returns a new instance of Query.
9 10 11 12 |
# File 'lib/steep/drivers/query.rb', line 9 def initialize(stdout:, stderr:) @stdout = stdout @stderr = stderr end |
Instance Attribute Details
#stderr ⇒ Object (readonly)
Returns the value of attribute stderr.
7 8 9 |
# File 'lib/steep/drivers/query.rb', line 7 def stderr @stderr end |
#stdout ⇒ Object (readonly)
Returns the value of attribute stdout.
6 7 8 |
# File 'lib/steep/drivers/query.rb', line 6 def stdout @stdout end |
Instance Method Details
#run_definition(names:) ⇒ Object
52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 |
# File 'lib/steep/drivers/query.rb', line 52 def run_definition(names:) unless Daemon.running? stderr.puts "Error: Steep daemon is not running. Start it with `steep server start`." return 1 end names.each do |name| request = { id: SecureRandom.uuid, method: Server::CustomMethods::Query__Definition::METHOD, params: { name: name } } result = send_request(request) stdout.puts JSON.generate({ name: name, result: result }) end 0 rescue Errno::ECONNREFUSED, Errno::ENOENT => e stderr.puts "Error: Failed to connect to Steep daemon: #{e.}" 1 end |
#run_hover(locations:) ⇒ Object
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 41 42 43 44 45 46 47 48 |
# File 'lib/steep/drivers/query.rb', line 16 def run_hover(locations:) unless Daemon.running? stderr.puts "Error: Steep daemon is not running. Start it with `steep server start`." return 1 end locations.each do |path, line, column| absolute_path = to_absolute_path(path) unless absolute_path stdout.puts JSON.generate({ file: path, line: line, column: column, error: "File not found: #{path}" }) next end uri = PathHelper.to_uri(absolute_path).to_s request = { id: SecureRandom.uuid, method: "textDocument/hover", params: { textDocument: { uri: uri }, position: { line: line - 1, character: column - 1 } } } result = send_request(request) stdout.puts JSON.generate({ file: path, line: line, column: column, result: result }) end 0 rescue Errno::ECONNREFUSED, Errno::ENOENT => e stderr.puts "Error: Failed to connect to Steep daemon: #{e.}" 1 end |