Common/WorkSpace/
GetWorkSpaceFolderInfo.rs

1//! # GetWorkSpaceFolderInfo Effect
2//!
3//! Defines the `ActionEffect` for retrieving information about the specific
4//! workspace folder that contains a given URI.
5
6use std::sync::Arc;
7
8use url::Url;
9
10use super::WorkSpaceProvider::WorkSpaceProvider;
11use crate::{Effect::ActionEffect::ActionEffect, Error::CommonError::CommonError};
12
13/// Creates an effect that, when executed, will find the workspace folder that
14/// contains the given URI.
15///
16/// It uses the `WorkSpaceProvider` capability from the environment. This is
17/// useful for determining which folder-level settings apply to a specific
18/// file.
19///
20/// # Parameters
21/// * `URIToMatch`: The `Url` of the resource (e.g., a file) for which to find
22///   the containing workspace folder.
23///
24/// # Returns
25/// An `ActionEffect` that resolves with an `Option` containing a tuple of the
26/// folder's `Url`, name, and index, or `None` if the URI is not within any
27/// open workspace folder.
28pub fn GetWorkSpaceFolderInfo(
29	URIToMatch:Url,
30) -> ActionEffect<Arc<dyn WorkSpaceProvider>, CommonError, Option<(Url, String, usize)>> {
31	ActionEffect::New(Arc::new(move |Provider:Arc<dyn WorkSpaceProvider>| {
32		let URIClone = URIToMatch.clone();
33
34		Box::pin(async move { Provider.GetWorkSpaceFolderInfo(URIClone).await })
35	}))
36}