Method: Parser::Source::Rewriter#insert_before_multi

Defined in:
lib/parser/source/rewriter.rb

#insert_before_multi(range, content) ⇒ Rewriter

Inserts new code before the given source range by allowing other insertions at the same position. Note that an insertion with latter invocation comes before earlier insertion at the same position in the rewritten source.

Examples:

Inserting '[('

rewriter.
  insert_before_multi(range, '(').
  insert_before_multi(range, '[').
  process

Parameters:

  • range (Range)
  • content (String)

Returns:

Raises:



117
118
119
120
# File 'lib/parser/source/rewriter.rb', line 117

def insert_before_multi(range, content)
  @insert_before_multi_order -= 1
  append Rewriter::Action.new(range.begin, content, true, @insert_before_multi_order)
end