Class: SyntaxTree::FCall
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.
-
#value ⇒ Object
readonly
- Const | Ident
-
the name of the method.
Attributes inherited from Node
Instance Method Summary collapse
- #accept(visitor) ⇒ Object
- #child_nodes ⇒ Object (also: #deconstruct)
- #deconstruct_keys(_keys) ⇒ Object
- #format(q) ⇒ Object
-
#initialize(value:, arguments:, location:, comments: []) ⇒ FCall
constructor
A new instance of FCall.
Methods inherited from Node
#construct_keys, #pretty_print, #to_json
Constructor Details
#initialize(value:, arguments:, location:, comments: []) ⇒ FCall
Returns a new instance of FCall.
4426 4427 4428 4429 4430 4431 |
# File 'lib/syntax_tree/node.rb', line 4426 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
4421 4422 4423 |
# File 'lib/syntax_tree/node.rb', line 4421 def arguments @arguments end |
#comments ⇒ Object (readonly)
- Array[ Comment | EmbDoc ]
-
the comments attached to this node
4424 4425 4426 |
# File 'lib/syntax_tree/node.rb', line 4424 def comments @comments end |
#value ⇒ Object (readonly)
- Const | Ident
-
the name of the method
4418 4419 4420 |
# File 'lib/syntax_tree/node.rb', line 4418 def value @value end |
Instance Method Details
#accept(visitor) ⇒ Object
4433 4434 4435 |
# File 'lib/syntax_tree/node.rb', line 4433 def accept(visitor) visitor.visit_fcall(self) end |
#child_nodes ⇒ Object Also known as: deconstruct
4437 4438 4439 |
# File 'lib/syntax_tree/node.rb', line 4437 def child_nodes [value, arguments] end |
#deconstruct_keys(_keys) ⇒ Object
4443 4444 4445 4446 4447 4448 4449 4450 |
# File 'lib/syntax_tree/node.rb', line 4443 def deconstruct_keys(_keys) { value: value, arguments: arguments, location: location, comments: comments } end |
#format(q) ⇒ Object
4452 4453 4454 4455 4456 4457 4458 4459 4460 4461 4462 4463 4464 |
# File 'lib/syntax_tree/node.rb', line 4452 def format(q) q.format(value) if arguments.is_a?(ArgParen) && arguments.arguments.nil? && !value.is_a?(Const) # If you're using an explicit set of parentheses on something that looks # like a constant, then we need to match that in order to maintain valid # Ruby. For example, you could do something like Foo(), on which we # would need to keep the parentheses to make it look like a method call. else q.format(arguments) end end |