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 uri:String,
22 position:Value,
23 context:Value,
24) -> Result<Value, String> {
25 dev_log!(
26 "commands",
27 "[Language Feature] Providing code actions for: {} at {:?}",
28 uri,
29 position
30 );
31
32 validate_language_feature_request("code_actions", &uri, &position)?;
33
34 let document_uri = Url::parse(&uri).map_err(|error| error.to_string())?;
35
36 invoke_provider(application_handle, |provider| {
38 async move {
39 let result = provider
40 .ProvideCodeActions(document_uri, position.clone(), context.clone())
41 .await?;
42 Ok(serde_json::to_value(result)?)
43 }
44 })
45 .await
46}