Class: SyntaxTree::Comment
- Inherits:
-
Node
- Object
- Node
- SyntaxTree::Comment
show all
- Defined in:
- lib/syntax_tree/node.rb
Overview
Comment represents a comment in the source.
Instance Attribute Summary collapse
-
#inline ⇒ Object
(also: #inline?)
readonly
- boolean
-
whether or not there is code on the same line as this comment.
-
#value ⇒ Object
readonly
- String
-
the contents of the comment.
Attributes inherited from Node
#location
Instance Method Summary
collapse
Methods inherited from Node
#construct_keys, #end_char, #pretty_print, #start_char, #to_json, #to_mermaid
Constructor Details
#initialize(value:, inline:, location:) ⇒ Comment
3718
3719
3720
3721
3722
3723
3724
3725
|
# File 'lib/syntax_tree/node.rb', line 3718
def initialize(value:, inline:, location:)
@value = value
@inline = inline
@location = location
@leading = false
@trailing = false
end
|
Instance Attribute Details
#inline ⇒ Object
Also known as:
inline?
- boolean
-
whether or not there is code on the same line as this comment.
If there is, then inline will be true.
3715
3716
3717
|
# File 'lib/syntax_tree/node.rb', line 3715
def inline
@inline
end
|
#value ⇒ Object
- String
-
the contents of the comment
3711
3712
3713
|
# File 'lib/syntax_tree/node.rb', line 3711
def value
@value
end
|
Instance Method Details
#===(other) ⇒ Object
3777
3778
3779
|
# File 'lib/syntax_tree/node.rb', line 3777
def ===(other)
other.is_a?() && value === other.value && inline === other.inline
end
|
#accept(visitor) ⇒ Object
3751
3752
3753
|
# File 'lib/syntax_tree/node.rb', line 3751
def accept(visitor)
visitor.(self)
end
|
#child_nodes ⇒ Object
Also known as:
deconstruct
3755
3756
3757
|
# File 'lib/syntax_tree/node.rb', line 3755
def child_nodes
[]
end
|
3747
3748
3749
|
# File 'lib/syntax_tree/node.rb', line 3747
def
[]
end
|
#copy(value: nil, inline: nil, location: nil) ⇒ Object
3759
3760
3761
3762
3763
3764
3765
|
# File 'lib/syntax_tree/node.rb', line 3759
def copy(value: nil, inline: nil, location: nil)
.new(
value: value || self.value,
inline: inline || self.inline,
location: location || self.location
)
end
|
#deconstruct_keys(_keys) ⇒ Object
3769
3770
3771
|
# File 'lib/syntax_tree/node.rb', line 3769
def deconstruct_keys(_keys)
{ value: value, inline: inline, location: location }
end
|
3773
3774
3775
|
# File 'lib/syntax_tree/node.rb', line 3773
def format(q)
q.text(value)
end
|
#ignore? ⇒ Boolean
3743
3744
3745
|
# File 'lib/syntax_tree/node.rb', line 3743
def ignore?
value.match?(/\A#\s*stree-ignore\s*\z/)
end
|
#leading! ⇒ Object
3727
3728
3729
|
# File 'lib/syntax_tree/node.rb', line 3727
def leading!
@leading = true
end
|
#leading? ⇒ Boolean
3731
3732
3733
|
# File 'lib/syntax_tree/node.rb', line 3731
def leading?
@leading
end
|
#trailing! ⇒ Object
3735
3736
3737
|
# File 'lib/syntax_tree/node.rb', line 3735
def trailing!
@trailing = true
end
|
#trailing? ⇒ Boolean
3739
3740
3741
|
# File 'lib/syntax_tree/node.rb', line 3739
def trailing?
@trailing
end
|