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.
23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/ruby_lsp/requests/support/syntax_tree_formatting_runner.rb', line 23 def initialize = 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
36 37 38 39 40 41 42 43 44 45 46 |
# File 'lib/ruby_lsp/requests/support/syntax_tree_formatting_runner.rb', line 36 def run(uri, document) relative_path = Pathname.new(T.must(uri.to_standardized_path || uri.opaque)) .relative_path_from(T.must(WORKSPACE_URI.to_standardized_path)) return if .ignore_files.any? { |pattern| File.fnmatch(pattern, relative_path) } SyntaxTree.format( document.source, .print_width, options: ., ) end |