Mountain/RPC/CocoonService/Provider/
ProvideRenameEdits.rs1use tonic::{Response, Status};
4use url::Url;
5use CommonLibrary::LanguageFeature::{
6 DTO::PositionDTO::PositionDTO,
7 LanguageFeatureProviderRegistry::LanguageFeatureProviderRegistry,
8};
9use ::Vine::Generated::{ProvideRenameEditsRequest, ProvideRenameEditsResponse};
10
11use crate::{RPC::CocoonService::CocoonServiceImpl, dev_log};
12
13pub async fn Fn(
14 Service:&CocoonServiceImpl,
15
16 Request:ProvideRenameEditsRequest,
17) -> Result<Response<ProvideRenameEditsResponse>, Status> {
18 dev_log!(
19 "cocoon",
20 "[CocoonService] Providing rename edits: new_name={}",
21 Request.new_name
22 );
23
24 let URI = Request.uri.as_ref().map(|U| U.value.as_str()).unwrap_or("");
25
26 let DocumentURI = Url::parse(URI).map_err(|E| Status::invalid_argument(format!("Invalid URI: {}", E)))?;
27
28 let Position_ = Request.position.as_ref();
29
30 let PositionDTO_ = PositionDTO {
31 LineNumber:Position_.map(|P| P.line).unwrap_or(0),
32
33 Column:Position_.map(|P| P.character).unwrap_or(0),
34 };
35
36 match Service
37 .environment
38 .ProvideRenameEdits(DocumentURI, PositionDTO_, Request.new_name)
39 .await
40 {
41 Ok(_) => Ok(Response::new(ProvideRenameEditsResponse::default())),
42
43 Err(Error) => Err(Status::internal(format!("Rename edits failed: {}", Error))),
44 }
45}