Class: Ast::Merge::StructuralEdit::Boundary
- Inherits:
-
Object
- Object
- Ast::Merge::StructuralEdit::Boundary
- Defined in:
- lib/ast/merge/structural_edit/boundary.rb
Overview
Passive metadata about one edge of a structural splice.
A boundary captures the surviving owner adjacent to a splice plus any known shared layout/comment attachments. The first contiguous replace primitive mostly needs the owner and edge metadata, but remove/rehome work can build on the same object without inventing a new boundary shape.
Constant Summary collapse
- EDGES =
Supported structural boundary edges.
%i[leading trailing].freeze
Instance Attribute Summary collapse
-
#comment_attachment ⇒ Object
readonly
Returns the value of attribute comment_attachment.
-
#edge ⇒ Object
readonly
Returns the value of attribute edge.
-
#layout_attachment ⇒ Object
readonly
Returns the value of attribute layout_attachment.
-
#metadata ⇒ Object
readonly
Returns the value of attribute metadata.
-
#owner ⇒ Object
readonly
Returns the value of attribute owner.
Instance Method Summary collapse
-
#gaps ⇒ Array<Layout::Gap>
Return all layout gaps attached to the boundary owner.
-
#initialize(edge:, owner: nil, layout_attachment: nil, comment_attachment: nil, metadata: {}, **options) ⇒ Boundary
constructor
A new instance of Boundary.
-
#inspect ⇒ String
Return a concise debug representation of the boundary.
- #leading? ⇒ Boolean
-
#regions ⇒ Array<Comment::Region>
Return all comment regions attached to the boundary owner.
- #trailing? ⇒ Boolean
Constructor Details
#initialize(edge:, owner: nil, layout_attachment: nil, comment_attachment: nil, metadata: {}, **options) ⇒ Boundary
Returns a new instance of Boundary.
20 21 22 23 24 25 26 |
# File 'lib/ast/merge/structural_edit/boundary.rb', line 20 def initialize(edge:, owner: nil, layout_attachment: nil, comment_attachment: nil, metadata: {}, **) @edge = normalize_edge(edge) @owner = owner @layout_attachment = @comment_attachment = @metadata = .merge().freeze end |
Instance Attribute Details
#comment_attachment ⇒ Object (readonly)
Returns the value of attribute comment_attachment.
18 19 20 |
# File 'lib/ast/merge/structural_edit/boundary.rb', line 18 def @comment_attachment end |
#edge ⇒ Object (readonly)
Returns the value of attribute edge.
18 19 20 |
# File 'lib/ast/merge/structural_edit/boundary.rb', line 18 def edge @edge end |
#layout_attachment ⇒ Object (readonly)
Returns the value of attribute layout_attachment.
18 19 20 |
# File 'lib/ast/merge/structural_edit/boundary.rb', line 18 def @layout_attachment end |
#metadata ⇒ Object (readonly)
Returns the value of attribute metadata.
18 19 20 |
# File 'lib/ast/merge/structural_edit/boundary.rb', line 18 def @metadata end |
#owner ⇒ Object (readonly)
Returns the value of attribute owner.
18 19 20 |
# File 'lib/ast/merge/structural_edit/boundary.rb', line 18 def owner @owner end |
Instance Method Details
#gaps ⇒ Array<Layout::Gap>
Return all layout gaps attached to the boundary owner.
39 40 41 42 43 44 |
# File 'lib/ast/merge/structural_edit/boundary.rb', line 39 def gaps = return [] unless .respond_to?(:gaps) Array(.public_send(:gaps)) end |
#inspect ⇒ String
Return a concise debug representation of the boundary.
59 60 61 |
# File 'lib/ast/merge/structural_edit/boundary.rb', line 59 def inspect "#<#{self.class.name} edge=#{edge.inspect} owner=#{owner&.class&.name} gaps=#{gaps.size} regions=#{regions.size}>" end |
#leading? ⇒ Boolean
28 29 30 |
# File 'lib/ast/merge/structural_edit/boundary.rb', line 28 def leading? edge == :leading end |
#regions ⇒ Array<Comment::Region>
Return all comment regions attached to the boundary owner.
49 50 51 52 53 54 |
# File 'lib/ast/merge/structural_edit/boundary.rb', line 49 def regions = return [] unless .respond_to?(:regions) Array(.public_send(:regions)) end |
#trailing? ⇒ Boolean
32 33 34 |
# File 'lib/ast/merge/structural_edit/boundary.rb', line 32 def trailing? edge == :trailing end |