task: Allow obtaining custom task variables from tree-sitter queries (#11624)

From now on, only top-level captures are treated as runnable tags and
the rest is appended to task context as custom environmental variables
(unless the name is prefixed with _, in which case the capture is
ignored). This is most likely gonna help with Pest-like test runners.



Release Notes:

- N/A

---------

Co-authored-by: Remco <djsmits12@gmail.com>
This commit is contained in:
Piotr Osiewicz 2024-05-09 23:38:18 +02:00 committed by GitHub
parent 95e246ac1c
commit bff1d8b142
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
7 changed files with 126 additions and 67 deletions

View file

@ -1,12 +1,19 @@
use std::path::Path;
use std::{ops::Range, path::Path};
use crate::Location;
use crate::{Location, Runnable};
use anyhow::Result;
use collections::HashMap;
use gpui::AppContext;
use task::{TaskTemplates, TaskVariables, VariableName};
use text::{Point, ToPoint};
use text::{BufferId, Point, ToPoint};
pub struct RunnableRange {
pub buffer_id: BufferId,
pub run_range: Range<usize>,
pub runnable: Runnable,
pub extra_captures: HashMap<String, String>,
}
/// Language Contexts are used by Zed tasks to extract information about the source file where the tasks are supposed to be scheduled from.
/// Multiple context providers may be used together: by default, Zed provides a base [`BasicContextProvider`] context that fills all non-custom [`VariableName`] variants.
///