Class: SyntaxTree::FCall
- Inherits:
-
Object
- Object
- SyntaxTree::FCall
- Defined in:
- lib/syntax_tree.rb
Overview
FCall represents the piece of a method call that comes before any arguments (i.e., just the name of the method). It is used in places where the parser is sure that it is a method call and not potentially a local variable.
method(argument)
In the above example, it’s referring to the method
segment.
Instance Attribute Summary collapse
-
#arguments ⇒ Object
readonly
- nil | ArgParen | Args
-
the arguments to the method call.
-
#comments ⇒ Object
readonly
- Array[ Comment | EmbDoc ]
-
the comments attached to this node.
-
#location ⇒ Object
readonly
- Location
-
the location of this node.
-
#value ⇒ Object
readonly
- Const | Ident
-
the name of the method.
Instance Method Summary collapse
- #child_nodes ⇒ Object
- #format(q) ⇒ Object
-
#initialize(value:, arguments:, location:, comments: []) ⇒ FCall
constructor
A new instance of FCall.
- #pretty_print(q) ⇒ Object
- #to_json(*opts) ⇒ Object
Constructor Details
#initialize(value:, arguments:, location:, comments: []) ⇒ FCall
Returns a new instance of FCall.
5830 5831 5832 5833 5834 5835 |
# File 'lib/syntax_tree.rb', line 5830 def initialize(value:, arguments:, location:, comments: []) @value = value @arguments = arguments @location = location @comments = comments end |
Instance Attribute Details
#arguments ⇒ Object (readonly)
- nil | ArgParen | Args
-
the arguments to the method call
5822 5823 5824 |
# File 'lib/syntax_tree.rb', line 5822 def arguments @arguments end |
#comments ⇒ Object (readonly)
- Array[ Comment | EmbDoc ]
-
the comments attached to this node
5828 5829 5830 |
# File 'lib/syntax_tree.rb', line 5828 def comments @comments end |
#location ⇒ Object (readonly)
- Location
-
the location of this node
5825 5826 5827 |
# File 'lib/syntax_tree.rb', line 5825 def location @location end |
#value ⇒ Object (readonly)
- Const | Ident
-
the name of the method
5819 5820 5821 |
# File 'lib/syntax_tree.rb', line 5819 def value @value end |
Instance Method Details
#child_nodes ⇒ Object
5837 5838 5839 |
# File 'lib/syntax_tree.rb', line 5837 def child_nodes [value, arguments] end |
#format(q) ⇒ Object
5841 5842 5843 5844 |
# File 'lib/syntax_tree.rb', line 5841 def format(q) q.format(value) q.format(arguments) end |
#pretty_print(q) ⇒ Object
5846 5847 5848 5849 5850 5851 5852 5853 5854 5855 5856 5857 5858 5859 5860 |
# File 'lib/syntax_tree.rb', line 5846 def pretty_print(q) q.group(2, "(", ")") do q.text("fcall") q.breakable q.pp(value) if arguments q.breakable q.pp(arguments) end q.pp(Comment::List.new(comments)) end end |
#to_json(*opts) ⇒ Object
5862 5863 5864 5865 5866 5867 5868 5869 5870 |
# File 'lib/syntax_tree.rb', line 5862 def to_json(*opts) { type: :fcall, value: value, args: arguments, loc: location, cmts: comments }.to_json(*opts) end |