class SyntaxTree::ArgParen
Experimental RBS support (using type sampling data from the type_fusion
project).
# sig/syntax_tree/node.rbs class SyntaxTree::ArgParen < SyntaxTree::Node def accept: (Visitor visitor) -> untyped def child_nodes: () -> untyped def initialize: (arguments: SyntaxTree::Args, location: SyntaxTree::Location) -> void end
method()
argument child node can be nil
if no arguments were passed, as in:
that represents the set of arguments being sent to the method method. The
In the example above, there would be an ArgParen node around the Args node
method(argument)
parentheses.
ArgParen represents wrapping arguments to a method inside a set of
def ===(other)
def ===(other) other.is_a?(ArgParen) && arguments === other.arguments end
def accept(visitor)
Experimental RBS support (using type sampling data from the type_fusion
project).
def accept: (Visitor visitor) -> untyped
This signature was generated using 8 samples from 1 application.
def accept(visitor) visitor.visit_arg_paren(self) end
def arity
def arity arguments&.arity || 0 end
def child_nodes
Experimental RBS support (using type sampling data from the type_fusion
project).
def child_nodes: () -> untyped
This signature was generated using 13 samples from 1 application.
def child_nodes [arguments] end
def copy(arguments: nil, location: nil)
def copy(arguments: nil, location: nil) node = ArgParen.new( arguments: arguments || self.arguments, location: location || self.location ) node.comments.concat(comments.map(&:copy)) node end
def deconstruct_keys(_keys)
def deconstruct_keys(_keys) { arguments: arguments, location: location, comments: comments } end
def format(q)
def format(q) unless arguments q.text("()") return end q.text("(") q.group do q.indent do q.breakable_empty q.format(arguments) q.if_break { q.text(",") } if q.trailing_comma? && trailing_comma? end q.breakable_empty end q.text(")") end
def initialize(arguments:, location:)
Experimental RBS support (using type sampling data from the type_fusion
project).
def initialize: (arguments: SyntaxTree::Args, location: SyntaxTree::Location) -> void
This signature was generated using 2 samples from 1 application.
def initialize(arguments:, location:) @arguments = arguments @location = location @comments = [] end
def trailing_comma?
def trailing_comma? arguments = self.arguments return false unless arguments.is_a?(Args) parts = arguments.parts if parts.last.is_a?(ArgBlock) # If the last argument is a block, then we can't put a trailing comma # after it without resulting in a syntax error. false elsif (parts.length == 1) && (part = parts.first) && (part.is_a?(Command) || part.is_a?(CommandCall)) # If the only argument is a command or command call, then a trailing # comma would be parsed as part of that expression instead of on this # one, so we don't want to add a trailing comma. false else # Otherwise, we should be okay to add a trailing comma. true end end