Mountain/Command/LanguageFeature/
CodeActions.rs1#[allow(unused_imports)]
6use CommonLibrary::{
7 Error::CommonError::CommonError,
8 LanguageFeature::LanguageFeatureProviderRegistry::LanguageFeatureProviderRegistry,
9};
10use serde_json::Value;
11use tauri::{AppHandle, Wry};
12use url::Url;
13
14use super::{InvokeProvider::invoke_provider, Validation::validate_language_feature_request};
15use crate::dev_log;
16
17pub(super) async fn provide_code_actions_impl(
20 application_handle:AppHandle<Wry>,
21
22 uri:String,
23
24 position:Value,
25
26 context:Value,
27) -> Result<Value, String> {
28 dev_log!(
29 "commands",
30 "[Language Feature] Providing code actions for: {} at {:?}",
31 uri,
32 position
33 );
34
35 validate_language_feature_request("code_actions", &uri, &position)?;
36
37 let document_uri = Url::parse(&uri).map_err(|error| error.to_string())?;
38
39 invoke_provider(application_handle, |provider| {
41 async move {
42 let result = provider
43 .ProvideCodeActions(document_uri, position.clone(), context.clone())
44 .await?;
45 Ok(serde_json::to_value(result)?)
46 }
47 })
48 .await
49}