Sha256: f7c4e2b1349359fa8add74788401ccc65b24337d0f4c7e8d7572a7b02ffd009b

Contents?: true

Size: 957 Bytes

Versions: 6

Compression:

Stored size: 957 Bytes

Contents

module RubyLsp
  module Standard
    class WrapsBuiltinLspStandardizer
      include RubyLsp::Requests::Support::Formatter
      def initialize
        init!
      end

      def init!
        @standardizer = ::Standard::Lsp::Standardizer.new(
          ::Standard::BuildsConfig.new.call([])
        )
      end

      def run_formatting(uri, document)
        @standardizer.format(uri_to_path(uri), document.source)
      end

      def run_diagnostic(uri, document)
        @standardizer.offenses(uri_to_path(uri), document.source, document.encoding)
      end

      private

      # duplicated from: lib/standard/lsp/routes.rb
      # modified to incorporate Ruby LSP's to_standardized_path method
      def uri_to_path(uri)
        if uri.respond_to?(:to_standardized_path) && !(standardized_path = uri.to_standardized_path).nil?
          standardized_path
        else
          uri.to_s.sub(%r{^file://}, "")
        end
      end
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
standard-1.41.0 lib/ruby_lsp/standard/wraps_built_in_lsp_standardizer.rb
standard-1.40.1 lib/ruby_lsp/standard/wraps_built_in_lsp_standardizer.rb
standard-1.40.0 lib/ruby_lsp/standard/wraps_built_in_lsp_standardizer.rb
standard-1.39.2 lib/ruby_lsp/standard/wraps_built_in_lsp_standardizer.rb
standard-1.39.1 lib/ruby_lsp/standard/wraps_built_in_lsp_standardizer.rb
standard-1.39.0 lib/ruby_lsp/standard/wraps_built_in_lsp_standardizer.rb