Class: Ast::Merge::Text::ConflictResolver

Inherits:
ConflictResolverBase show all
Defined in:
lib/ast/merge/text/conflict_resolver.rb

Overview

Conflict resolver for text-based AST merging.

Uses content-based matching with destination-order preservation:

  1. Lines are matched by normalized content (whitespace-trimmed)

  2. Destination order is preserved (destination is source of truth for structure)

  3. Template-only lines are optionally added at the end

  4. Freeze blocks are always preserved from destination

Examples:

resolver = ConflictResolver.new(template_analysis, dest_analysis)
result = MergeResult.new
resolver.resolve(result)

Constant Summary

Constants inherited from ConflictResolverBase

ConflictResolverBase::DECISION_ADDED, ConflictResolverBase::DECISION_APPENDED, ConflictResolverBase::DECISION_DESTINATION, ConflictResolverBase::DECISION_FREEZE_BLOCK, ConflictResolverBase::DECISION_FROZEN, ConflictResolverBase::DECISION_IDENTICAL, ConflictResolverBase::DECISION_KEPT_DEST, ConflictResolverBase::DECISION_KEPT_TEMPLATE, ConflictResolverBase::DECISION_RECURSIVE, ConflictResolverBase::DECISION_REPLACED, ConflictResolverBase::DECISION_TEMPLATE

Instance Attribute Summary

Attributes inherited from ConflictResolverBase

#add_template_only_nodes, #dest_analysis, #preference, #strategy, #template_analysis

Instance Method Summary collapse

Methods inherited from ConflictResolverBase

#default_preference, #freeze_node?, #per_type_preference?, #preference_for_node, #resolve

Constructor Details

#initialize(template_analysis, dest_analysis, preference: :destination, add_template_only_nodes: false) ⇒ ConflictResolver

Initialize the conflict resolver

Parameters:

  • template_analysis (FileAnalysis)

    Analysis of template

  • dest_analysis (FileAnalysis)

    Analysis of destination

  • preference (Symbol) (defaults to: :destination)

    :destination or :template

  • add_template_only_nodes (Boolean) (defaults to: false)

    Whether to add template-only lines



25
26
27
28
29
30
31
32
33
34
35
36
37
38
# File 'lib/ast/merge/text/conflict_resolver.rb', line 25

def initialize(
  template_analysis,
  dest_analysis,
  preference: :destination,
  add_template_only_nodes: false
)
  super(
    strategy: :batch,
    preference: preference,
    template_analysis: template_analysis,
    dest_analysis: dest_analysis,
    add_template_only_nodes: add_template_only_nodes
  )
end