Class: Bash::Merge::CommentTracker
- Inherits:
-
Ast::Merge::Comment::HashTrackerBase
- Object
- Ast::Merge::Comment::HashTrackerBase
- Bash::Merge::CommentTracker
- Defined in:
- lib/bash/merge/comment_tracker.rb
Overview
Extracts and tracks comments with their line numbers from Bash source. Bash comments use the # syntax, making freeze block detection straightforward.
Inherits shared lookup, query, region-building, and attachment API from
Ast::Merge::Comment::HashTrackerBase. Only format-specific comment
extraction, shebang detection, and owner resolution are overridden here.
Instance Method Summary collapse
- #augment(owners: [], **options) ⇒ Object
-
#initialize(source) ⇒ CommentTracker
constructor
Initialize comment tracker by scanning the source.
-
#shebang?(line_num) ⇒ Boolean
Check if a line is a shebang.
Constructor Details
#initialize(source) ⇒ CommentTracker
Initialize comment tracker by scanning the source
24 25 26 27 28 |
# File 'lib/bash/merge/comment_tracker.rb', line 24 def initialize(source) @source = source @line_parser = Ast::Merge::Comment::QuotedHashLineParser.new super(source.lines.map(&:chomp)) end |
Instance Method Details
#augment(owners: [], **options) ⇒ Object
40 41 42 43 44 45 46 47 48 49 50 |
# File 'lib/bash/merge/comment_tracker.rb', line 40 def augment(owners: [], **) Ast::Merge::Comment::Augmenter.new( lines: @lines, comments: @comments, owners: owners, style: :hash_comment, total_comment_count: @comments.size, inline_comment_count: @comments.count { |comment| !comment[:full_line] }, ** ) end |
#shebang?(line_num) ⇒ Boolean
Check if a line is a shebang
34 35 36 37 38 |
# File 'lib/bash/merge/comment_tracker.rb', line 34 def shebang?(line_num) return false if line_num < 1 || line_num > @lines.length @lines[line_num - 1].start_with?('#!') end |