Class: Ast::Merge::Comment::Augmenter
- Inherits:
-
Object
- Object
- Ast::Merge::Comment::Augmenter
- Defined in:
- lib/ast/merge/comment/augmenter.rb
Overview
Builds standardized comment regions and attachments from source text, tracked comment hashes, and structural owner ranges.
This is a passive augmentation layer. It does not modify merge behavior;
it only infers normalized Comment::Region and Comment::Attachment
objects that format gems can adopt incrementally.
Instance Attribute Summary collapse
-
#attachments_by_owner ⇒ Object
readonly
Returns the value of attribute attachments_by_owner.
-
#capability ⇒ Object
readonly
Returns the value of attribute capability.
-
#lines ⇒ Object
readonly
Returns the value of attribute lines.
-
#orphan_regions ⇒ Object
readonly
Returns the value of attribute orphan_regions.
-
#owners ⇒ Object
readonly
Returns the value of attribute owners.
-
#postlude_region ⇒ Object
readonly
Returns the value of attribute postlude_region.
-
#preamble_region ⇒ Object
readonly
Returns the value of attribute preamble_region.
-
#style ⇒ Object
readonly
Returns the value of attribute style.
-
#tracked_comments ⇒ Object
readonly
Returns the value of attribute tracked_comments.
Class Method Summary collapse
-
.call(**options) ⇒ Augmenter
Build an augmenter and run augmentation immediately.
Instance Method Summary collapse
-
#attachment_for(owner) ⇒ Attachment?
Return the inferred attachment for a specific owner.
-
#initialize(lines: nil, source: nil, comments: [], owners: [], style: nil, capability: nil, **options) ⇒ Augmenter
constructor
A new instance of Augmenter.
Constructor Details
#initialize(lines: nil, source: nil, comments: [], owners: [], style: nil, capability: nil, **options) ⇒ Augmenter
Returns a new instance of Augmenter.
33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 |
# File 'lib/ast/merge/comment/augmenter.rb', line 33 def initialize(lines: nil, source: nil, comments: [], owners: [], style: nil, capability: nil, **) @lines = normalize_lines(lines, source) @style = resolve_style(style) @owners = normalize_owners(owners) @tracked_comments = normalize_comments(comments) @capability = capability || Capability.source_augmented( source: :tracked_hash, style: style_name, owner_count: @owners.size, comment_count: @tracked_comments.size, ** ) @attachments_by_owner = {} @preamble_region = nil @postlude_region = nil @orphan_regions = [] build! end |
Instance Attribute Details
#attachments_by_owner ⇒ Object (readonly)
Returns the value of attribute attachments_by_owner.
13 14 15 |
# File 'lib/ast/merge/comment/augmenter.rb', line 13 def @attachments_by_owner end |
#capability ⇒ Object (readonly)
Returns the value of attribute capability.
13 14 15 |
# File 'lib/ast/merge/comment/augmenter.rb', line 13 def capability @capability end |
#lines ⇒ Object (readonly)
Returns the value of attribute lines.
13 14 15 |
# File 'lib/ast/merge/comment/augmenter.rb', line 13 def lines @lines end |
#orphan_regions ⇒ Object (readonly)
Returns the value of attribute orphan_regions.
13 14 15 |
# File 'lib/ast/merge/comment/augmenter.rb', line 13 def orphan_regions @orphan_regions end |
#owners ⇒ Object (readonly)
Returns the value of attribute owners.
13 14 15 |
# File 'lib/ast/merge/comment/augmenter.rb', line 13 def owners @owners end |
#postlude_region ⇒ Object (readonly)
Returns the value of attribute postlude_region.
13 14 15 |
# File 'lib/ast/merge/comment/augmenter.rb', line 13 def postlude_region @postlude_region end |
#preamble_region ⇒ Object (readonly)
Returns the value of attribute preamble_region.
13 14 15 |
# File 'lib/ast/merge/comment/augmenter.rb', line 13 def preamble_region @preamble_region end |
#style ⇒ Object (readonly)
Returns the value of attribute style.
13 14 15 |
# File 'lib/ast/merge/comment/augmenter.rb', line 13 def style @style end |
#tracked_comments ⇒ Object (readonly)
Returns the value of attribute tracked_comments.
13 14 15 |
# File 'lib/ast/merge/comment/augmenter.rb', line 13 def tracked_comments @tracked_comments end |
Class Method Details
.call(**options) ⇒ Augmenter
Build an augmenter and run augmentation immediately.
28 29 30 |
# File 'lib/ast/merge/comment/augmenter.rb', line 28 def call(**) new(**) end |
Instance Method Details
#attachment_for(owner) ⇒ Attachment?
Return the inferred attachment for a specific owner.
58 59 60 |
# File 'lib/ast/merge/comment/augmenter.rb', line 58 def (owner) [owner] end |