-
Notifications
You must be signed in to change notification settings - Fork 121
/
base_request.rb
35 lines (28 loc) · 909 Bytes
/
base_request.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
# 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