search: compute TextPatternInfo after results types, not vice versa
Created by: rvantonder
Stacked on https://github.com/sourcegraph/sourcegraph/pull/32596.
This PR is really important. Before, what we did was:
- Compute
pattern info
(the thing that internally tracks the pattern value for atomic queries, whether it's regexp, etc.) - Later realize we need to populate pattern info (mutate!) to also set
PatternMatchesPath
andPatternMatchesContent
based on the result types (type:path
etc.)
But computing result types, previous to this PR, depended on some of the state in pattern info
(basically, the query. circular dependency. gross)
Now, after this:
- Compute result types first from query and break dependency on
pattern info
- Compute
pattern info
, this time without mutating it, in theToTextPatternInfo
function (which is now more primed to go away).
The PR is a bit busy but this code is tested to heck, so review with confidence.
Test plan
Semantics-preserving.