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