Mountain/Command/LanguageFeature/
references.rs

1//! # LanguageFeature - References
2//!
3//! Finds all references to a symbol
4
5use CommonLibrary::{
6	Error::CommonError::CommonError,
7	LanguageFeature::{
8		DTO::PositionDTO::PositionDTO,
9		LanguageFeatureProviderRegistry::LanguageFeatureProviderRegistry,
10	},
11};
12use log::debug;
13use serde_json::Value;
14use tauri::{AppHandle, Wry};
15use url::Url;
16
17use super::{invoke_provider::invoke_provider, validation::validate_language_feature_request};
18
19/// Implementation of references command - called by the command wrapper in the
20/// parent module.
21pub(super) async fn provide_references_impl(
22	application_handle:AppHandle<Wry>,
23	uri:String,
24	position:Value,
25	context:Value,
26) -> Result<Value, String> {
27	debug!("[Language Feature] Providing references for: {} at {:?}", uri, position);
28
29	validate_language_feature_request("references", &uri, &position)?;
30
31	let document_uri = Url::parse(&uri).map_err(|error| error.to_string())?;
32
33	let position_dto:PositionDTO =
34		serde_json::from_value(position.clone()).map_err(|error| format!("Failed to parse position: {}", error))?;
35
36	// Context is passed as raw Value per trait signature
37	invoke_provider(application_handle, |provider| {
38		async move {
39			let result = provider.ProvideReferences(document_uri, position_dto, context.clone()).await?;
40			Ok(serde_json::to_value(result)?)
41		}
42	})
43	.await
44}