Class: Solargraph::LanguageServer::Message::TextDocument::Formatting
- Includes:
- Diagnostics::RubocopHelpers
- Defined in:
- lib/solargraph/language_server/message/text_document/formatting.rb
Instance Attribute Summary
Attributes inherited from Base
Attributes inherited from Base
#error, #host, #id, #method, #params, #request, #result
Instance Method Summary collapse
Methods included from Diagnostics::RubocopHelpers
fix_drive_letter, generate_options, redirect_stdout, require_rubocop
Methods inherited from Base
Methods included from UriHelpers
decode, encode, file_to_uri, uri_to_file
Methods inherited from Base
#initialize, #post_initialize, #send_response, #set_error, #set_result
Constructor Details
This class inherits a constructor from Solargraph::LanguageServer::Message::Base
Instance Method Details
#process ⇒ Object
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/solargraph/language_server/message/text_document/formatting.rb', line 13 def process file_uri = params['textDocument']['uri'] config = config_for(file_uri) original = host.read_text(file_uri) args = cli_args(file_uri, config) require_rubocop(config['version']) , paths = RuboCop::Options.new.parse(args) [:stdin] = original corrections = redirect_stdout do RuboCop::Runner.new(, RuboCop::ConfigStore.new).run(paths) end result = [:stdin] log_corrections(corrections) format original, result rescue RuboCop::ValidationError, RuboCop::ConfigNotFoundError => e set_error(Solargraph::LanguageServer::ErrorCodes::INTERNAL_ERROR, "[#{e.class}] #{e.}") end |