class Vernacular::AST::Modifiers::TypedMethodArgs

Extends Ruby syntax to allow typed method argument declarations, as in:

def my_method(argument_a : Integer, argument_b : String); end

Private Class Methods

new() click to toggle source
Calls superclass method
# File lib/vernacular/ast/modifiers/typed_method_args.rb, line 9
        def initialize
          super

          extend_parser(:f_arg, 'f_arg tCOLON cpath', <<~PARSE)
            result = @builder.type_check_arg(*val)
          PARSE

          extend_builder(:type_check_arg) do |args, colon, cpath|
            location = args[0].loc.with_operator(loc(colon))
                              .with_expression(join_exprs(args[0], cpath))
            [n(:type_check_arg, [args, cpath], location)]
          end

          build_rewriter { include TypedMethodArgsRewriter }
        end