Class: Json::Merge::CommentTracker

Inherits:
Ast::Merge::Comment::CStyleTrackerBase
  • Object
show all
Defined in:
lib/json/merge/comment_tracker.rb

Overview

Extracts and tracks comments with their line numbers from JSON / JSONC source. The current tree-sitter JSON grammar can surface JSONC comments, so json-merge now uses the shared C-style comment tracker as well.

Instance Method Summary collapse

Constructor Details

#initialize(source) ⇒ CommentTracker

Returns a new instance of CommentTracker.

Parameters:

  • source (String)

    JSON / JSONC source code



10
11
12
13
# File 'lib/json/merge/comment_tracker.rb', line 10

def initialize(source)
  @source = source
  super(source.lines.map(&:chomp))
end