Closed joshuabezaleel closed 2 years ago
This was still really much of a work in progress so I am really sorry in advance for all of the commented code and log print 😞 @slimsag
OK cool, this helped a lot. Here's what I did:
First, I ran this on a Java repo - and it error'd out, as you said it would.
Then I tried removing parts of the query, and it worked, like I thought:
So why do those parts of the query not work? I added some code to capture the full @doc
and print that capture to see what nodes are available, my full changes looked like this:
This spammed my terminal with a ton of nodes, but one thing I noticed was that some of the nodes look like this:
nsequence: (block (comment) (comment) (comment) (comment) (comment) (comment) (return_statement (true)))))) (return_statement (false))))))]
I thought it was strange that (comment)
differed from our original query for (block_comment)
, and so I thought maybe the grammar was outdated: I found the Java grammar here and searched for block_comment
to see if that node exists, and it does here:
Now it starts to look a bit more clear: comment
can describe either a line_comment
or a block_comment
, so if a block_comment
doesn't exist..? Well, then we'd get that error. I tried that change, and it works! 🥳
Hope that helps @joshuabezaleel ! Let me know if you have any questions, I'll close this PR - feel free to create a new one whenever
As for why this worked on the playground.. I suspect the playground is out of date, and the Java grammar used by tree-sitter-go is more recent, but I'm not 100% sure :)