Method: Parser::Source::TreeRewriter#import!
- Defined in:
- lib/parser/source/tree_rewriter.rb
#import!(foreign_rewriter, offset: 0) ⇒ Rewriter
For special cases where one needs to merge a rewriter attached to a different source_buffer or that needs to be offset. Policies of the receiver are used.
168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 |
# File 'lib/parser/source/tree_rewriter.rb', line 168 def import!(foreign_rewriter, offset: 0) return self if foreign_rewriter.empty? contracted = foreign_rewriter.action_root.contract merge_effective_range = ::Parser::Source::Range.new( @source_buffer, contracted.range.begin_pos + offset, contracted.range.end_pos + offset, ) check_range_validity(merge_effective_range) merge_with = contracted.moved(@source_buffer, offset) @action_root = @action_root.combine(merge_with) self end |