Sha256: 8899be4d1daf08013e5e69ec155012e142eeec9e04a743f11a9cb1f286005e1a

Contents?: true

Size: 1.5 KB

Versions: 28

Compression:

Stored size: 1.5 KB

Contents

module Steep
  module Drivers
    class Worker
      attr_reader :stdout, :stderr, :stdin

      attr_accessor :steepfile_path
      attr_accessor :worker_type
      attr_accessor :worker_name

      include Utils::DriverHelper

      def initialize(stdout:, stderr:, stdin:)
        @stdout = stdout
        @stderr = stderr
        @stdin = stdin
      end

      def run()
        Steep.logger.tagged("#{worker_type}:#{worker_name}") do
          project = load_config()

          loader = Project::FileLoader.new(project: project)
          loader.load_sources([])
          loader.load_signatures()

          reader = LanguageServer::Protocol::Transport::Io::Reader.new(stdin)
          writer = LanguageServer::Protocol::Transport::Io::Writer.new(stdout)

          worker = case worker_type
                   when :code
                     Server::CodeWorker.new(project: project, reader: reader, writer: writer)
                   when :signature
                     Server::SignatureWorker.new(project: project, reader: reader, writer: writer)
                   when :interaction
                     Server::InteractionWorker.new(project: project, reader: reader, writer: writer)
                   else
                     raise "Unknown worker type: #{worker_type}"
                   end

          Steep.logger.info "Starting #{worker_type} worker..."

          worker.run()
        rescue Interrupt
          Steep.logger.info "Shutting down by interrupt..."
        end

        0
      end
    end
  end
end

Version data entries

28 entries across 28 versions & 1 rubygems

Version Path
steep-0.19.0 lib/steep/drivers/worker.rb
steep-0.18.0 lib/steep/drivers/worker.rb
steep-0.17.1 lib/steep/drivers/worker.rb
steep-0.17.0 lib/steep/drivers/worker.rb
steep-0.16.3 lib/steep/drivers/worker.rb
steep-0.16.2 lib/steep/drivers/worker.rb
steep-0.16.1 lib/steep/drivers/worker.rb
steep-0.16.0 lib/steep/drivers/worker.rb