CommonLibrary/LanguageFeature/ProvideDefinition.rs
1//! # ProvideDefinition Effect
2//!
3//! Defines the `ActionEffect` for requesting definition locations from a
4//! language feature provider.
5
6use std::sync::Arc;
7
8use url::Url;
9
10use super::{
11 DTO::{LocationDTO::LocationDTO, PositionDTO::PositionDTO},
12 LanguageFeatureProviderRegistry::LanguageFeatureProviderRegistry,
13};
14use crate::{Effect::ActionEffect::ActionEffect, Error::CommonError::CommonError};
15
16/// Creates an effect that, when executed, will request definition locations.
17pub fn ProvideDefinition(
18 DocumentURI:Url,
19
20 PositionDTO:PositionDTO,
21) -> ActionEffect<Arc<dyn LanguageFeatureProviderRegistry>, CommonError, Option<Vec<LocationDTO>>> {
22 ActionEffect::New(Arc::new(move |Registry:Arc<dyn LanguageFeatureProviderRegistry>| {
23 let DocumentURIClone = DocumentURI.clone();
24
25 Box::pin(async move { Registry.ProvideDefinition(DocumentURIClone, PositionDTO).await })
26 }))
27}