tasks: Expose captured variables to ContextProvider (#12134)
This PR changes the interface of ContextProvider, allowing it to inspect *all* variables set so far during the process of building `TaskVariables`. This makes it possible to capture e.g. an identifier in tree-sitter query, process it and then export it as a task variable. Notably, the list of variables includes captures prefixed with leading underscore; they are removed after all calls to `build_context`, but it makes it possible to capture something and then conditionally preserve it (and perhaps modify it). Release Notes: - N/A
This commit is contained in:
parent
ba9449692e
commit
58796a8480
15 changed files with 212 additions and 201 deletions
|
@ -153,8 +153,8 @@ mod tests {
|
|||
|
||||
use editor::Editor;
|
||||
use gpui::{Entity, TestAppContext};
|
||||
use language::{BasicContextProvider, Language, LanguageConfig};
|
||||
use project::{FakeFs, Project};
|
||||
use language::{Language, LanguageConfig};
|
||||
use project::{BasicContextProvider, FakeFs, Project};
|
||||
use serde_json::json;
|
||||
use task::{TaskContext, TaskVariables, VariableName};
|
||||
use ui::VisualContext;
|
||||
|
@ -191,7 +191,7 @@ mod tests {
|
|||
}),
|
||||
)
|
||||
.await;
|
||||
|
||||
let project = Project::test(fs, ["/dir".as_ref()], cx).await;
|
||||
let rust_language = Arc::new(
|
||||
Language::new(
|
||||
LanguageConfig::default(),
|
||||
|
@ -203,7 +203,7 @@ mod tests {
|
|||
name: (_) @name) @item"#,
|
||||
)
|
||||
.unwrap()
|
||||
.with_context_provider(Some(Arc::new(BasicContextProvider))),
|
||||
.with_context_provider(Some(Arc::new(BasicContextProvider::new(project.clone())))),
|
||||
);
|
||||
|
||||
let typescript_language = Arc::new(
|
||||
|
@ -221,9 +221,9 @@ mod tests {
|
|||
")" @context)) @item"#,
|
||||
)
|
||||
.unwrap()
|
||||
.with_context_provider(Some(Arc::new(BasicContextProvider))),
|
||||
.with_context_provider(Some(Arc::new(BasicContextProvider::new(project.clone())))),
|
||||
);
|
||||
let project = Project::test(fs, ["/dir".as_ref()], cx).await;
|
||||
|
||||
let worktree_id = project.update(cx, |project, cx| {
|
||||
project.worktrees().next().unwrap().read(cx).id()
|
||||
});
|
||||
|
|
|
@ -540,8 +540,8 @@ mod tests {
|
|||
|
||||
use editor::Editor;
|
||||
use gpui::{TestAppContext, VisualTestContext};
|
||||
use language::{ContextProviderWithTasks, Language, LanguageConfig, LanguageMatcher, Point};
|
||||
use project::{FakeFs, Project};
|
||||
use language::{Language, LanguageConfig, LanguageMatcher, Point};
|
||||
use project::{ContextProviderWithTasks, FakeFs, Project};
|
||||
use serde_json::json;
|
||||
use task::TaskTemplates;
|
||||
use workspace::CloseInactiveTabsAndPanes;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue