Class: Json::Merge::SourceLocator
- Inherits:
-
Object
- Object
- Json::Merge::SourceLocator
- Defined in:
- lib/json/merge/source_locator.rb,
sig/json/merge.rbs
Overview
Locates JSON object-pair owners that can be copied as whole source lines.
Defined Under Namespace
Classes: Range
Instance Method Summary collapse
-
#initialize(source, dialect:, backend: nil) ⇒ SourceLocator
constructor
A new instance of SourceLocator.
- #pair_range(path) ⇒ Range?
Constructor Details
#initialize(source, dialect:, backend: nil) ⇒ SourceLocator
Returns a new instance of SourceLocator.
9 10 11 12 13 14 15 16 17 |
# File 'lib/json/merge/source_locator.rb', line 9 def initialize(source, dialect:, backend: nil) @source = source @lines = source.lines Json::Merge.register_backend! backend_id = backend.to_s.empty? ? Json::Merge::TREE_SITTER_BACKEND.id : backend.to_s @analysis = TreeHaver.with_backend(backend_id) do FileAnalysis.new(source, dialect: dialect) end end |