class Protobuf::Generators::FileGenerator

def map_extensions(descriptor, namespaces)


the value is an array of field descriptors.
The key is the type_name of the message being extended, and
Recursively map out all extensions known in this file.
def map_extensions(descriptor, namespaces)
  if fully_qualified_token?(descriptor.name)
    fully_qualified_namespace = descriptor.name
  elsif !(namespace = namespaces.reject(&:empty?).join(".")).empty?
    fully_qualified_namespace = ".#{namespace}"
  end
  # Record all the message descriptor name's we encounter (should be the whole tree).
  if descriptor.is_a?(::Google::Protobuf::DescriptorProto)
    if fully_qualified_token?(descriptor.name)
      @known_messages << descriptor.name
    else
      fully_qualified_namespace = ".#{namespaces.join('.')}"
      @known_messages << fully_qualified_namespace
    end
  end
  descriptor.extension.each do |field_descriptor|
    unless fully_qualified_token?(field_descriptor.name) && fully_qualified_namespace
      field_descriptor.name = "#{fully_qualified_namespace}.#{field_descriptor.name}"
    end
    @extension_fields[field_descriptor.extendee] << field_descriptor
  end
  [:message_type, :nested_type].each do |type|
    next unless descriptor.respond_to_has_and_present?(type)
    descriptor.public_send(type).each do |type_descriptor|
      map_extensions(type_descriptor, (namespaces + [type_descriptor.name]))
    end
  end
end