Class: Bash::Merge::SmartMerger
- Inherits:
-
Ast::Merge::SmartMergerBase
- Object
- Ast::Merge::SmartMergerBase
- Bash::Merge::SmartMerger
- Defined in:
- lib/bash/merge/smart_merger.rb
Overview
Main entry point for intelligent Bash script merging. SmartMerger orchestrates the merge process using FileAnalysis, ConflictResolver, and MergeResult to merge two Bash scripts intelligently.
Instance Method Summary collapse
-
#errors ⇒ Array
Get any parse errors from template or destination.
-
#initialize(template_content, dest_content, signature_generator: nil, preference: :destination, add_template_only_nodes: false, freeze_token: nil, match_refiner: nil, regions: nil, region_placeholder: nil, node_typing: nil, **options) ⇒ SmartMerger
constructor
Creates a new SmartMerger for intelligent Bash script merging.
-
#merge ⇒ String
Perform the merge and return the result as a Bash string.
-
#merge_with_debug ⇒ Hash
Perform the merge and return detailed results including debug info.
-
#valid? ⇒ Boolean
Check if both files were parsed successfully.
Constructor Details
#initialize(template_content, dest_content, signature_generator: nil, preference: :destination, add_template_only_nodes: false, freeze_token: nil, match_refiner: nil, regions: nil, region_placeholder: nil, node_typing: nil, **options) ⇒ SmartMerger
To specify a custom parser path, use the TREE_SITTER_BASH_PATH environment variable. This is handled by tree_haver’s GrammarFinder.
Creates a new SmartMerger for intelligent Bash script merging.
57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 |
# File 'lib/bash/merge/smart_merger.rb', line 57 def initialize( template_content, dest_content, signature_generator: nil, preference: :destination, add_template_only_nodes: false, freeze_token: nil, match_refiner: nil, regions: nil, region_placeholder: nil, node_typing: nil, ** ) super( template_content, dest_content, signature_generator: signature_generator, preference: preference, add_template_only_nodes: add_template_only_nodes, freeze_token: freeze_token, match_refiner: match_refiner, regions: regions, region_placeholder: region_placeholder, node_typing: node_typing, ** ) end |
Instance Method Details
#errors ⇒ Array
Get any parse errors from template or destination.
125 126 127 128 129 130 |
# File 'lib/bash/merge/smart_merger.rb', line 125 def errors errors = [] errors.concat(@template_analysis.errors.map { |e| {source: :template, error: e} }) errors.concat(@dest_analysis.errors.map { |e| {source: :destination, error: e} }) errors end |
#merge ⇒ String
Perform the merge and return the result as a Bash string.
88 89 90 |
# File 'lib/bash/merge/smart_merger.rb', line 88 def merge merge_result.to_bash end |
#merge_with_debug ⇒ Hash
Perform the merge and return detailed results including debug info.
95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 |
# File 'lib/bash/merge/smart_merger.rb', line 95 def merge_with_debug content = merge { content: content, statistics: @result.statistics, decisions: @result.decision_summary, template_analysis: { valid: @template_analysis.valid?, nodes: @template_analysis.nodes.size, freeze_blocks: @template_analysis.freeze_blocks.size, }, dest_analysis: { valid: @dest_analysis.valid?, nodes: @dest_analysis.nodes.size, freeze_blocks: @dest_analysis.freeze_blocks.size, }, } end |
#valid? ⇒ Boolean
Check if both files were parsed successfully.
118 119 120 |
# File 'lib/bash/merge/smart_merger.rb', line 118 def valid? @template_analysis.valid? && @dest_analysis.valid? end |