Sha256: 40bbcc6b9c0d99e41efe58a7e16c949d29f01a718cf89a22b006c8ea896362e5

Contents?: true

Size: 847 Bytes

Versions: 4

Compression:

Stored size: 847 Bytes

Contents

# frozen_string_literal: true

module RubyNext
  module Language
    module Rewriters
      class EndlessMethod < Base
        SYNTAX_PROBE = "obj = Object.new; def obj.foo() = 42"
        MIN_SUPPORTED_VERSION = Gem::Version.new("2.8.0")

        def on_def_e(node)
          context.track! self

          replace(node.loc.assignment, "; ")
          insert_after(node.loc.expression, "; end")

          process(
            node.updated(
              :def,
              node.children
            )
          )
        end

        def on_defs_e(node)
          context.track! self

          replace(node.loc.assignment, "; ")
          insert_after(node.loc.expression, "; end")

          process(
            node.updated(
              :defs,
              node.children
            )
          )
        end
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
ruby-next-core-0.9.1 lib/ruby-next/language/rewriters/endless_method.rb
ruby-next-core-0.9.0 lib/ruby-next/language/rewriters/endless_method.rb
ruby-next-core-0.9.0.pre lib/ruby-next/language/rewriters/endless_method.rb
ruby-next-core-0.8.0 lib/ruby-next/language/rewriters/endless_method.rb