Skip to content

Port prototype rbi generation to prism - #3105

Open
Earlopain wants to merge 1 commit into
ruby:masterfrom
Earlopain:prototype-rbi-prism
Open

Port prototype rbi generation to prism#3105
Earlopain wants to merge 1 commit into
ruby:masterfrom
Earlopain:prototype-rbi-prism

Conversation

@Earlopain

Copy link
Copy Markdown
Contributor

Apart from porting to prism, this also does the following:

  1. Remove variable tracking for type_of0.
    It contains AST::TypeParam but checked for inclusion of a Symbol. There's no difference in the output even when this is fixed, so I just removed it entirely
  2. Have the parse method return declarations, make it a class method.
    Just more convenient with the new structure. Eventually rb prototype will do this as well
  3. Allow to use it on jruby/truffleruby.
  4. Split comment parsing from comment processing in the helper.
    In rbi the comments now come from a plain parse. When prototype rb uses prism as well, parse_comments can be removed (as well as most of the other helper methods there)

I tested this against code samples from https://github.com/Shopify/tapioca/blob/d029cc9c3f76865f61fdbaff68d75e18a0014764/spec/tapioca/gem/pipeline_spec.rb
The output is largely the same, and improved in some areas. For example, type_member with no paren is no longer considered an untyped constant. Previously that was only the case for type_member() or when an argument was passed like type_member(:out).

For #348

@Earlopain
Earlopain marked this pull request as ready for review August 26, 2026 17:25
@Earlopain

Copy link
Copy Markdown
Contributor Author

cc @eregon

Apart from porting to prism, this also does the following:

1. Remove `variable` tracking for `type_of0`. It contains `AST::TypeParam` but checked for inclusion of a Symbol.
There's no difference in the output even when this is fixed, so I just removed it entirely
2. Have the parse method return declarations, make it a class method.
Just more convenient with the new structure. Eventually `rb prototype` will do this as well
3. Allow to use it on jruby/truffleruby.
4. Split comment parsing from comment processing in the helper.
In rbi the comments now come from a plain parse. When `prototype rb` uses prism as well, `parse_comments` can be
removed (as well as most of the other helper methods there)

I tested this against code samples from https://github.com/Shopify/tapioca/blob/d029cc9c3f76865f61fdbaff68d75e18a0014764/spec/tapioca/gem/pipeline_spec.rb
The output is largely the same, and improved in some areas. For example, `type_member` with no paren
is no longer considered an untyped constant. Previously that was only the case for `type_member()` or when
an argument was passed like `type_member(:out)`.
@Earlopain
Earlopain force-pushed the prototype-rbi-prism branch from 5e2b785 to 3d82789 Compare August 26, 2026 17:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant