protobuf icon indicating copy to clipboard operation
protobuf copied to clipboard

Improve IDE support for Ruby

Open acozzette opened this issue 3 years ago • 4 comments

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

acozzette avatar Feb 11 '22 20:02 acozzette

I think RBS is a promising direction here: https://blog.appsignal.com/2021/01/27/rbs-the-new-ruby-3-typing-language-in-action.html

We could make the main generated code foo_pb.rb nothing but a serialized descriptor. Then we could have a separate foo_pb.rbs file that contains full static typing information, for IDE-friendliness.

haberman avatar Mar 08 '22 18:03 haberman

We triage inactive PRs and issues in order to make it easier to find active work. If this issue should remain active or becomes active again, please add a comment.

This issue is labeled inactive because the last activity was over 90 days ago.

github-actions[bot] avatar Jan 29 '24 10:01 github-actions[bot]

This issue is still active per pending PR https://github.com/protocolbuffers/protobuf/pull/15633

zhangskz avatar Feb 05 '24 16:02 zhangskz

We triage inactive PRs and issues in order to make it easier to find active work. If this issue should remain active or becomes active again, please add a comment.

This issue is labeled inactive because the last activity was over 90 days ago.

github-actions[bot] avatar May 06 '24 10:05 github-actions[bot]

We triage inactive PRs and issues in order to make it easier to find active work. If this issue should remain active or becomes active again, please reopen it.

This issue was closed and archived because there has been no new activity in the 14 days since the inactive label was added.

github-actions[bot] avatar May 20 '24 10:05 github-actions[bot]