cue/internal: Make ToFile optionally preserve StructLits
internal.ToFile when passed a StructLit, would previously take its
elements, and return them in a File.
This can be problematic, because File.Pos and File.End only inspect the
Pos and End of its first and last elements. This means that if the
StructLit had explicit braces but no elements, it would go from having a
known range in its source, to having no range at all. This breaks
completions for embedded json files.
Change-Id: Ibe505be80207def55b366eca8a213a87f3f4270b
Signed-off-by: Matthew Sackman <matthew@cue.works>
Reviewed-on: https://cue.gerrithub.io/c/cue-lang/cue/+/1231227
Reviewed-by: Daniel Martí <mvdan@mvdan.cc>
TryBot-Result: CUEcueckoo <cueckoo@cuelang.org>