Class: RubyLsp::Requests::Support::SyntaxTreeFormattingRunner
- Inherits:
-
Object
- Object
- RubyLsp::Requests::Support::SyntaxTreeFormattingRunner
- Extended by:
- T::Sig
- Includes:
- FormatterRunner, Singleton
- Defined in:
- lib/ruby_lsp/requests/support/syntax_tree_formatting_runner.rb
Overview
:nodoc:
Instance Method Summary collapse
-
#initialize ⇒ SyntaxTreeFormattingRunner
constructor
A new instance of SyntaxTreeFormattingRunner.
- #run(uri, document) ⇒ Object
Constructor Details
#initialize ⇒ SyntaxTreeFormattingRunner
Returns a new instance of SyntaxTreeFormattingRunner.
17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/ruby_lsp/requests/support/syntax_tree_formatting_runner.rb', line 17 def initialize @options = T.let( begin opts = SyntaxTree::CLI::Options.new opts.parse(SyntaxTree::CLI::ConfigFile.new.arguments) opts end, SyntaxTree::CLI::Options, ) end |
Instance Method Details
#run(uri, document) ⇒ Object
30 31 32 33 34 35 36 37 38 39 |
# File 'lib/ruby_lsp/requests/support/syntax_tree_formatting_runner.rb', line 30 def run(uri, document) relative_path = Pathname.new(URI(uri).path).relative_path_from(T.must(WORKSPACE_URI.path)) return if @options.ignore_files.any? { |pattern| File.fnmatch(pattern, relative_path) } SyntaxTree.format( document.source, @options.print_width, options: @options., ) end |