Class: Ast::Crispr::MergeReplace

Inherits:
Actor
  • Object
show all
Includes:
OperationProfilable, OperationSupport
Defined in:
lib/ast/crispr.rb

Instance Method Summary collapse

Methods included from OperationProfilable

included, #operation_profile

Instance Method Details

#callObject



1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
# File 'lib/ast/crispr.rb', line 1310

def call
  self.operation_profile = self.class.operation_profile
  context = context_for(content: content, source_label: source_label, target: target)
  self.matches = normalize_matches(target, context)
  self.match_count = matches.size
  self.captured_text = capture_text(content, matches)
  if matches.empty?
    self.updated_content = content
    self.changed = false
    return
  end

  self.updated_content, self.merge_results = merge_replace_line_ranges(
    content,
    matches,
    replacement,
    merger_class: merger_class,
    merger_options: merger_options.to_h
  )
  self.changed = updated_content != content
rescue Error => e
  crispr_fail!(e)
end