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
refactor(bundler): New Gemfile parser based on "tree-sitter" #28403
base: main
Are you sure you want to change the base?
Conversation
Okay, now it's obvious that particular |
Or, another possibility that it has something to do with our aggressive CI caching |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
another parser? isn't your self written parser good enough?
it's probably related to node v18 issues?
Nah, it's not good enough 😂 |
I don't know, the local setup on my M1 machine works fine for both 18 and 20 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
looks complicated 🫣
@@ -135,10 +135,10 @@ describe('modules/manager/bundler/extract', () => { | |||
'Gemfile', | |||
); | |||
expect(res?.deps).toMatchObject([ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why the order changes?
@@ -0,0 +1,327 @@ | |||
import Parser, { Query, SyntaxNode } from 'tree-sitter'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it seems it's something like antlr?
does it make sense to use it for more languages?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, it is similar to Antlr, now it's gaining popularity among text editor enthusiasts (specifically, Neovim), and it powers GitHub's syntax highlight.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
does it make sense to use it for more languages?
It supports quite a bit of languages: https://tree-sitter.github.io/tree-sitter/
The problem is, like this Ruby implementation, many of them are not compatible with the recent node binding.
Co-authored-by: Michael Kriese <michael.kriese@visualon.de>
Changes
This PR introduces "tree-sitter" for parsing dependencies from complex languages.
Context
The current regex-based implementation is hard to maintain.
It blocks implementation of #4789, which should be straightforward with this new parsing approach.
Documentation (please check one with an [x])
How I've tested my work (please select one)
I have verified these changes via: