Class: Bash::Merge::FreezeNode
- Inherits:
-
Ast::Merge::FreezeNodeBase
- Object
- Ast::Merge::FreezeNodeBase
- Bash::Merge::FreezeNode
- Defined in:
- lib/bash/merge/freeze_node.rb
Overview
Wrapper to represent freeze blocks as first-class nodes in Bash scripts. A freeze block is a section marked with freeze/unfreeze comment markers that should be preserved from the destination during merges.
Inherits from Ast::Merge::FreezeNodeBase for shared functionality including the Location struct, InvalidStructureError, and configurable marker patterns.
Uses the :hash_comment pattern type by default for Bash files (# comments).
Constant Summary collapse
- InvalidStructureError =
Inherit InvalidStructureError from base class
Ast::Merge::FreezeNodeBase::InvalidStructureError
- Location =
Inherit Location from base class
Ast::Merge::FreezeNodeBase::Location
Instance Method Summary collapse
-
#command? ⇒ Boolean
Check if this is a command (always false for FreezeNode).
-
#function_definition? ⇒ Boolean
Check if this is a function definition (always false for FreezeNode).
-
#initialize(start_line:, end_line:, lines:, start_marker: nil, end_marker: nil, pattern_type: Ast::Merge::FreezeNodeBase::DEFAULT_PATTERN) ⇒ FreezeNode
constructor
A new instance of FreezeNode.
-
#inspect ⇒ String
String representation for debugging.
-
#signature ⇒ Array
Returns a stable signature for this freeze block.
-
#variable_assignment? ⇒ Boolean
Check if this is a variable assignment (always false for FreezeNode).
Constructor Details
#initialize(start_line:, end_line:, lines:, start_marker: nil, end_marker: nil, pattern_type: Ast::Merge::FreezeNodeBase::DEFAULT_PATTERN) ⇒ FreezeNode
Returns a new instance of FreezeNode.
32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 |
# File 'lib/bash/merge/freeze_node.rb', line 32 def initialize(start_line:, end_line:, lines:, start_marker: nil, end_marker: nil, pattern_type: Ast::Merge::FreezeNodeBase::DEFAULT_PATTERN) # Extract lines for the entire block (lines param is all source lines) block_lines = (start_line..end_line).map { |ln| lines[ln - 1] } super( start_line: start_line, end_line: end_line, lines: block_lines, start_marker: start_marker, end_marker: end_marker, pattern_type: pattern_type ) validate_structure! end |
Instance Method Details
#command? ⇒ Boolean
Check if this is a command (always false for FreezeNode)
71 72 73 |
# File 'lib/bash/merge/freeze_node.rb', line 71 def command? false end |
#function_definition? ⇒ Boolean
Check if this is a function definition (always false for FreezeNode)
59 60 61 |
# File 'lib/bash/merge/freeze_node.rb', line 59 def function_definition? false end |
#inspect ⇒ String
String representation for debugging
77 78 79 80 81 82 83 84 |
# File 'lib/bash/merge/freeze_node.rb', line 77 def inspect # simplecov:disable # Defensive: slice is always set via resolve_content in FreezeNodeBase#initialize # The || 0 branch is normally unreachable because validate_structure! ensures non-empty content content_length = slice&.length || 0 # simplecov:enable "#<#{self.class.name} lines=#{start_line}..#{end_line} content_length=#{content_length}>" end |
#signature ⇒ Array
Returns a stable signature for this freeze block. Signature includes the normalized content to detect changes.
51 52 53 54 55 |
# File 'lib/bash/merge/freeze_node.rb', line 51 def signature # Normalize by stripping each line and joining normalized = @lines.map { |l| l&.strip }.compact.reject(&:empty?).join("\n") [:FreezeNode, normalized] end |
#variable_assignment? ⇒ Boolean
Check if this is a variable assignment (always false for FreezeNode)
65 66 67 |
# File 'lib/bash/merge/freeze_node.rb', line 65 def variable_assignment? false end |