Class: RuboCop::LSP::Server Private
- Inherits:
-
Object
- Object
- RuboCop::LSP::Server
- Defined in:
- lib/rubocop/lsp/server.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.
Language Server Protocol of RuboCop.
Instance Method Summary collapse
- #configure(options) ⇒ Object private
- #format(path, text, command:) ⇒ Object private
-
#initialize(config_store) ⇒ Server
constructor
private
A new instance of Server.
- #offenses(path, text) ⇒ Object private
- #start ⇒ Object private
- #stop(&block) ⇒ Object private
- #write(response) ⇒ Object private
Constructor Details
#initialize(config_store) ⇒ Server
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 Server.
22 23 24 25 26 27 28 29 30 31 |
# File 'lib/rubocop/lsp/server.rb', line 22 def initialize(config_store) $PROGRAM_NAME = "rubocop --lsp #{ConfigFinder.project_root}" RuboCop::LSP.enable @reader = LanguageServer::Protocol::Transport::Io::Reader.new($stdin) @writer = LanguageServer::Protocol::Transport::Io::Writer.new($stdout) @runtime = RuboCop::LSP::Runtime.new(config_store) @routes = Routes.new(self) end |
Instance Method Details
#configure(options) ⇒ 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.
60 61 62 63 64 |
# File 'lib/rubocop/lsp/server.rb', line 60 def configure() @runtime.safe_autocorrect = [:safe_autocorrect] @runtime.lint_mode = [:lint_mode] @runtime.layout_mode = [:layout_mode] end |
#format(path, text, command:) ⇒ 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.
52 53 54 |
# File 'lib/rubocop/lsp/server.rb', line 52 def format(path, text, command:) @runtime.format(path, text, command: command) end |
#offenses(path, text) ⇒ 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.
56 57 58 |
# File 'lib/rubocop/lsp/server.rb', line 56 def offenses(path, text) @runtime.offenses(path, text) end |
#start ⇒ 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.
33 34 35 36 37 38 39 40 41 42 43 44 45 46 |
# File 'lib/rubocop/lsp/server.rb', line 33 def start @reader.read do |request| if !request.key?(:method) @routes.handle_method_missing(request) elsif (route = @routes.for(request[:method])) route.call(request) else @routes.handle_unsupported_method(request) end rescue StandardError => e Logger.log("Error #{e.class} #{e.[0..100]}") Logger.log(e.backtrace.inspect) end end |
#stop(&block) ⇒ 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.
66 67 68 69 |
# File 'lib/rubocop/lsp/server.rb', line 66 def stop(&block) at_exit(&block) if block exit end |
#write(response) ⇒ 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.
48 49 50 |
# File 'lib/rubocop/lsp/server.rb', line 48 def write(response) @writer.write(response) end |