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.

Constant Summary collapse

CONFIGURATION_FILE_PATTERNS =

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

[
  RuboCop::ConfigFinder::DOTFILE,
  RuboCop::CLI::Command::AutoGenerateConfig::AUTO_GENERATED_FILE
].freeze

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.



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

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.



36
37
38
39
40
41
# File 'lib/rubocop/lsp/routes.rb', line 36

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.



184
185
186
187
188
# File 'lib/rubocop/lsp/routes.rb', line 184

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

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

#handle_unsupported_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.



173
174
175
176
177
178
179
180
181
182
# File 'lib/rubocop/lsp/routes.rb', line 173

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