lib/ruby_lsp/requests/base_request.rb in ruby-lsp-0.0.3 vs lib/ruby_lsp/requests/base_request.rb in ruby-lsp-0.0.4

- old
+ new

@@ -1,5 +1,6 @@ +# typed: true # frozen_string_literal: true module RubyLsp module Requests # :nodoc: @@ -14,9 +15,19 @@ 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