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