class SyntaxTree::Parser
def on_params(
Experimental RBS support (using type sampling data from the type_fusion
project).
def on_params: (Array[SyntaxTree::Ident]? requireds, Array[Array, SyntaxTree::Ident, SyntaxTree::HashLiteral]? optionals, SyntaxTree::RestParam? rest, nil posts, nil keywords, nil keyword_rest, SyntaxTree::BlockArg? block) -> untyped
This signature was generated using 6 samples from 1 application.
(nil | :& | BlockArg) block
(nil | :nil | ArgsForward | KwRestParam) keyword_rest,
(nil | Array[[Ident, nil | untyped]]) keywords,
(nil | Array[Ident]) posts,
(nil | ArgsForward | ExcessedComma | RestParam) rest,
(nil | Array[[Ident, untyped]]) optionals,
(nil | Array[Ident]) requireds,
on_params: (
:call-seq:
def on_params( requireds, optionals, rest, posts, keywords, keyword_rest, block ) # This is to make it so that required keyword arguments # have a `nil` for the value instead of a `false`. keywords&.map! { |(key, value)| [key, value || nil] } # Here we're going to build up a list of all of the params so that we can # determine our location information. parts = [] requireds&.each { |required| parts << required.location } optionals&.each do |(key, value)| parts << key.location parts << value.location if value end parts << rest.location if rest posts&.each { |post| parts << post.location } keywords&.each do |(key, value)| parts << key.location parts << value.location if value end if keyword_rest == :nil # When we get a :nil here, it means that we have **nil syntax, which # means this set of parameters accepts no more keyword arguments. In # this case we need to go and find the location of these two tokens. operator = consume_operator(:**) parts << operator.location.to(consume_keyword(:nil).location) elsif keyword_rest parts << keyword_rest.location end parts << block.location if block && block != :& parts = parts.compact location = if parts.any? parts[0].to(parts[-1]) else Location.fixed(line: lineno, char: char_pos, column: current_column) end Params.new( requireds: requireds || [], optionals: optionals || [], rest: rest, posts: posts || [], keywords: keywords || [], keyword_rest: keyword_rest, block: (block if block != :&), location: location ) end