tools/fix: extract and extend explicitopen fix
Extract the explicitopen fix logic into fixopen.go
and extend it with several improvements:
- Hoist embedded close() to wrapper level: under old
semantics, embedding close() opened up the embedding.
Under explicitopen it no longer does, so the fix now
removes close() from the embedding and applies it as
a wrapper around the containing struct.
- Wrapper selection: close-only uses close(), close
with other refs uses close(__reclose()), close with
defs uses __closeAll (which subsumes close).
- Single-embed simplification: structs with a single
embedding are simplified to the expression directly
without wrapping.
- Add TODO comment for top-level definition embeddings,
which are likely intended as schema constraints.
- Split tests into explicitopen.txtar (basic cases),
explicitopen_expr.txtar (close/conjunction/disjunction
expressions), and explicitopen_shorthands.txtar
(single-embed shortcuts and comprehension TODOs).
Signed-off-by: Marcel van Lohuizen <mpvl@gmail.com>
Change-Id: If2d6b35c07dffb24b7ada346653ff2929b07fc08
Reviewed-on: https://cue.gerrithub.io/c/cue-lang/cue/+/1236310
TryBot-Result: CUEcueckoo <cueckoo@cuelang.org>
Reviewed-by: Daniel Martí <mvdan@mvdan.cc>
Unity-Result: CUE porcuepine <cue.porcuepine@gmail.com>