Sha256: 1dd4192ef3643632361c3c64ecfe8822ac936e77a72d3fb11519cc4f41995c2f

Contents?: true

Size: 909 Bytes

Versions: 10

Compression:

Stored size: 909 Bytes

Contents

# typed: strict
# frozen_string_literal: true

module RubyLsp
  module Requests
    # :nodoc:
    class BaseRequest < SyntaxTree::Visitor
      extend T::Sig
      extend T::Helpers

      abstract!

      sig { params(document: Document).void }
      def initialize(document)
        @document = document

        super()
      end

      sig { abstract.returns(Object) }
      def run; end

      sig { params(node: SyntaxTree::Node).returns(LanguageServer::Protocol::Interface::Range) }
      def range_from_syntax_tree_node(node)
        loc = node.location

        LanguageServer::Protocol::Interface::Range.new(
          start: LanguageServer::Protocol::Interface::Position.new(line: loc.start_line - 1,
            character: loc.start_column),
          end: LanguageServer::Protocol::Interface::Position.new(line: loc.end_line - 1, character: loc.end_column),
        )
      end
    end
  end
end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
ruby-lsp-0.3.3 lib/ruby_lsp/requests/base_request.rb
ruby-lsp-0.3.2 lib/ruby_lsp/requests/base_request.rb
ruby-lsp-0.3.1 lib/ruby_lsp/requests/base_request.rb
ruby-lsp-0.3.0 lib/ruby_lsp/requests/base_request.rb
ruby-lsp-0.2.4 lib/ruby_lsp/requests/base_request.rb
ruby-lsp-0.2.3 lib/ruby_lsp/requests/base_request.rb
ruby-lsp-0.2.2 lib/ruby_lsp/requests/base_request.rb
ruby-lsp-0.2.1 lib/ruby_lsp/requests/base_request.rb
ruby-lsp-0.2.0 lib/ruby_lsp/requests/base_request.rb
ruby-lsp-0.1.0 lib/ruby_lsp/requests/base_request.rb