1use std::{ops::Range, sync::Arc};
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 full_range: Range<usize>,
15 pub runnable: Runnable,
16 pub extra_captures: HashMap<String, String>,
17}
18/// Language Contexts are used by Zed tasks to extract information about the source file where the tasks are supposed to be scheduled from.
19/// Multiple context providers may be used together: by default, Zed provides a base [`BasicContextProvider`] context that fills all non-custom [`VariableName`] variants.
20///
21/// The context will be used to fill data for the tasks, and filter out the ones that do not have the variables required.
22pub trait ContextProvider: Send + Sync {
23 /// 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.
24 fn build_context(
25 &self,
26 _variables: &TaskVariables,
27 _location: &Location,
28 _project_env: Option<&HashMap<String, String>>,
29 _cx: &mut AppContext,
30 ) -> Result<TaskVariables> {
31 Ok(TaskVariables::default())
32 }
33
34 /// Provides all tasks, associated with the current language.
35 fn associated_tasks(
36 &self,
37 _: Option<Arc<dyn crate::File>>,
38 _cx: &AppContext,
39 ) -> Option<TaskTemplates> {
40 None
41 }
42}