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.



192
193
194
195
196
# File 'lib/rubocop/lsp/routes.rb', line 192

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.



181
182
183
184
185
186
187
188
189
190
# File 'lib/rubocop/lsp/routes.rb', line 181

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