Class: YARP::CallNode
- Inherits:
-
YARPNode
- Object
- YARPNode
- YARP::CallNode
- Defined in:
- lib/yarp/node.rb,
ext/yarp/api_node.c
Overview
Represents a method call, in all of the various forms that can take.
foo
^^^
foo()
^^^^^
+foo
^^^^
foo + bar
^^^^^^^^^
foo.bar
^^^^^^^
foo&.bar
^^^^^^^^
Instance Attribute Summary collapse
-
#arguments ⇒ Object
readonly
attr_reader arguments: ArgumentsNode?.
-
#block ⇒ Object
readonly
attr_reader block: BlockNode?.
-
#call_operator_loc ⇒ Object
readonly
attr_reader call_operator_loc: Location?.
-
#closing_loc ⇒ Object
readonly
attr_reader closing_loc: Location?.
-
#flags ⇒ Object
readonly
attr_reader flags: Integer.
-
#message_loc ⇒ Object
readonly
attr_reader message_loc: Location?.
-
#name ⇒ Object
readonly
attr_reader name: String.
-
#opening_loc ⇒ Object
readonly
attr_reader opening_loc: Location?.
-
#receiver ⇒ Object
readonly
attr_reader receiver: Node?.
Instance Method Summary collapse
-
#accept(visitor) ⇒ Object
def accept: (visitor: Visitor) -> void.
-
#call_operator ⇒ Object
def call_operator: () -> String?.
-
#child_nodes ⇒ Object
(also: #deconstruct)
def child_nodes: () -> Array[nil | Node].
-
#closing ⇒ Object
def closing: () -> String?.
-
#comment_targets ⇒ Object
def comment_targets: () -> Array[Node | Location].
-
#copy(**params) ⇒ Object
def copy: (**params) -> CallNode.
- #deconstruct_keys(keys) ⇒ Object
-
#initialize(receiver, call_operator_loc, message_loc, opening_loc, arguments, closing_loc, block, flags, name, location) ⇒ CallNode
constructor
def initialize: (receiver: Node?, call_operator_loc: Location?, message_loc: Location?, opening_loc: Location?, arguments: ArgumentsNode?, closing_loc: Location?, block: BlockNode?, flags: Integer, name: String, location: Location) -> void.
- #inspect(inspector = NodeInspector.new) ⇒ Object
-
#message ⇒ Object
def message: () -> String?.
-
#opening ⇒ Object
def opening: () -> String?.
-
#safe_navigation? ⇒ Boolean
def safe_navigation?: () -> bool.
-
#variable_call? ⇒ Boolean
def variable_call?: () -> bool.
Constructor Details
#initialize(receiver, call_operator_loc, message_loc, opening_loc, arguments, closing_loc, block, flags, name, location) ⇒ CallNode
def initialize: (receiver: Node?, call_operator_loc: Location?, message_loc: Location?, opening_loc: Location?, arguments: ArgumentsNode?, closing_loc: Location?, block: BlockNode?, flags: Integer, name: String, location: Location) -> void
1419 1420 1421 1422 1423 1424 1425 1426 1427 1428 1429 1430 |
# File 'lib/yarp/node.rb', line 1419 def initialize(receiver, call_operator_loc, , opening_loc, arguments, closing_loc, block, flags, name, location) @receiver = receiver @call_operator_loc = call_operator_loc @message_loc = @opening_loc = opening_loc @arguments = arguments @closing_loc = closing_loc @block = block @flags = flags @name = name @location = location end |
Instance Attribute Details
#arguments ⇒ Object (readonly)
attr_reader arguments: ArgumentsNode?
1404 1405 1406 |
# File 'lib/yarp/node.rb', line 1404 def arguments @arguments end |
#block ⇒ Object (readonly)
attr_reader block: BlockNode?
1410 1411 1412 |
# File 'lib/yarp/node.rb', line 1410 def block @block end |
#call_operator_loc ⇒ Object (readonly)
attr_reader call_operator_loc: Location?
1395 1396 1397 |
# File 'lib/yarp/node.rb', line 1395 def call_operator_loc @call_operator_loc end |
#closing_loc ⇒ Object (readonly)
attr_reader closing_loc: Location?
1407 1408 1409 |
# File 'lib/yarp/node.rb', line 1407 def closing_loc @closing_loc end |
#flags ⇒ Object (readonly)
attr_reader flags: Integer
1413 1414 1415 |
# File 'lib/yarp/node.rb', line 1413 def flags @flags end |
#message_loc ⇒ Object (readonly)
attr_reader message_loc: Location?
1398 1399 1400 |
# File 'lib/yarp/node.rb', line 1398 def @message_loc end |
#name ⇒ Object (readonly)
attr_reader name: String
1416 1417 1418 |
# File 'lib/yarp/node.rb', line 1416 def name @name end |
#opening_loc ⇒ Object (readonly)
attr_reader opening_loc: Location?
1401 1402 1403 |
# File 'lib/yarp/node.rb', line 1401 def opening_loc @opening_loc end |
#receiver ⇒ Object (readonly)
attr_reader receiver: Node?
1392 1393 1394 |
# File 'lib/yarp/node.rb', line 1392 def receiver @receiver end |
Instance Method Details
#accept(visitor) ⇒ Object
def accept: (visitor: Visitor) -> void
1433 1434 1435 |
# File 'lib/yarp/node.rb', line 1433 def accept(visitor) visitor.visit_call_node(self) end |
#call_operator ⇒ Object
def call_operator: () -> String?
1472 1473 1474 |
# File 'lib/yarp/node.rb', line 1472 def call_operator call_operator_loc&.slice end |
#child_nodes ⇒ Object Also known as: deconstruct
def child_nodes: () -> Array[nil | Node]
1438 1439 1440 |
# File 'lib/yarp/node.rb', line 1438 def child_nodes [receiver, arguments, block] end |
#closing ⇒ Object
def closing: () -> String?
1487 1488 1489 |
# File 'lib/yarp/node.rb', line 1487 def closing closing_loc&.slice end |
#comment_targets ⇒ Object
def comment_targets: () -> Array[Node | Location]
1443 1444 1445 |
# File 'lib/yarp/node.rb', line 1443 def comment_targets [*receiver, *call_operator_loc, *, *opening_loc, *arguments, *closing_loc, *block] end |
#copy(**params) ⇒ Object
def copy: (**params) -> CallNode
1448 1449 1450 1451 1452 1453 1454 1455 1456 1457 1458 1459 1460 1461 |
# File 'lib/yarp/node.rb', line 1448 def copy(**params) CallNode.new( params.fetch(:receiver) { receiver }, params.fetch(:call_operator_loc) { call_operator_loc }, params.fetch(:message_loc) { }, params.fetch(:opening_loc) { opening_loc }, params.fetch(:arguments) { arguments }, params.fetch(:closing_loc) { closing_loc }, params.fetch(:block) { block }, params.fetch(:flags) { flags }, params.fetch(:name) { name }, params.fetch(:location) { location }, ) end |
#deconstruct_keys(keys) ⇒ Object
1467 1468 1469 |
# File 'lib/yarp/node.rb', line 1467 def deconstruct_keys(keys) { receiver: receiver, call_operator_loc: call_operator_loc, message_loc: , opening_loc: opening_loc, arguments: arguments, closing_loc: closing_loc, block: block, flags: flags, name: name, location: location } end |
#inspect(inspector = NodeInspector.new) ⇒ Object
1501 1502 1503 1504 1505 1506 1507 1508 1509 1510 1511 1512 1513 1514 1515 1516 1517 1518 1519 1520 1521 1522 1523 1524 1525 1526 1527 1528 |
# File 'lib/yarp/node.rb', line 1501 def inspect(inspector = NodeInspector.new) inspector << inspector.header(self) if (receiver = self.receiver).nil? inspector << "├── receiver: ∅\n" else inspector << "├── receiver:\n" inspector << receiver.inspect(inspector.child_inspector("│ ")).delete_prefix(inspector.prefix) end inspector << "├── call_operator_loc: #{inspector.location(call_operator_loc)}\n" inspector << "├── message_loc: #{inspector.location()}\n" inspector << "├── opening_loc: #{inspector.location(opening_loc)}\n" if (arguments = self.arguments).nil? inspector << "├── arguments: ∅\n" else inspector << "├── arguments:\n" inspector << arguments.inspect(inspector.child_inspector("│ ")).delete_prefix(inspector.prefix) end inspector << "├── closing_loc: #{inspector.location(closing_loc)}\n" if (block = self.block).nil? inspector << "├── block: ∅\n" else inspector << "├── block:\n" inspector << block.inspect(inspector.child_inspector("│ ")).delete_prefix(inspector.prefix) end inspector << "├── flags: #{[("safe_navigation" if ), ("variable_call" if variable_call?)].compact.join(", ")}\n" inspector << "└── name: #{name.inspect}\n" inspector.to_str end |
#message ⇒ Object
def message: () -> String?
1477 1478 1479 |
# File 'lib/yarp/node.rb', line 1477 def &.slice end |
#opening ⇒ Object
def opening: () -> String?
1482 1483 1484 |
# File 'lib/yarp/node.rb', line 1482 def opening opening_loc&.slice end |
#safe_navigation? ⇒ Boolean
def safe_navigation?: () -> bool
1492 1493 1494 |
# File 'lib/yarp/node.rb', line 1492 def flags.anybits?(CallNodeFlags::SAFE_NAVIGATION) end |
#variable_call? ⇒ Boolean
def variable_call?: () -> bool
1497 1498 1499 |
# File 'lib/yarp/node.rb', line 1497 def variable_call? flags.anybits?(CallNodeFlags::VARIABLE_CALL) end |