search: compute result types without mutating args
Created by: rvantonder
Stacked on https://github.com/sourcegraph/sourcegraph/pull/32593.
This PR creates a pure function to compute result types from args without mutating args. It's possible now because no state leaks to any part of our app outside of these functions.
The end goal is to compute result types without args at all, and just use the minimal state from query and such, instead of "routing" state through TextPatternInfo. This is part of a bunch of simplifications in job construction for optimizing queries.
Test plan
Semantics-preserving.