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 _cx: &mut AppContext,
29 ) -> Result<TaskVariables> {
30 Ok(TaskVariables::default())
31 }
32
33 /// Provides all tasks, associated with the current language.
34 fn associated_tasks(
35 &self,
36 _: Option<Arc<dyn crate::File>>,
37 _cx: &AppContext,
38 ) -> Option<TaskTemplates> {
39 None
40 }
41}