buildozer: add print_all_lists command for '+' list expressions (#1525)

Buildozer's mutating list commands (`add`, `remove`, `replace`,
`substitute`) and `print_comment <attr> <value>` traverse `+`
concatenation expressions via `edit.AllLists`, operating on all
top-level `*build.ListExpr` operands in expressions such as `["a", "b"]
+ select(...)` or `DEPS_VAR + ["a"]`.

However, `print <attr>` relies on `Rule.AttrStrings` (`build.Strings`),
which only matches a single `*build.ListExpr` and falls back to
returning the raw formatted expression string whenever `+` is used.
Unconditionally changing `print <attr>` would break existing callers
that distinguish pure list literals from expressions containing
variables or `select(...)`.

Add `edit.AllListsStrings(e build.Expr) []string` to extract string
literals across all top-level `*build.ListExpr` operands returned by
`edit.AllLists(e)`, and expose a `print_all_lists <attribute(s)>`
command in Buildozer that prints the combined string elements from all
top-level list literals as a list (e.g. `["a"] + select(...)` prints
`[a]`, and `VAR + ["a"] + ["b"]` prints `[a b]`).
5 files changed
tree: 5be6fa7f3c84f97fd01f8c7dc0ec63843895ead6
  1. .bazelci/
  2. .github/
  3. api_proto/
  4. build/
  5. build_proto/
  6. buildifier/
  7. buildozer/
  8. bzlenv/
  9. config/
  10. convertast/
  11. deps_proto/
  12. differ/
  13. edit/
  14. extra_actions_base_proto/
  15. file/
  16. generatetables/
  17. labels/
  18. lang/
  19. release/
  20. tables/
  21. testutils/
  22. unused_deps/
  23. warn/
  24. wspace/
  25. .bazelrc
  26. .bazelversion
  27. .gitignore
  28. .mailmap
  29. .pre-commit-config.yaml
  30. AGENTS.md
  31. BUILD.bazel
  32. CODEOWNERS
  33. CONTRIBUTING.md
  34. CONTRIBUTORS
  35. go.mod
  36. go.sum
  37. launcher.js
  38. LICENSE
  39. MODULE.bazel
  40. README.md
  41. status.py
  42. update_generated.sh
  43. WARNINGS.md
  44. WORKSPACE
  45. WORKSPACE.bzlmod
README.md

Buildtools for bazel

This repository contains developer tools for working with Google's bazel buildtool.

Build status

Setup

See instructions in each tool's directory.