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
EXECUTE_COMMANDS =

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.

Commands handled by workspace/executeCommand. Advertised to the client via executeCommandProvider so it knows which commands it can invoke.

%w[rubocop.formatAutocorrects rubocop.formatAutocorrectsAll].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.



34
35
36
37
38
# File 'lib/rubocop/lsp/routes.rb', line 34

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.



40
41
42
43
44
45
# File 'lib/rubocop/lsp/routes.rb', line 40

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.



204
205
206
207
208
# File 'lib/rubocop/lsp/routes.rb', line 204

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.



193
194
195
196
197
198
199
200
201
202
# File 'lib/rubocop/lsp/routes.rb', line 193

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