Skip to repository content54 lines · 2.2 KB · rust
tenant.openagents/omega
No repository description is available.
OpenAgents Git authority 2026-07-28T02:52:37.716Z Public web read
NIP-34 coordinate
30617:7649603503856e5148d571eac2766b288a8ff1e9e35d380337a1d2b0015b4f92:omegaMaintainersHidden in public view
References2 branches · 1 tag
Read-only clone
git clone https://openagents.com/git/tenant.openagents/omega.gitBrowse files
task_context.rs
1use std::{path::PathBuf, sync::Arc};
2
3use crate::{Buffer, LanguageToolchainStore, Location, RunnableResolver};
4
5use anyhow::Result;
6use collections::HashMap;
7use fs::Fs;
8use gpui::{App, Entity, Task};
9use lsp::LanguageServerName;
10use task::{TaskTemplates, TaskVariables};
11
12/// Language Contexts are used by Zed tasks to extract information about the source file where the tasks are supposed to be scheduled from.
13/// Multiple context providers may be used together: by default, Zed provides a base [`BasicContextProvider`] context that fills all non-custom [`VariableName`] variants.
14///
15/// The context will be used to fill data for the tasks, and filter out the ones that do not have the variables required.
16pub trait ContextProvider: Send + Sync {
17 /// 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.
18 fn build_context(
19 &self,
20 _variables: &TaskVariables,
21 _location: ContextLocation<'_>,
22 _project_env: Option<HashMap<String, String>>,
23 _toolchains: Arc<dyn LanguageToolchainStore>,
24 _cx: &mut App,
25 ) -> Task<Result<TaskVariables>> {
26 let _ = _location;
27 Task::ready(Ok(TaskVariables::default()))
28 }
29
30 /// Provides all tasks, associated with the current language.
31 fn associated_tasks(&self, _: Option<Entity<Buffer>>, _: &App) -> Task<Option<TaskTemplates>> {
32 Task::ready(None)
33 }
34
35 /// A language server name, that can return tasks using LSP (ext) for this language.
36 fn lsp_task_source(&self) -> Option<LanguageServerName> {
37 None
38 }
39
40 /// A resolver for runnable queries that group captures with `@run_item`.
41 /// For each group, the resolver picks which `@run` range and extra captures
42 /// to surface. Without a resolver, grouped matches emit no runnables.
43 fn runnable_resolver(&self) -> Option<Arc<dyn RunnableResolver>> {
44 None
45 }
46}
47
48/// Metadata about the place in the project we gather the context for.
49pub struct ContextLocation<'a> {
50 pub fs: Option<Arc<dyn Fs>>,
51 pub worktree_root: Option<PathBuf>,
52 pub file_location: &'a Location,
53}
54