Module: Ast::Merge::StructuralEdit::RemovePlanSupport
- Defined in:
- lib/ast/merge/structural_edit/remove_plan_support.rb
Overview
Shared helpers for parser-agnostic RemovePlan assembly from one contiguous statement run plus explicit neighboring boundary owners.
Class Method Summary collapse
-
.build_remove_plan(analysis:, statements:, leading_statement: nil, trailing_statement: nil, source: nil) ⇒ RemovePlan?
Build a RemovePlan for a contiguous run of removed statements.
Class Method Details
.build_remove_plan(analysis:, statements:, leading_statement: nil, trailing_statement: nil, source: nil) ⇒ RemovePlan?
Build a Ast::Merge::StructuralEdit::RemovePlan for a contiguous run of removed statements.
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 |
# File 'lib/ast/merge/structural_edit/remove_plan_support.rb', line 19 def build_remove_plan(analysis:, statements:, leading_statement: nil, trailing_statement: nil, source: nil) return unless analysis.respond_to?(:source) statement_list = Array(statements) first_statement = statement_list.first last_statement = statement_list.last return unless first_statement && last_statement remove_start_line = BoundarySupport.statement_start_line(first_statement) remove_end_line = BoundarySupport.statement_end_line(last_statement) return if remove_start_line.nil? || remove_end_line.nil? RemovePlan.new( source: analysis.source, remove_start_line: remove_start_line, remove_end_line: remove_end_line, leading_boundary: BoundarySupport.build_splice_boundary( analysis, leading_statement, edge: :leading, source: source ), trailing_boundary: BoundarySupport.build_splice_boundary( analysis, trailing_statement, edge: :trailing, source: source ), removed_attachments: BoundarySupport.( analysis, statement_list ), metadata: source ? { source: source } : {} ) rescue ArgumentError nil end |