cue/ast/astutil,tools/fix: add cross-file shadowing detection for predeclared identifiers
When Sanitize processes a single file, it cannot know if a predeclared
name like "self" is shadowed by a top-level field in another file of
the same package. This causes issues when fix generates "let X = self"
for value alias conversion - if another file has "self: 42", the "self"
reference should be renamed to "__self".
Add SanitizeFiles to sanitize all files of a package at once, detecting
cross-file shadowing of predeclared identifiers. Pull sanitization out
of the internal file() function so callers choose the appropriate
entrypoint: File() uses single-file Sanitize, Instances() uses
cross-file SanitizeFiles.
Change-Id: Ie7028fa3d05dbbcde405657404c4d82926169758
Signed-off-by: Marcel van Lohuizen <mpvl@gmail.com>
Reviewed-on: https://cue.gerrithub.io/c/cue-lang/cue/+/1231454
TryBot-Result: CUEcueckoo <cueckoo@cuelang.org>
Reviewed-by: Daniel Martí <mvdan@mvdan.cc>
Unity-Result: CUE porcuepine <cue.porcuepine@gmail.com>