Sha256: c75296b4e8cfef3b2916d49599c69ab5256af5f9a7c643006ed579cc5d8157a2
Contents?: true
Size: 1004 Bytes
Versions: 1
Compression:
Stored size: 1004 Bytes
Contents
# frozen_string_literal: true module LsifParser # Processes and stores documents data and links to their ranges class Docs PREFIX = 'file://' attr_reader :docs, :doc_ranges, :ranges def initialize(prefix) @prefix = prefix.delete_prefix('/') @docs = {} @doc_ranges = {} @ranges = Ranges.new end def read(line) case line['label'] when 'document' add(line) when 'contains' add_ranges(line) else @ranges.read(line) end end def each docs.each do |id, path| next if path.start_with?(PREFIX) yield id, path end end def find(id) @docs[id] end private def add(line) id = line['id'] url = line['uri'] docs[id] = url .delete_prefix("#{PREFIX}/#{prefix}") .delete_prefix('/') end def add_ranges(line) @doc_ranges[line['outV']] = line['inVs'] end attr_reader :prefix end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
lsif_parser-0.1.0 | lib/lsif_parser/docs.rb |