Class: Ast::Merge::Comment::Empty
- Defined in:
- lib/ast/merge/comment/empty.rb
Overview
Represents an empty/blank line in source code.
Empty lines are important for preserving document structure and
separating comment blocks. They serve as natural boundaries between
logical sections of comments.
Instance Attribute Summary collapse
-
#line_number ⇒ Integer
readonly
The line number in source.
-
#text ⇒ String
readonly
The actual line content (may have whitespace).
Attributes inherited from AstNode
Instance Method Summary collapse
-
#freeze_marker?(_freeze_token) ⇒ Boolean
Empty lines never contain freeze markers.
-
#initialize(line_number:, text: "") ⇒ Empty
constructor
Initialize a new Empty line.
-
#inspect ⇒ String
Human-readable representation.
-
#normalized_content ⇒ String
Empty normalized content.
-
#signature ⇒ Array
Empty lines have a generic signature - they don’t match by content.
-
#type ⇒ String
TreeHaver::Node protocol: type.
Methods inherited from AstNode
#<=>, #child, #child_count, #children, #each, #end_byte, #end_point, #has_error?, #missing?, #named?, #source, #start_byte, #start_point, #structural?, #to_s, #unwrap
Constructor Details
#initialize(line_number:, text: "") ⇒ Empty
Initialize a new Empty line.
39 40 41 42 43 44 45 46 47 48 49 50 51 |
# File 'lib/ast/merge/comment/empty.rb', line 39 def initialize(line_number:, text: "") @line_number = line_number @text = text.to_s location = AstNode::Location.new( start_line: line_number, end_line: line_number, start_column: 0, end_column: @text.length, ) super(slice: @text, location: location) end |
Instance Attribute Details
#line_number ⇒ Integer (readonly)
Returns The line number in source.
24 25 26 |
# File 'lib/ast/merge/comment/empty.rb', line 24 def line_number @line_number end |
#text ⇒ String (readonly)
Returns The actual line content (may have whitespace).
27 28 29 |
# File 'lib/ast/merge/comment/empty.rb', line 27 def text @text end |
Instance Method Details
#freeze_marker?(_freeze_token) ⇒ Boolean
Empty lines never contain freeze markers.
71 72 73 |
# File 'lib/ast/merge/comment/empty.rb', line 71 def freeze_marker?(_freeze_token) false end |
#inspect ⇒ String
Returns Human-readable representation.
76 77 78 |
# File 'lib/ast/merge/comment/empty.rb', line 76 def inspect "#<Comment::Empty line=#{line_number}>" end |
#normalized_content ⇒ String
Returns Empty normalized content.
63 64 65 |
# File 'lib/ast/merge/comment/empty.rb', line 63 def normalized_content "" end |
#signature ⇒ Array
Empty lines have a generic signature - they don’t match by content.
All empty lines are considered equivalent for matching purposes.
58 59 60 |
# File 'lib/ast/merge/comment/empty.rb', line 58 def signature [:empty_line] end |
#type ⇒ String
TreeHaver::Node protocol: type
31 32 33 |
# File 'lib/ast/merge/comment/empty.rb', line 31 def type "empty_line" end |