Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Would Sorbet signatures be in scope? #175

Open
bmulholland opened this issue May 31, 2021 · 3 comments
Open

Would Sorbet signatures be in scope? #175

bmulholland opened this issue May 31, 2021 · 3 comments

Comments

@bmulholland
Copy link

bmulholland commented May 31, 2021

Sorbet information is largely connected to the actual syntax, and ideally I'd love features like "add/modify/re-order/remove attributes from sorbet sig when changing the method definition."

At a conceptual level, the signatures are part of the ruby structure - but it also isn't officially part of Ruby.

However, I have no idea if that is something that would be in scope for treesitter generally, or the ruby support in particular.

If it wouldn't belong here, where would it? What about ruby 3 RBS files?

@mbj
Copy link

mbj commented May 31, 2021

I think you can parse sorbet out of the 'regular' ruby AST easily as a postprocessor. I do not think sorbet should get primary AST nodes, as long they are "regular ruby".

@bmulholland
Copy link
Author

Post processing does conceptually map to the implementation of Sorbet.

I'm pretty new to the concepts of ASTs etc (read: I have no idea what I'm talking about) - does that mean that one could implement a treesitter grammar plugin that depends on the base ruby grammar (this project) and extends it to include connections to sorbet signatures?

@dcreager
Copy link
Contributor

dcreager commented Jun 1, 2021

does that mean that one could implement a treesitter grammar plugin that depends on the base ruby grammar

This sounds like a good use for tree-sitter's (admittedly poorly documented) "base grammar" feature. You can pass in a base grammar as an additional parameter to the grammar function, which allows you to build on top of an existing grammar. That's what we do for the TypeScript and TSX grammars (tree-sitter/tree-sitter-typescript) to build on the JavaScript grammar (tree-sitter/tree-sitter-javascript).

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

No branches or pull requests

3 participants