vscode-bazel
vscode-bazel copied to clipboard
Introduce `pickTarget` and `pickPackage` command variables
This commit introduces the bazel.pickTarget and bazel.pickPackage command variables. Those commands can be used from tasks.json and launch.json to prompt the user to select a Bazel target or package. The available choices are determined by a user-specified Bazel query.
The implementation reuses the existing quick-pick functionality from bazel_quickpick.ts. The wrapQuickPick function parses the arguments passed from the task.json and then forwards to the existing quickpicks.
Those utility functions were restructured as part of this commit:
- The internal helpers
queryWorkspaceQuickPickPackagesandqueryWorkspaceQuickPickTargetswere inlined intoqueryQuickPick{Packages,Targets}as the internal helper functions got in the way of other changes, but didn't deduplicate any code as they only had one caller. - The
queryQuickPick{Packages,Targets}take an object with named parameters now. queryQuickPickPackagenow also accepts aqueryparameter instead of using thequeryExpression. BothqueryQuickPickPackagesandqueryQuickPickTargetsdefault to the query//...if no query string is provided by the caller.
Point (3) also is a user-facing change. Commands like "Build package" and "Test package" now use //... instead of the configured queryExpression. This is in sync with other commands like "Test target" which uses the hardcoded query kind('.*_test rule', ...).
@cameron-martin @jfirebaugh do you have time to review this? In case you currently don't have time to review in detail, I would appreciate high-level feedback whether you consider this functionality as valuable in general 🙂
I've been on holiday but I reckon I'll be able to take a look next week. The functionality does look useful though.
By the way: I think long-term it would make sense to also add support for cquery and parameters such as --experimental_explicit_aspects, --universe_scope, --infer_universe_scope, --noimplicit_deps. But I will leave that for a different commit.