<commit_before>require 'inch/language/elixir/provider/reader/object/function_parameter_object'

module Inch
  module Language
    module Elixir
      module Provider
        module Reader
          module Object
            # Proxy class for functions
            class FunctionObject < Base
              def name
                @hash['id']
              end

              def fullname
                @hash['module_id'] + '.' + @hash['id']
              end

              def method?
                true
              end

              def parameters
                names = FunctionSignature.new(@hash['signature']).parameter_names
                names.map do |name|
                  FunctionParameterObject.new(self, name)
                end
              end

              private

              class FunctionSignature < Struct.new(:signature)
                def parameter_names
                  names = []
                  signature.each do |tuple|
                    if name = name_from_tuple(*tuple)
                      names << name
                    end
                  end
                  names
                end

                def name_from_tuple(a, _, b)
                  if b.nil?
                    a
                  else
                    if a == "\\\\"
                      b.first.first
                    end
                  end
                end
              end

            end
          end
        end
      end
    end
  end
end<commit_msg>Fix elixir parameter parsing<commit_after>require 'inch/language/elixir/provider/reader/object/function_parameter_object'

module Inch
  module Language
    module Elixir
      module Provider
        module Reader
          module Object
            # Proxy class for functions
            class FunctionObject < Base
              def name
                @hash['id']
              end

              def fullname
                @hash['module_id'] + '.' + @hash['id']
              end

              def method?
                true
              end

              def parameters
                names = FunctionSignature.new(@hash['signature']).parameter_names
                names.map do |name|
                  FunctionParameterObject.new(self, name)
                end
              end

              private

              class FunctionSignature < Struct.new(:signature)
                def parameter_names
                  return [] if signature.nil?
                  signature.map do |tuple|
                    name_from_tuple(*tuple)
                  end
                end

                def name_from_tuple(a, _, b)
                  if b.nil? || b == 'Elixir'
                    a
                  else
                    if a == "\\\\"
                      name_from_tuple(*b.first)
                    else
                      warn "[WARN] could not parse FunctionSignature: #{[a, _, b].inspect}"
                    end
                  end
                end
              end

            end
          end
        end
      end
    end
  end
end
{'fraction_non_alphanumeric': 0.060498220640569395, 'fraction_numerical': 0.0, 'mean_word_length': 0.8830694275274056, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5012275', 'n_tokens_mistral': 724, 'n_tokens_neox': 653, 'n_words': 179}