Class: RuboCop::Lsp::Routes Private

Inherits:
Object
  • Object
show all
Defined in:
lib/rubocop/lsp/routes.rb

Overview

This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.

Routes for Language Server Protocol of RuboCop.

Instance Method Summary collapse

Constructor Details

#initialize(server) ⇒ Routes

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns a new instance of Routes.



25
26
27
28
29
# File 'lib/rubocop/lsp/routes.rb', line 25

def initialize(server)
  @server = server

  @text_cache = {}
end

Instance Method Details

#for(name) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



31
32
33
34
35
36
# File 'lib/rubocop/lsp/routes.rb', line 31

def for(name)
  name = "handle_#{name}"
  return unless respond_to?(name)

  method(name)
end

#handle_method_missing(request) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



170
171
172
173
174
# File 'lib/rubocop/lsp/routes.rb', line 170

def handle_method_missing(request)
  return unless request.key?(:id)

  @server.write(id: request[:id], result: nil)
end

#handle_unsupported_method(request, method = request[:method]) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



159
160
161
162
163
164
165
166
167
168
# File 'lib/rubocop/lsp/routes.rb', line 159

def handle_unsupported_method(request, method = request[:method])
  @server.write(
    id: request[:id],
    error: LanguageServer::Protocol::Interface::ResponseError.new(
      code: LanguageServer::Protocol::Constant::ErrorCodes::METHOD_NOT_FOUND,
      message: "Unsupported Method: #{method}"
    )
  )
  Logger.log("Unsupported Method: #{method}")
end