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.
What problem are you trying to solve?
Fix various bugs
What is your solution?
Pass JsRuntime into test helper function
(Sneaking this in) We need to pass in a reference to
JsRuntime
so we can later inspect it in tests.Ensure the QueryMatch and Violation bridges are wiped clean, even after an execution error."
We previously returned early via
?
on a scoped execution. This led to bridges getting in an inconsistent state after an error. For example, a script might have mutated a bridge by successfully pushing a Violation to it, and then it threw an error. This would've left a violation on the bridge, which would've been drained by the next successful execution, leading to unexpected results.Update file context from
set_file_context
, not automatically fromset_root_context
.There was a "bug" here that caused the go module query code to run for every file, regardless of whether it was a go file or not. I'm refactoring the bridges to have less logic within their individual functions, relying instead on the
JsRuntime
to trigger the necessary logic. This implicitly fixes the aforementioned bug.Filter results from the
tree_sitter::QueryCursor
that have no captures. Additionally, add guard to return earlyA
tree_sitter::QueryCursor
can return a vec of empty vecs (e.g.[ [], [], [], [] ] // ...
), which would cause a v8 execution for each empty vec. This adds two guards against this and a test to ensure it can't happen.Use Arc to pass around tree_sitter::Tree
It turns out when a
tree_sitter::Tree
is cloned, it doesn't point to the same root node as the tree being cloned. We need to use a reference counting pointer to get the behavior we desire (detecting effective equivalence of two trees)Clear the TsNodeBridge when the tree_sitter::Tree changes on the RootContext
There was no bug in analysis behavior, however, before this commit, we were keeping all nodes ever serialized in the
TsNodeBridge
, meaning they wouldn't be garbage-collected. This clears the bridge whenever the tree changes.Alternatives considered
What the reviewer should know