Class: SyntaxTree::FCall

Inherits:
Node
  • Object
show all
Defined in:
lib/syntax_tree/node.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

Attributes inherited from Node

#location

Instance Method Summary collapse

Methods inherited from Node

#pretty_print, #to_json

Constructor Details

#initialize(value:, arguments:, location:, comments: []) ⇒ FCall

Returns a new instance of FCall.



3962
3963
3964
3965
3966
3967
# File 'lib/syntax_tree/node.rb', line 3962

def initialize(value:, arguments:, location:, comments: [])
  @value = value
  @arguments = arguments
  @location = location
  @comments = comments
end

Instance Attribute Details

#argumentsObject (readonly)

nil | ArgParen | Args

the arguments to the method call



3957
3958
3959
# File 'lib/syntax_tree/node.rb', line 3957

def arguments
  @arguments
end

#commentsObject (readonly)

Array[ Comment | EmbDoc ]

the comments attached to this node



3960
3961
3962
# File 'lib/syntax_tree/node.rb', line 3960

def comments
  @comments
end

#valueObject (readonly)

Const | Ident

the name of the method



3954
3955
3956
# File 'lib/syntax_tree/node.rb', line 3954

def value
  @value
end

Instance Method Details

#accept(visitor) ⇒ Object



3969
3970
3971
# File 'lib/syntax_tree/node.rb', line 3969

def accept(visitor)
  visitor.visit_fcall(self)
end

#child_nodesObject Also known as: deconstruct



3973
3974
3975
# File 'lib/syntax_tree/node.rb', line 3973

def child_nodes
  [value, arguments]
end

#deconstruct_keys(keys) ⇒ Object



3979
3980
3981
3982
3983
3984
3985
3986
# File 'lib/syntax_tree/node.rb', line 3979

def deconstruct_keys(keys)
  {
    value: value,
    arguments: arguments,
    location: location,
    comments: comments
  }
end

#format(q) ⇒ Object



3988
3989
3990
3991
# File 'lib/syntax_tree/node.rb', line 3988

def format(q)
  q.format(value)
  q.format(arguments)
end