Class: Steep::Drivers::Langserver
- Includes:
- Utils::DriverHelper
- Defined in:
- lib/steep/drivers/langserver.rb
Instance Attribute Summary collapse
-
#command_socket ⇒ Object
Returns the value of attribute command_socket.
-
#jobs_option ⇒ Object
readonly
Returns the value of attribute jobs_option.
-
#refork ⇒ Object
Returns the value of attribute refork.
-
#stderr ⇒ Object
readonly
Returns the value of attribute stderr.
-
#stdin ⇒ Object
readonly
Returns the value of attribute stdin.
-
#stdout ⇒ Object
readonly
Returns the value of attribute stdout.
-
#type_check_queue ⇒ Object
readonly
Returns the value of attribute type_check_queue.
-
#type_check_thread ⇒ Object
readonly
Returns the value of attribute type_check_thread.
-
#write_mutex ⇒ Object
readonly
Returns the value of attribute write_mutex.
Attributes included from Utils::DriverHelper
#disable_install_collection, #steepfile
Instance Method Summary collapse
-
#initialize(stdout:, stderr:, stdin:) ⇒ Langserver
constructor
A new instance of Langserver.
- #project ⇒ Object
- #reader ⇒ Object
- #run ⇒ Object
-
#start_command_socket(master) ⇒ Object
Starts accepting
steep query/steep checkconnections on the UNIX socket. - #writer ⇒ Object
Methods included from Utils::DriverHelper
#install_collection, #keep_diagnostic?, #load_config, #request_id, #shutdown_exit, #wait_for_message, #wait_for_response_id
Constructor Details
#initialize(stdout:, stderr:, stdin:) ⇒ Langserver
Returns a new instance of Langserver.
16 17 18 19 20 21 22 23 24 25 |
# File 'lib/steep/drivers/langserver.rb', line 16 def initialize(stdout:, stderr:, stdin:) @stdout = stdout @stderr = stderr @stdin = stdin @write_mutex = Mutex.new @type_check_queue = Queue.new @jobs_option = Utils::JobsOption.new(jobs_count_modifier: -1) @refork = false @command_socket = true end |
Instance Attribute Details
#command_socket ⇒ Object
Returns the value of attribute command_socket.
12 13 14 |
# File 'lib/steep/drivers/langserver.rb', line 12 def command_socket @command_socket end |
#jobs_option ⇒ Object (readonly)
Returns the value of attribute jobs_option.
10 11 12 |
# File 'lib/steep/drivers/langserver.rb', line 10 def jobs_option @jobs_option end |
#refork ⇒ Object
Returns the value of attribute refork.
11 12 13 |
# File 'lib/steep/drivers/langserver.rb', line 11 def refork @refork end |
#stderr ⇒ Object (readonly)
Returns the value of attribute stderr.
5 6 7 |
# File 'lib/steep/drivers/langserver.rb', line 5 def stderr @stderr end |
#stdin ⇒ Object (readonly)
Returns the value of attribute stdin.
6 7 8 |
# File 'lib/steep/drivers/langserver.rb', line 6 def stdin @stdin end |
#stdout ⇒ Object (readonly)
Returns the value of attribute stdout.
4 5 6 |
# File 'lib/steep/drivers/langserver.rb', line 4 def stdout @stdout end |
#type_check_queue ⇒ Object (readonly)
Returns the value of attribute type_check_queue.
8 9 10 |
# File 'lib/steep/drivers/langserver.rb', line 8 def type_check_queue @type_check_queue end |
#type_check_thread ⇒ Object (readonly)
Returns the value of attribute type_check_thread.
9 10 11 |
# File 'lib/steep/drivers/langserver.rb', line 9 def type_check_thread @type_check_thread end |
#write_mutex ⇒ Object (readonly)
Returns the value of attribute write_mutex.
7 8 9 |
# File 'lib/steep/drivers/langserver.rb', line 7 def write_mutex @write_mutex end |
Instance Method Details
#project ⇒ Object
35 36 37 |
# File 'lib/steep/drivers/langserver.rb', line 35 def project @project or raise "Empty #project" end |
#reader ⇒ Object
31 32 33 |
# File 'lib/steep/drivers/langserver.rb', line 31 def reader @reader ||= LanguageServer::Protocol::Transport::Io::Reader.new(stdin) end |
#run ⇒ Object
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 |
# File 'lib/steep/drivers/langserver.rb', line 39 def run @project = load_config() interaction_worker = Server::WorkerProcess.start_worker(:interaction, name: "interaction", steepfile: project.steepfile_path, steep_command: jobs_option.steep_command) typecheck_workers = Server::WorkerProcess.start_typecheck_workers(steepfile: project.steepfile_path, args: [], steep_command: jobs_option.steep_command, count: jobs_option.jobs_count_value) master = Server::Master.new( project: project, reader: reader, writer: writer, interaction_worker: interaction_worker, typecheck_workers: typecheck_workers, refork: refork, ) master.typecheck_automatically = true socket = start_command_socket(master) begin master.start() ensure socket&.stop end 0 end |
#start_command_socket(master) ⇒ Object
Starts accepting steep query/steep check connections on the UNIX socket
Returns nil when the command socket is disabled, is not supported on the platform,
or is already served by another process.
71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 |
# File 'lib/steep/drivers/langserver.rb', line 71 def start_command_socket(master) return nil unless command_socket configuration = Daemon::Configuration.new(base_dir: project.base_dir.to_s) socket = Server::CommandSocket.new(master: master, configuration: configuration) if socket.start stderr.puts "Steep command socket is ready: #{configuration.socket_path}" socket else stderr.puts "Steep command socket is not available: #{configuration.socket_path}" nil end rescue NotImplementedError, StandardError => error Steep.logger.error { "Failed to start command socket: #{error.inspect}" } stderr.puts "Failed to start Steep command socket: #{error.}" nil end |
#writer ⇒ Object
27 28 29 |
# File 'lib/steep/drivers/langserver.rb', line 27 def writer @writer ||= LanguageServer::Protocol::Transport::Io::Writer.new(stdout) end |