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?, #inner_node, #missing?, #named?, #start_byte, #start_point, #structural?, #to_s, #unwrap
Constructor Details
#initialize(line_number:, text: "") ⇒ Empty
Initialize a new Empty line.
41 42 43 44 45 46 47 48 49 50 51 52 53 |
# File 'lib/ast/merge/comment/empty.rb', line 41 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.
26 27 28 |
# File 'lib/ast/merge/comment/empty.rb', line 26 def line_number @line_number end |
#text ⇒ String (readonly)
Returns The actual line content (may have whitespace).
29 30 31 |
# File 'lib/ast/merge/comment/empty.rb', line 29 def text @text end |
Instance Method Details
#freeze_marker?(_freeze_token) ⇒ Boolean
Empty lines never contain freeze markers.
73 74 75 |
# File 'lib/ast/merge/comment/empty.rb', line 73 def freeze_marker?(_freeze_token) false end |
#inspect ⇒ String
Returns Human-readable representation.
78 79 80 |
# File 'lib/ast/merge/comment/empty.rb', line 78 def inspect "#<Comment::Empty line=#{line_number}>" end |
#normalized_content ⇒ String
Returns Empty normalized content.
65 66 67 |
# File 'lib/ast/merge/comment/empty.rb', line 65 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.
60 61 62 |
# File 'lib/ast/merge/comment/empty.rb', line 60 def signature [:empty_line] end |
#type ⇒ String
TreeHaver::Node protocol: type
33 34 35 |
# File 'lib/ast/merge/comment/empty.rb', line 33 def type "empty_line" end |