Class: RubyLsp::Rails::ServerAddon

Inherits:
ServerComponent show all
Includes:
Common
Defined in:
lib/ruby_lsp/ruby_lsp_rails/server.rb

Instance Attribute Summary

Attributes inherited from ServerComponent

#capabilities, #stderr, #stdout

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Common

#begin_progress, #end_progress, #log_message, #report_progress, #send_error_response, #send_result, #with_notification_error_handling, #with_progress, #with_request_error_handling

Methods inherited from ServerComponent

#initialize

Constructor Details

This class inherits a constructor from RubyLsp::Rails::ServerComponent

Class Method Details

.delegate(name, request, params) ⇒ Object

Delegate ‘request` with `params` to the server add-on with the given `name` : (String, String, Hash[Symbol | String, untyped]) -> void



211
212
213
# File 'lib/ruby_lsp/ruby_lsp_rails/server.rb', line 211

def delegate(name, request, params)
  @server_addons[name]&.execute(request, params)
end

.finalize_registrations!(stdout, stderr, capabilities) ⇒ Object

Instantiate all server addons and store them in a hash for easy access after we have discovered the classes : (IO | StringIO, IO | StringIO, Hash[Symbol | String, untyped]) -> void



217
218
219
220
221
222
223
# File 'lib/ruby_lsp/ruby_lsp_rails/server.rb', line 217

def finalize_registrations!(stdout, stderr, capabilities)
  until @server_addon_classes.empty?
    addon = @server_addon_classes.shift #: as !nil
      .new(stdout, stderr, capabilities)
    @server_addons[addon.name] = addon
  end
end

.inherited(child) ⇒ Object

We keep track of runtime server add-ons the same way we track other add-ons, by storing classes that inherit from the base one : (singleton(ServerAddon)) -> void



204
205
206
207
# File 'lib/ruby_lsp/ruby_lsp_rails/server.rb', line 204

def inherited(child)
  @server_addon_classes << child
  super
end

Instance Method Details

#execute(request, params) ⇒ Object

: (String, Hash[String | Symbol, untyped]) -> untyped

Raises:

  • (NotImplementedError)


232
233
234
# File 'lib/ruby_lsp/ruby_lsp_rails/server.rb', line 232

def execute(request, params)
  raise NotImplementedError, "Not implemented!"
end

#nameObject

: -> String

Raises:

  • (NotImplementedError)


227
228
229
# File 'lib/ruby_lsp/ruby_lsp_rails/server.rb', line 227

def name
  raise NotImplementedError, "Not implemented!"
end