feat: Add support for RBS inline type annotations#279
Open
pcasaretto wants to merge 1 commit intotree-sitter:masterfrom
Open
feat: Add support for RBS inline type annotations#279pcasaretto wants to merge 1 commit intotree-sitter:masterfrom
pcasaretto wants to merge 1 commit intotree-sitter:masterfrom
Conversation
Morriar
reviewed
Aug 25, 2025
| @@ -0,0 +1,231 @@ | |||
| ======================= | |||
There was a problem hiding this comment.
Could you add a test showing the behavior if the #: is found inside a string:
puts "#: Hello, World"
Author
There was a problem hiding this comment.
Added some more edge cases involving strings.
3ce9025 to
57b2f6b
Compare
Adds recognition of RBS (Ruby Signature) inline type annotation comments to enable better editor support for Ruby type annotations. Changes: - Add rbs_type_comment token for #: comments - Add rbs_continuation_comment token for #| comments - Include both tokens in extras to allow them anywhere - Add highlighting queries to style RBS comments as @type.annotation - Add comprehensive test coverage with 11 test cases This implementation intentionally only recognizes RBS comment patterns without parsing the type syntax itself. This keeps the grammar simple while providing the foundation for tools to identify and process type annotations separately. RBS comments are now distinguished from regular comments in the AST, allowing editors to provide enhanced type information display and navigation for Ruby code with inline type signatures.
57b2f6b to
50c5dd3
Compare
Morriar
approved these changes
Feb 19, 2026
|
This is a cool change, how do we get someone from the team to review/merge it? @amaanq I see you've been active in this repo recently 🙏 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This PR adds support for recognizing RBS (Ruby Signature) inline type annotation comments in Ruby code. This enables better editor support for Ruby's type annotations by distinguishing them from regular comments in the AST.
Motivation
RBS is Ruby's official type signature language, and increasingly Ruby developers are using inline RBS comments to annotate their code with type information:
Currently, tree-sitter-ruby treats these as regular comments, making it impossible for editors to provide enhanced support for type annotations (different highlighting, hover information, etc.).
Implementation
This implementation takes a minimal approach - it recognizes RBS comment patterns without parsing the type syntax itself:
#:comments are recognized asrbs_type_commenttokens#|comments (multi-line continuations) are recognized asrbs_continuation_commenttokens#comments remain unchangedWhy not parse the full RBS syntax?
Changes
rbs_type_commentandrbs_continuation_commenttoken rules@type.annotation(vs@commentfor regular comments)Testing
All tests pass (301 total, including 11 new RBS tests):
Impact
Related Work