Sha256: 7f7f09789f237ce97e251eec2f80b2e9b390c1b7fb6be20a76669bab852a42a9
Contents?: true
Size: 1.14 KB
Versions: 1
Compression:
Stored size: 1.14 KB
Contents
# frozen_string_literal: true module LsifParser # Processes and stores ranges data and links to their hovers and definitions class Ranges def initialize @ranges = {} @def_refs = {} @hovers = Hovers.new end def read(line) case line['label'] when 'range' add(line) when 'item' add_item(line) else @hovers.read(line) end end def find(id) @ranges[id] end def hover_for(id) @hovers.for(id) end def def_ref_for(id) @def_refs[id] end private def add(line) id = line['id'] start_data = line['start'] @ranges[id] = { start_line: start_data['line'], start_char: start_data['character'] } end def add_item(line) type = line['property'] return unless %w[definitions references].include?(type) line['inVs'].each do |range_id| @ranges[range_id]&.merge!(ref_id: line['outV']) end return unless type == 'definitions' @def_refs[line['outV']] = { id: line['inVs'].first, doc_id: line['document'] } end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
lsif_parser-0.1.0 | lib/lsif_parser/ranges.rb |