Class: SorbetView::Lsp::Server
- Inherits:
-
Object
- Object
- SorbetView::Lsp::Server
- Extended by:
- T::Sig
- Defined in:
- lib/sorbet_view/lsp/server.rb
Instance Method Summary collapse
-
#initialize(input: $stdin, output: $stdout, sorbet_args: []) ⇒ Server
constructor
A new instance of Server.
- #start ⇒ Object
Constructor Details
#initialize(input: $stdin, output: $stdout, sorbet_args: []) ⇒ Server
Returns a new instance of Server.
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/sorbet_view/lsp/server.rb', line 14 def initialize(input: $stdin, output: $stdout, sorbet_args: []) @config = T.let(Configuration.load, Configuration) @sorbet_args = T.let(sorbet_args, T::Array[String]) @logger = T.let(Logger.new(File.open('sorbet_view_lsp.log', 'a')), Logger) @transport = T.let(Transport.new(input: input, output: output), Transport) @document_store = T.let(DocumentStore.new, DocumentStore) @uri_mapper = T.let(UriMapper.new(config: @config), UriMapper) @position_translator = T.let(PositionTranslator.new, PositionTranslator) @compiler = T.let(Compiler::TemplateCompiler.new(config: @config), Compiler::TemplateCompiler) @component_compiler = T.let(Compiler::ComponentCompiler.new(config: @config), Compiler::ComponentCompiler) @output_manager = T.let(FileSystem::OutputManager.new(@config.output_dir), FileSystem::OutputManager) @sorbet = T.let(SorbetProcess.new(config: @config, logger: @logger), SorbetProcess) @file_watcher = T.let(nil, T.nilable(FileSystem::FileWatcher)) @initialized = T.let(false, T::Boolean) @shutdown = T.let(false, T::Boolean) @sorbet_open_uris = T.let(Set.new, T::Set[String]) @component_version = T.let(0, Integer) end |
Instance Method Details
#start ⇒ Object
34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 |
# File 'lib/sorbet_view/lsp/server.rb', line 34 def start @logger.info('SorbetView LSP server starting') loop do = @transport. break if .nil? () break if @shutdown end rescue => e @logger.error("Server error: #{e.}\n#{e.backtrace&.join("\n")}") ensure @file_watcher&.stop @ivar_json_watcher&.stop @sorbet.stop @logger.info('SorbetView LSP server stopped') end |