Skip to content

Improve IDE support for Ruby #9495

@acozzette

Description

@acozzette

The generated Ruby code is not very IDE-friendly, and could be improved to support things like auto-completion. For Python, we're going in the direction of making the main generated code small and efficient but not human-readable, and generating separate .pyi files that are more human-readable and IDE-friendly. We need to figure out a plan for Ruby, though.

#7593 suggests one solution, which would be to embed code in if false blocks so that it's visible to the IDE and to human readers without changing behavior. @haberman also suggesting doing something like this:

Google::Protobuf::DescriptorPool.generated_pool.add_serialized_descriptor(
  "<serialized_descriptor>"
)

# Google::Protobuf::Message defines #inherited to hook in the correct behaviors.
# This fails if #add_serialized_descriptor has not been called for "Foo."
class Foo < Google::Protobuf::Message
  # The base class overrides attr_accessor to do the right thing (maybe even
  # define it as a no-op if #inherited is handling the hard part.
  attr_accessor :foo
end

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementinactiveDenotes the issue/PR has not seen activity in the last 90 days.ruby

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions