Sha256: 42201bb7178b3ff9b72fbeea44e7c472db4000f14ecc2fc217a290b8f7c64ae8

Contents?: true

Size: 809 Bytes

Versions: 1

Compression:

Stored size: 809 Bytes

Contents

# typed: true
# frozen_string_literal: true

module RubyLsp
  module Requests
    # :nodoc:
    class BaseRequest < SyntaxTree::Visitor
      def self.run(document)
        new(document).run
      end

      def initialize(document)
        @document = document

        super()
      end

      def run
        raise NotImplementedError, "#{self.class}#run must be implemented"
      end

      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

1 entries across 1 versions & 1 rubygems

Version Path
ruby-lsp-0.0.4 lib/ruby_lsp/requests/base_request.rb