File: forward_args_node.rb

package info (click to toggle)
ruby-rubocop-ast 0.3.0%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 892 kB
  • sloc: ruby: 10,886; makefile: 4
file content (33 lines) | stat: -rw-r--r-- 949 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# frozen_string_literal: true

module RuboCop
  module AST
    # A node extension for `forward-args` nodes. This will be used in place
    # of a plain node when the builder constructs the AST, making its methods
    # available to all `forward-args` nodes within RuboCop.
    #
    # Not used with modern emitters:
    #
    #   $ ruby-parse -e "def foo(...); end"
    #   (def :foo
    #     (args
    #       (forward-arg)) nil)
    #   $ ruby-parse --legacy -e "->(foo) { bar }"
    #   (def :foo
    #     (forward-args) nil)
    #
    # Note the extra 's' with legacy form.
    #
    # The main RuboCop runs in legacy mode; this node is only used
    # if user `AST::Builder.modernize` or `AST::Builder.emit_lambda=true`
    class ForwardArgsNode < Node
      include CollectionNode

      # Node wraps itself in an array to be compatible with other
      # enumerable argument types.
      def to_a
        [self]
      end
    end
  end
end