bazelbuild / vscode-bazel

Bazel support for Visual Studio Code
https://marketplace.visualstudio.com/items?itemName=BazelBuild.vscode-bazel
Apache License 2.0
232 stars 76 forks source link

Support `bazel` tasks from `tasks.json` #346

Closed vogelsgesang closed 4 months ago

vogelsgesang commented 4 months ago

User-facing changes

This commit fixes two user-facing bugs:

In both cases, the user was presented with the error message

There is no task provider registered for tasks of type "bazel"

This commit fixes the issue, such that rerunning tasks from the history and configuring tasks through tasks.json now works properly.

Furthermore, the taskDefinition inside the package.json was improved:

Code changes

Fixing the issue mainly required registering a TaskProvider for bazel tasks. The TaskProvider currently does not auto-detect the available tasks, but only implements resolveTask.

The notifications in onTaskProcessEnd had to be refactored: So far, the BazelTaskInfo was attached right during task creation. However, this didn't work for the new resolveTask. resolveTask apparently isn't allowed to change a task's definition. To make notifications work, the BazelTaskInfo is now attached in the onTaskStart callback.

Many of the fields of the BazelTaskInfo were unused. This commit removes commandOptions, processId, exitCode all of which were stored but never read. Doing so, it turned out that the onTaskProcessStart was no longer necessary.

Lastly, the callbacks used for task notifications were moved from extension.ts to bazel_task_info.ts and activation of all task-related functionality was centralized in the activateTaskProvider function

BEGIN_COMMIT_OVERRIDE feat: Support bazel tasks from tasks.json (#346) END_COMMIT_OVERRIDE