fix(tree-sitter): pass node text to grammar #860
Merged
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.
Identify the Bug
The WASM tree-sitter language mode does not pass node text into the grammar when calling
idForScope
. This is a breaking change from the legacy tree-sitter language mode that prevents the semanticolor package from working with Pulsar's new tree-sitter modes. I believe that this only affects semanticolor, as the original change was made explicitly for that package. (See atom/atom#20212)References
idForScope
and makes use of the text: https://github.com/digitallyserviced/semanticolor/blob/master/lib/semanticolor-grammar.js#L44-L65Description of the Change
I updated
ScopeResolver
andWASMTreeSitterLanguageMode
to pass the syntax node text through toWASMTreeSitterGrammar
. I also updatedWASMTreeSitterGrammar
andTreeSitterGrammar
to highlight why the seemingly unused parameter is needed. Once I identified what was needed, the change was easy.Alternate Designs
I looked around to see if there was a better way of getting the package working w/ the new mode, but didn't see anything obvious. Open to suggestions if there are other ways that I didn't see.
Possible Drawbacks
It is a little strange to make a change like this only to support a single package. That said, I love that package and I'm happy to be able to keep it going.
Verification Process
I did not add or update any tests, but I could attempt to do so if desired. I verified this by
semanticolor
so that it recognizesWASMTreeSitterGrammar
s, in addition to legacy grammarsRelease Notes
Added support for the semanticolor package in modern tree-sitter grammars.