tasks: Add ability to query active toolchains for languages (#20667)
Closes #18649 Release Notes: - Python tasks now use active toolchain to run.
This commit is contained in:
parent
04ba75e2e5
commit
89f9a506f9
9 changed files with 170 additions and 103 deletions
|
@ -3,7 +3,7 @@ use async_compression::futures::bufread::GzipDecoder;
|
|||
use async_trait::async_trait;
|
||||
use collections::HashMap;
|
||||
use futures::{io::BufReader, StreamExt};
|
||||
use gpui::{AppContext, AsyncAppContext};
|
||||
use gpui::{AppContext, AsyncAppContext, Task};
|
||||
use http_client::github::AssetKind;
|
||||
use http_client::github::{latest_github_release, GitHubLspBinaryVersion};
|
||||
pub use language::*;
|
||||
|
@ -424,9 +424,10 @@ impl ContextProvider for RustContextProvider {
|
|||
&self,
|
||||
task_variables: &TaskVariables,
|
||||
location: &Location,
|
||||
project_env: Option<&HashMap<String, String>>,
|
||||
project_env: Option<HashMap<String, String>>,
|
||||
_: Arc<dyn LanguageToolchainStore>,
|
||||
cx: &mut gpui::AppContext,
|
||||
) -> Result<TaskVariables> {
|
||||
) -> Task<Result<TaskVariables>> {
|
||||
let local_abs_path = location
|
||||
.buffer
|
||||
.read(cx)
|
||||
|
@ -440,27 +441,27 @@ impl ContextProvider for RustContextProvider {
|
|||
.is_some();
|
||||
|
||||
if is_main_function {
|
||||
if let Some((package_name, bin_name)) = local_abs_path
|
||||
.and_then(|path| package_name_and_bin_name_from_abs_path(path, project_env))
|
||||
{
|
||||
return Ok(TaskVariables::from_iter([
|
||||
if let Some((package_name, bin_name)) = local_abs_path.and_then(|path| {
|
||||
package_name_and_bin_name_from_abs_path(path, project_env.as_ref())
|
||||
}) {
|
||||
return Task::ready(Ok(TaskVariables::from_iter([
|
||||
(RUST_PACKAGE_TASK_VARIABLE.clone(), package_name),
|
||||
(RUST_BIN_NAME_TASK_VARIABLE.clone(), bin_name),
|
||||
]));
|
||||
])));
|
||||
}
|
||||
}
|
||||
|
||||
if let Some(package_name) = local_abs_path
|
||||
.and_then(|local_abs_path| local_abs_path.parent())
|
||||
.and_then(|path| human_readable_package_name(path, project_env))
|
||||
.and_then(|path| human_readable_package_name(path, project_env.as_ref()))
|
||||
{
|
||||
return Ok(TaskVariables::from_iter([(
|
||||
return Task::ready(Ok(TaskVariables::from_iter([(
|
||||
RUST_PACKAGE_TASK_VARIABLE.clone(),
|
||||
package_name,
|
||||
)]));
|
||||
)])));
|
||||
}
|
||||
|
||||
Ok(TaskVariables::default())
|
||||
Task::ready(Ok(TaskVariables::default()))
|
||||
}
|
||||
|
||||
fn associated_tasks(
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue