Add activation events for providing/resolving tasks (TaskProvider extension API) #102013
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR is related to issue #99797 and its consequent PR #99957.
This PR makes the following changes:
onTaskProvide:taskType
activation event whenever VS Code queries TaskProviders for tasksonTaskResolve:taskType
activation event whenever VS Code needs to resolve a TaskProvider's taskITaskService.getPossibleTaskTypes(): Promise<string[]>
An async version of
.taskTypes()
which also checks all task definitions defined in package.json of (inactive) extensionsgetPossibleTaskTypes()
Task types for inactive extensions (that specify
taskDefinitions
in their package.json) also get listed nowRelated activation events and triggers:
onTaskProvide:taskType
triggered by selectingShow All Tasks
in theTasks: Run Task
's TaskQuickPickThis is fired for every task type registered in TaskDefinitionRegistry (except for
shell
andprocess
)onTaskProvide:taskType
triggered by selecting an extension top level entry in theTasks: Run Task
's TaskQuickPickThis is fired for just the selected task type
onTaskResolve:taskType
triggered by trying to resolve a task, if it has a type definedI recently added a TaskProvider for my extension, and noticed that in certain cases, it couldn't be resolved. After taking a look, it seemed to be caused by the extension not being activated yet, hence not having registered the TaskProvider. With this PR, extensions can now add a proper activation event to deal with providing/resolving their tasks.
I noticed while working on this that #99957 made it that extensions can activate on
onCommand:...runTask
or even*
instead. This PR provides more specific activation events, instead of having to rely on the aforementioned events.Another possibility that I have thought about but decided against:
Since we can use
taskDefinitions
(TaskDefinitionRegistry) to figure out which extensions will (should) provide TaskProviders for which types, we can automatically start an extension when we need to provide/resolve using such a provider. ThetaskDefinitions
would basically also register the extension for the appropriateonTaskProvide
/onTaskResolve
activation events.The same could be done for commands, since similar to
taskDefinitions
we can accesscommands
too, including from inactive extensions. Since this auto-registration isn't actually the case for commands, I assume it shouldn't be the case for task definitions either.