1use std::ops::Range;
2
3use crate::{Location, Runnable};
4
5use anyhow::Result;
6use collections::HashMap;
7use gpui::AppContext;
8use task::{TaskTemplates, TaskVariables};
9use text::BufferId;
10
11pub struct RunnableRange {
12 pub buffer_id: BufferId,
13 pub run_range: Range<usize>,
14 pub runnable: Runnable,
15 pub extra_captures: HashMap<String, String>,
16}
17/// Language Contexts are used by Zed tasks to extract information about the source file where the tasks are supposed to be scheduled from.
18/// Multiple context providers may be used together: by default, Zed provides a base [`BasicContextProvider`] context that fills all non-custom [`VariableName`] variants.
19///
20/// The context will be used to fill data for the tasks, and filter out the ones that do not have the variables required.
21pub trait ContextProvider: Send + Sync {
22 /// Builds a specific context to be placed on top of the basic one (replacing all conflicting entries) and to be used for task resolving later.
23 fn build_context(
24 &self,
25 _variables: &TaskVariables,
26 _location: &Location,
27 _cx: &mut AppContext,
28 ) -> Result<TaskVariables> {
29 Ok(TaskVariables::default())
30 }
31
32 /// Provides all tasks, associated with the current language.
33 fn associated_tasks(&self) -> Option<TaskTemplates> {
34 None
35 }
36}