Module: RubyLanguageServer::Location

Defined in:
lib/ruby_language_server/location.rb

Overview

Hash factories for the language server

Class Method Summary collapse

Class Method Details

.hash(uri, start_line, start_character = 0, end_line = nil, end_character = nil) ⇒ Object



7
8
9
10
11
12
# File 'lib/ruby_language_server/location.rb', line 7

def hash(uri, start_line, start_character = 0, end_line = nil, end_character = nil)
  {
    uri: uri,
    range: position_hash(start_line, start_character, end_line, end_character)
  }
end

.position_hash(start_line, start_character = 0, end_line = nil, end_character = nil) ⇒ Object



14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/ruby_language_server/location.rb', line 14

def position_hash(start_line, start_character = 0, end_line = nil, end_character = nil)
  end_line ||= start_line
  end_character ||= start_character
  {
    start:
    {
      line: start_line - 1,
      character: start_character
    },
    end: {
      line: end_line - 1,
      character: end_character
    }
  }
end