Sha256: 371903a4b0291a6fcfc2911ec2680e456ee5425b28a3911001c19da68fca2cc8
Contents?: true
Size: 925 Bytes
Versions: 7
Compression:
Stored size: 925 Bytes
Contents
# frozen_string_literal: true module RubyNext module Language module Rewriters class ShorthandHash < Base NAME = "shorthand-hash" SYNTAX_PROBE = "data = {x}" MIN_SUPPORTED_VERSION = Gem::Version.new("3.0.0") def on_ipair(node) context.track! self ident, = *node.children key = key_from_ident(ident) replace( node.loc.expression, "#{key}: #{key}" ) node.updated( :pair, [ s(:sym, key), ident ] ) end private def key_from_ident(node) case node.type when :send node.children[1] when :lvar node.children[0] else raise ArgumentError, "Unsupport ipair node: #{node}" end end end end end end
Version data entries
7 entries across 7 versions & 1 rubygems