Class: Steep::Drivers::Langserver

Inherits:
Object
  • Object
show all
Includes:
Utils::DriverHelper
Defined in:
lib/steep/drivers/langserver.rb

Instance Attribute Summary collapse

Attributes included from Utils::DriverHelper

#disable_install_collection, #steepfile

Instance Method Summary collapse

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.



15
16
17
18
19
20
21
22
23
# File 'lib/steep/drivers/langserver.rb', line 15

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
end

Instance Attribute Details

#jobs_optionObject (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

#reforkObject

Returns the value of attribute refork.



11
12
13
# File 'lib/steep/drivers/langserver.rb', line 11

def refork
  @refork
end

#stderrObject (readonly)

Returns the value of attribute stderr.



5
6
7
# File 'lib/steep/drivers/langserver.rb', line 5

def stderr
  @stderr
end

#stdinObject (readonly)

Returns the value of attribute stdin.



6
7
8
# File 'lib/steep/drivers/langserver.rb', line 6

def stdin
  @stdin
end

#stdoutObject (readonly)

Returns the value of attribute stdout.



4
5
6
# File 'lib/steep/drivers/langserver.rb', line 4

def stdout
  @stdout
end

#type_check_queueObject (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_threadObject (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_mutexObject (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

#projectObject



33
34
35
# File 'lib/steep/drivers/langserver.rb', line 33

def project
  @project or raise "Empty #project"
end

#readerObject



29
30
31
# File 'lib/steep/drivers/langserver.rb', line 29

def reader
  @reader ||= LanguageServer::Protocol::Transport::Io::Reader.new(stdin)
end

#runObject



37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
# File 'lib/steep/drivers/langserver.rb', line 37

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

  master.start()

  0
end

#writerObject



25
26
27
# File 'lib/steep/drivers/langserver.rb', line 25

def writer
  @writer ||= LanguageServer::Protocol::Transport::Io::Writer.new(stdout)
end