Common/LanguageFeature/
ProvideHover.rs

1//! # ProvideHover Effect
2//!
3//! Defines the `ActionEffect` for requesting hover information at a specific
4//! document position.
5
6use std::sync::Arc;
7
8use url::Url;
9
10use super::{
11	DTO::{HoverResultDTO::HoverResultDTO, PositionDTO::PositionDTO},
12	LanguageFeatureProviderRegistry::LanguageFeatureProviderRegistry,
13};
14use crate::{Effect::ActionEffect::ActionEffect, Error::CommonError::CommonError};
15
16/// Creates an effect that, when executed, will request hover information for a
17/// symbol at a given position in a document.
18///
19/// It uses the `LanguageFeatureProviderRegistry` capability from the
20/// environment to find and invoke the appropriate hover provider.
21///
22/// # Parameters
23/// * `DocumentURI`: The `Url` of the document in which the hover was requested.
24/// * `PositionDTO`: The line and column `PositionDTO` where the hover was
25///   requested.
26///
27/// # Returns
28/// An `ActionEffect` that resolves with an `Option<HoverResultDTO>`, containing
29/// the hover content if a provider was found and returned a result, or `None`
30/// otherwise.
31pub fn ProvideHover(
32	DocumentURI:Url,
33
34	PositionDTO:PositionDTO,
35) -> ActionEffect<Arc<dyn LanguageFeatureProviderRegistry>, CommonError, Option<HoverResultDTO>> {
36	ActionEffect::New(Arc::new(move |Registry:Arc<dyn LanguageFeatureProviderRegistry>| {
37		let URIClone = DocumentURI.clone();
38
39		Box::pin(async move { Registry.ProvideHover(URIClone, PositionDTO).await })
40	}))
41}