0
     ˆÊÉÎ532È¿Ë     ‹      ½•moÓ0ÇßïS¿à]sMÚÁœ ÑT¢R×V] „�»�7'Žl‡n|zœ¦Sj�i)RÎÎßw÷»œÎäE<$ŸfCô.¹£Ùû·ãÑ áÀ‡Þ  NâöCßëú Ã	F8·¶º X­VÞªç)½„d¹-dŒÕ"³³G'¤Ù‹NÉ9eî�ˆVòhT2~�Ô�ª­Œ÷¡6LN5‡R1~k@Š´¬ŠªN¥0ùzók¡X-¹£²;i-$#Ðzt1`„¤Š=4±ý£ÆqîÖ 4]‡kL›£oTŠeb«*Q,‘ÑYˆAdªt§%-ï¼¥X`D¥ñçÑ`úÅéÀæÍéˆP”k¾ñ›A8¹œ†W8šÐ‚ û5×­fL�E.O±œß´âñý°Ã¸ÕÄÜdZTV¨r+‡¸‹š)i*êXOA®wU­„ý©4û©³«ùp’Ä£y[Ö¸Øf÷œ¿†£™“—ÅBóÌ*ý°Ájc¼,SS]>.Ñ&i-–¹ÅB´WùRËïí.iò1ÙË(šõnŽ­Ý<I,èAÇw��üÓ‹îk„Ïú¯þ;�WÐjKÑ¬ŽAâçÏ&Y(É¸Þe9Ôq™*
UºæÙ¿'èuºç�à¬!ð{	ŽÑMO �Âu}CÐÿžà/çl&'�õ|&ÐÞ? k¸ôw~       !ˆÊÉÎ‚l@È¿Ë     !‹      µ”ÝŽÓ0…ï÷)Œ/¸K¦iC‘ºNPi*Q±ýQ7âÂ‰ÝÄZ×Žlw»åéq›²[P»€R¤L’ã™óÍÄ&/²ù(ÿ¼£wùô->¼½™Œ >öF Yžµâ°ŒgáÚ¹f °ÝnÃm/Ô¦‚|	µ[Ë¬3¢t!s§Wdÿ.½B¤æ”ù;"N8ÉÓ‰büé½qV0ÃÆ°55˜.AiÆƒ‚\�ÜTB�Ñ�¶Tj#¥°uPj*¹-…ªÝpC�6Úô¾ +’B³ÝÞHôÿŠúÜ4ZjïC“W£{*E¥ìtƒS"Ö²¦L0ˆR+…¤ê.¬Ä
#*]‚¿LFó¯^®Þ¯N	Eµá«¿%³ëy2ÄéŒ®9z^3m57Ô:´ÖL¬gÅ·­øV|»œ0k5™6¢qB«')xÄSÔRKÛPÏúÊÔæTÕJØïºAËŸš±.Ç³<›,Û–°}Š'w—FˆÓ…•C™0¼ôÓÙ-·ë_ªÂ6×?ÑÑ�UípŠP€Î*ÿ‚b£î”ÞªSß¤³¥nvÇÊ�á©Ù_Üu;Ý^uý…¢î Šº„õÞÿ+†ãî”!ÿ”ŸeXŽ‡Ùt®ý^ŸgˆƒN?ˆú¨â×â~ï™QüáoÇIàph£ïG-Àï       #ˆÊÉÎ497È¿Ë ñ    #‹      Õ•AoÚ@…ïùÓ=ôfµÉÚUŠ‘ŠJ€‚«¨ªªjm/ö
³K×CMúëkcª@jZ©•r²=ûæù}ciÌ_ã^øiÒ‡wáí&ß=`â]§‡„AsÐmµ]ÄþˆËˆVWˆeY¶ÊNËØÃ)f´Ì»X�U1µJ˜Æëš<“"©®ÀIQ.ý�NäÌÐ¬©P‰ìb®"Ü¼ºüzÙur¥×'ÕküFõ�ÜÈ˜cÓZ™áÎ�G&¹¯_âþ�aÕ·�$¢­o}k}N|¹JµÇÈ¬˜ÏÕ2…ÂÆC]`”½h¥jÎ@ää±ÏƒÞøK¥CÊênŸÈ¬œ{ìMÏ]�½æ�ÄRrÇ5·�f(
‚¥IÔ\Éä¤xÖˆgêÇiÃ Ñ²ˆ­Z‘2úAŠâ>jlòb%*Ö‹Š ³ûªF’ün">ÆäfÚ…Á`ÚŒ$©-Ò=áó0"¬Ô�²2&cïwé«—:*V×¿a—Íª4#æ8pTù@k½Ð¦ÔûLÕ¼ŽÒ| ;Íªˆ"•kbYÌ?RÜx”ø¼}ÞqÚ®ãv ýúªíœBs»ïÿ7Ú!Ós‡É×©Ò��ökÏl$©4vqHvXü÷hO\)¸[¶·»›cóƒø	‰ž43ƒ    D   %ˆl–ßi~””†»%�À¶¦-ÿ�þH6VnB:ÈJórŒ€þÐƒdL·Ï_�uÐb&=LyZËcõÁÍ £    %# frozen_string_literal: true

require_relative "nop"
require_relative "../color"
require_relative "../ruby-lex"

# :stopdoc:
module IRB
  module ExtendCommand
    class ShowSource < Nop
      def execute(str = nil)
        unless str.is_a?(String)
          puts "Error: Expected a string but got #{str.inspect}"
          return
        end
        source = find_source(str)
        if source && File.exist?(source.file)
          show_source(source)
        else
          puts "Error: Couldn't locate a definition for #{str}"
        end
        nil
      end

      private

      # @param [IRB::ExtendCommand::ShowSource::Source] source
      def show_source(source)
        puts
        puts "#{bold("From")}: #{source.file}:#{source.first_line}"
        puts
        code = IRB::Color.colorize_code(File.read(source.file))
        puts code.lines[(source.first_line - 1)...source.last_line].join
        puts
      end

      def find_source(str)
        case str
        when /\A[A-Z]\w*(::[A-Z]\w*)*\z/ # Const::Name
          eval(str, irb_context.workspace.binding) # trigger autoload
          base = irb_context.workspace.binding.receiver.yield_self { |r| r.is_a?(Module) ? r : Object }
          file, line = base.const_source_location(str) if base.respond_to?(:const_source_location) # Ruby 2.7+
        when /\A(?<owner>[A-Z]\w*(::[A-Z]\w*)*)#(?<method>[^ :.]+)\z/ # Class#method
          owner = eval(Regexp.last_match[:owner], irb_context.workspace.binding)
          method = Regexp.last_match[:method]
          if owner.respond_to?(:instance_method) && owner.instance_methods.include?(method.to_sym)
            file, line = owner.instance_method(method).source_location
          end
        when /\A((?<receiver>.+)(\.|::))?(?<method>[^ :.]+)\z/ # method, receiver.method, receiver::method
          receiver = eval(Regexp.last_match[:receiver] || 'self', irb_context.workspace.binding)
          method = Regexp.last_match[:method]
          file, line = receiver.method(method).source_location if receiver.respond_to?(method)
        end
        if file && line
          Source.new(file: file, first_line: line, last_line: find_end(file, line))
        end
      end

      def find_end(file, first_line)
        return first_line unless File.exist?(file)
        lex = RubyLex.new
        lines = File.read(file).lines[(first_line - 1)..-