However, there is still a logic bug that causes the FileContext to be regenerated for every execution, which is wasteful, as it doesn't change between different rule executions.
What is your solution?
Update the FileContext only when a call to set_root_context detects that the tree changed.
Alternatives considered
What the reviewer should know
Relevant change is ~15 LOC, the rest is test boilerplate + tests.
This PR also tests the transition between two executions to make sure FileContexts aren't co-mingled (just like we do for Arguments)
What problem are you trying to solve?
https://github.com/DataDog/datadog-static-analyzer/pull/408 fixed a bug that was causing file contexts to be generated for all files, regardless of applicability (e.g. it would calculate a Go package alias map for a JavaScript file).
However, there is still a logic bug that causes the FileContext to be regenerated for every execution, which is wasteful, as it doesn't change between different rule executions.
What is your solution?
Update the FileContext only when a call to
set_root_context
detects that the tree changed.Alternatives considered
What the reviewer should know