Sha256: 88b0f46eb58ce2e875195e9383c3293e1d896ed34d1560b991929fdf5bccd4e0

Contents?: true

Size: 732 Bytes

Versions: 7

Compression:

Stored size: 732 Bytes

Contents

# frozen_string_literal: true

module RubyNext
  module Language
    module Rewriters
      class MethodReference < Base
        NAME = "method-reference"
        SYNTAX_PROBE = "Language.:transform"
        MIN_SUPPORTED_VERSION = Gem::Version.new("3.0.0")

        def on_meth_ref(node)
          context.track! self

          receiver, mid = *node.children

          replace(
            node.children.first.loc.expression.end.join(
              node.loc.expression.end
            ),
            ".method(:#{mid})"
          )

          node.updated(
            :send,
            [
              receiver,
              :method,
              s(:sym, mid)
            ]
          )
        end
      end
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
ruby-next-core-0.11.0 lib/ruby-next/language/rewriters/method_reference.rb
ruby-next-core-0.10.5 lib/ruby-next/language/rewriters/method_reference.rb
ruby-next-core-0.10.4 lib/ruby-next/language/rewriters/method_reference.rb
ruby-next-core-0.10.3 lib/ruby-next/language/rewriters/method_reference.rb
ruby-next-core-0.10.2 lib/ruby-next/language/rewriters/method_reference.rb
ruby-next-core-0.10.1 lib/ruby-next/language/rewriters/method_reference.rb
ruby-next-core-0.10.0 lib/ruby-next/language/rewriters/method_reference.rb