Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Introduce pickTarget and pickPackage command variables #354

Conversation

vogelsgesang
Copy link
Collaborator

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:

  1. The internal helpers queryWorkspaceQuickPickPackages and queryWorkspaceQuickPickTargets were inlined into queryQuickPick{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.
  2. The queryQuickPick{Packages,Targets} take an object with named parameters now.
  3. queryQuickPickPackage now also accepts a query parameter instead of using the queryExpression. Both queryQuickPickPackages and queryQuickPickTargets default 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', ...).

@vogelsgesang
Copy link
Collaborator Author

@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 🙂

@cameron-martin
Copy link
Collaborator

I've been on holiday but I reckon I'll be able to take a look next week. The functionality does look useful though.

@vogelsgesang vogelsgesang force-pushed the avogelsgesang-command-var-quickpick branch 2 times, most recently from d1c9a56 to 7cbb8b5 Compare April 1, 2024 14:38
@vogelsgesang
Copy link
Collaborator Author

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.

@cameron-martin cameron-martin changed the title Introduce pickTarget and pickPackage command variables feat: Introduce pickTarget and pickPackage command variables Apr 2, 2024
Copy link
Collaborator

@cameron-martin cameron-martin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Apart from the two other comments, looks good.

src/assert.ts Show resolved Hide resolved
README.md Outdated Show resolved Hide resolved
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:
1. The internal helpers `queryWorkspaceQuickPickPackages` and
   `queryWorkspaceQuickPickTargets` were inlined into
   `queryQuickPick{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.
2. The `queryQuickPick{Packages,Targets}` take an object with named
   parameters now.
3. `queryQuickPickPackage` now also accepts a `query` parameter instead
   of using the `queryExpression`. Both `queryQuickPickPackages` and
   `queryQuickPickTargets` default 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', ...)`.
@vogelsgesang vogelsgesang force-pushed the avogelsgesang-command-var-quickpick branch from 7cbb8b5 to 1fc4fc4 Compare April 2, 2024 13:39
@cameron-martin cameron-martin merged commit 2ef6d2a into bazelbuild:master Apr 2, 2024
4 checks passed
@vogelsgesang vogelsgesang deleted the avogelsgesang-command-var-quickpick branch April 2, 2024 13:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants