1#![allow(non_snake_case, unused_variables, dead_code, unused_imports)]
2
3pub mod Auth;
12
13pub mod GenericNotification;
14
15pub mod GenericRequest;
16
17pub mod Command;
18
19pub mod Debug;
20
21pub mod Extension;
22
23pub mod FileSystem;
24
25pub mod Initialization;
26
27pub mod Output;
28
29pub mod Provider;
30
31pub mod Save;
32
33pub mod SCM;
34
35pub mod Secret;
36
37pub mod Task;
38
39pub mod Terminal;
40
41pub mod TreeView;
42
43pub mod Window;
44
45pub mod Workspace;
46
47#[allow(unused_imports)]
48use std::{
49 collections::HashMap,
50 sync::Arc,
51 time::{SystemTime, UNIX_EPOCH},
52};
53
54use async_trait::async_trait;
55use CommonLibrary::{
56 Command::CommandExecutor::CommandExecutor,
57 LanguageFeature::{
58 DTO::{PositionDTO::PositionDTO, ProviderType::ProviderType},
59 LanguageFeatureProviderRegistry::LanguageFeatureProviderRegistry,
60 },
61 Secret::SecretProvider::SecretProvider,
62 Terminal::TerminalProvider::TerminalProvider,
63 UserInterface::{
64 DTO::{
65 InputBoxOptionsDTO::InputBoxOptionsDTO,
66 QuickPickItemDTO::QuickPickItemDTO,
67 QuickPickOptionsDTO::QuickPickOptionsDTO,
68 },
69 UserInterfaceProvider::UserInterfaceProvider,
70 },
71};
72use serde_json::json;
73use tokio::sync::RwLock;
74use tonic::{Request, Response, Status};
75use url::Url;
76
77use crate::{
78 ApplicationState::DTO::{
79 ProviderRegistrationDTO::ProviderRegistrationDTO,
80 WorkspaceFolderStateDTO::WorkspaceFolderStateDTO,
81 },
82 Environment::MountainEnvironment::MountainEnvironment,
83};
84use crate::dev_log;
86use crate::Vine::Generated::{
87 AppendOutputRequest,
90 ApplyEditRequest,
91 ApplyEditResponse,
92 Argument,
93 CancelOperationRequest,
94
95 ClearOutputRequest,
96 CloseTerminalRequest,
97 CodeAction,
98
99 CompletionItem,
100 CopyFileRequest,
101 CreateDirectoryRequest,
102 CreateOutputChannelRequest,
103 CreateOutputChannelResponse,
104 CreateStatusBarItemRequest,
105 CreateStatusBarItemResponse,
106 CreateWebviewPanelRequest,
107 CreateWebviewPanelResponse,
108 DebugConfiguration,
109 DeleteFileRequest,
110 DeleteSecretRequest,
111 DisposeOutputRequest,
112 DisposeWebviewPanelRequest,
113 Empty,
115 ExecuteCommandRequest,
116 ExecuteCommandResponse,
117 ExecuteTaskRequest,
118 ExecuteTaskResponse,
119 ExtensionInfo,
120 FindFilesRequest,
122 FindFilesResponse,
123 FindTextInFilesRequest,
124 FindTextInFilesResponse,
125 GenericNotification as GenericNotificationMsg,
126 GenericRequest as GenericRequestMsg,
128 GenericResponse,
129 GetAllExtensionsResponse,
130 GetAuthenticationSessionRequest,
131 GetAuthenticationSessionResponse,
132 GetConfigurationRequest,
133 GetConfigurationResponse,
134 GetExtensionRequest,
135 GetExtensionResponse,
136 GetSecretRequest,
138 GetSecretResponse,
139 GetTreeChildrenRequest,
140 GetTreeChildrenResponse,
141 GitExecRequest,
142 GitExecResponse,
143
144 InitExtensionHostRequest,
146
147 Location,
148 OnDidReceiveMessageRequest,
149
150 OpenDocumentRequest,
151 OpenDocumentResponse,
152 OpenExternalRequest,
153 OpenTerminalRequest,
155 ParticipateInSaveRequest,
157 ParticipateInSaveResponse,
158 Position,
159 PostWebviewMessageRequest,
160 ProvideCallHierarchyRequest,
161 ProvideCallHierarchyResponse,
162 ProvideCodeActionsRequest,
163 ProvideCodeActionsResponse,
164 ProvideCodeLensesRequest,
165 ProvideCodeLensesResponse,
166 ProvideCompletionItemsRequest,
167 ProvideCompletionItemsResponse,
168 ProvideDefinitionRequest,
169 ProvideDefinitionResponse,
170 ProvideDocumentFormattingRequest,
171 ProvideDocumentFormattingResponse,
172 ProvideDocumentHighlightsRequest,
173 ProvideDocumentHighlightsResponse,
174 ProvideDocumentRangeFormattingRequest,
175 ProvideDocumentRangeFormattingResponse,
176 ProvideDocumentSymbolsRequest,
177 ProvideDocumentSymbolsResponse,
178 ProvideFoldingRangesRequest,
179 ProvideFoldingRangesResponse,
180 ProvideHoverRequest,
181 ProvideHoverResponse,
182 ProvideInlayHintsRequest,
183 ProvideInlayHintsResponse,
184 ProvideLinkedEditingRangesRequest,
185 ProvideLinkedEditingRangesResponse,
186 ProvideOnTypeFormattingRequest,
187 ProvideOnTypeFormattingResponse,
188 ProvideReferencesRequest,
189 ProvideReferencesResponse,
190 ProvideRenameEditsRequest,
191 ProvideRenameEditsResponse,
192 ProvideSelectionRangesRequest,
193 ProvideSelectionRangesResponse,
194 ProvideSemanticTokensRequest,
195 ProvideSemanticTokensResponse,
196 ProvideSignatureHelpRequest,
197 ProvideSignatureHelpResponse,
198 ProvideTypeHierarchyRequest,
199 ProvideTypeHierarchyResponse,
200 ProvideWorkspaceSymbolsRequest,
201 ProvideWorkspaceSymbolsResponse,
202 Range,
203 ReadFileRequest,
205 ReadFileResponse,
206 ReaddirRequest,
207 ReaddirResponse,
208 RegisterAuthenticationProviderRequest,
209 RegisterCommandRequest,
211 RegisterDebugAdapterRequest,
213 RegisterOnTypeFormattingProviderRequest,
214 RegisterProviderRequest,
216 RegisterScmProviderRequest,
218 RegisterSemanticTokensProviderRequest,
219 RegisterSignatureHelpProviderRequest,
220 RegisterTaskProviderRequest,
221 RegisterTreeViewProviderRequest,
223 RenameFileRequest,
224 ReportProgressRequest,
225 ResizeTerminalRequest,
226 RpcError,
227 SaveAllRequest,
228 SaveAllResponse,
229 SetStatusBarTextRequest,
230 SetWebviewHtmlRequest,
231 ShowInputBoxRequest,
232 ShowInputBoxResponse,
233 ShowMessageRequest,
234 ShowMessageResponse,
235 ShowOutputRequest,
236 ShowProgressRequest,
237 ShowProgressResponse,
238 ShowQuickPickRequest,
239 ShowQuickPickResponse,
240 ShowTextDocumentRequest,
242 ShowTextDocumentResponse,
243 SourceControlResourceState,
244 StartDebuggingRequest,
245 StartDebuggingResponse,
246
247 StatRequest,
248 StatResponse,
249 StopDebuggingRequest,
250 StoreSecretRequest,
251 TerminalClosedNotification,
252 TerminalDataNotification,
253
254 TerminalInputRequest,
255 TerminalOpenedNotification,
256 TerminalProcessIdNotification,
257 TerminateTaskRequest,
258 TextDocumentSaveReason,
259 TextEdit,
260 TextEditForSave,
261
262 TextMatch,
263 TreeItem,
264
265 UnregisterCommandRequest,
266
267 UpdateConfigurationRequest,
268 UpdateScmGroupRequest,
269 UpdateWorkspaceFoldersRequest,
270
271 Uri,
272 ViewColumn,
273
274 WatchFileRequest,
275
276 WorkspaceFolder,
277 WriteFileRequest,
278
279 cocoon_service_server::CocoonService,
280 on_did_receive_message_request,
281 post_webview_message_request,
282};
283
284#[derive(Clone)]
289pub struct CocoonServiceImpl {
290 environment:Arc<MountainEnvironment>,
292
293 ActiveOperations:Arc<RwLock<HashMap<u64, tokio_util::sync::CancellationToken>>>,
296}
297
298impl CocoonServiceImpl {
299 pub fn new(environment:Arc<MountainEnvironment>) -> Self {
307 dev_log!("cocoon", "[CocoonService] New instance created");
308
309 Self { environment, ActiveOperations:Arc::new(RwLock::new(HashMap::new())) }
310 }
311
312 pub async fn RegisterOperation(&self, request_id:u64) -> tokio_util::sync::CancellationToken {
320 let token = tokio_util::sync::CancellationToken::new();
321
322 self.ActiveOperations.write().await.insert(request_id, token.clone());
323
324 dev_log!("cocoon", "[CocoonService] Registered operation {} for cancellation", request_id);
325
326 token
327 }
328
329 pub async fn UnregisterOperation(&self, request_id:u64) {
334 self.ActiveOperations.write().await.remove(&request_id);
335
336 dev_log!("cocoon", "[CocoonService] Unregistered operation {}", request_id);
337 }
338
339 fn RegisterProvider(&self, handle:u32, provider_type:ProviderType, language_selector:&str, extension_id:&str) {
350 let dto = ProviderRegistrationDTO {
355 Handle:handle,
356
357 ProviderType:provider_type,
358
359 Selector:json!([{ "language": language_selector }]),
360
361 SideCarIdentifier:"cocoon-main".to_string(),
362
363 ExtensionIdentifier:json!(extension_id),
364
365 Options:None,
366 };
367
368 self.environment
369 .ApplicationState
370 .Extension
371 .ProviderRegistration
372 .RegisterProvider(handle, dto);
373
374 dev_log!(
375 "cocoon",
376 "[CocoonService] Provider {:?} registered: handle={}, language={}",
377 provider_type,
378 handle,
379 language_selector
380 );
381 }
382
383 fn UriToPath(uri_opt:Option<&Uri>) -> Option<std::path::PathBuf> {
388 let value = uri_opt?.value.as_str();
389
390 if value.is_empty() {
391 return None;
392 }
393
394 let path_str = if let Some(Stripped) = value.strip_prefix("file://") {
396 Stripped
397 } else if value.starts_with('/') || (value.len() > 1 && value.as_bytes()[1] == b':') {
398 value
400 } else {
401 value
403 };
404
405 Some(std::path::PathBuf::from(path_str))
406 }
407}
408
409#[async_trait]
410
411impl CocoonService for CocoonServiceImpl {
412 type OpenChannelFromMountainStream = std::pin::Pin<
418 Box<
419 dyn tonic::codegen::tokio_stream::Stream<Item = Result<crate::Vine::Generated::Envelope, tonic::Status>>
420 + Send
421 + 'static,
422 >,
423 >;
424
425 async fn open_channel_from_mountain(
426 &self,
427
428 _request:tonic::Request<tonic::Streaming<crate::Vine::Generated::Envelope>>,
429 ) -> Result<tonic::Response<Self::OpenChannelFromMountainStream>, tonic::Status> {
430 Err(tonic::Status::unimplemented(
431 "OpenChannelFromMountain: streaming multiplexer not yet wired (Patch 14); use unary endpoints",
432 ))
433 }
434
435 async fn process_mountain_request(
444 &self,
445
446 request:Request<GenericRequestMsg>,
447 ) -> Result<Response<GenericResponse>, Status> {
448 let Req = request.into_inner();
449
450 let RequestId = Req.request_identifier;
451
452 dev_log!(
453 "cocoon",
454 "[CocoonService] generic request: method={} id={}",
455 Req.method,
456 RequestId
457 );
458
459 fn OkResponse(RequestId:u64, Value:&impl serde::Serialize) -> Response<GenericResponse> {
461 let Bytes = serde_json::to_vec(Value).unwrap_or_default();
462
463 Response::new(GenericResponse { request_identifier:RequestId, result:Bytes, error:None })
464 }
465
466 fn ErrResponse(RequestId:u64, Code:i32, Message:String) -> Response<GenericResponse> {
468 Response::new(GenericResponse {
469 request_identifier:RequestId,
470 result:Vec::new(),
471 error:Some(RpcError { code:Code, message:Message, data:Vec::new() }),
472 })
473 }
474
475 let Params:serde_json::Value = if Req.parameter.is_empty() {
477 serde_json::Value::Null
478 } else {
479 serde_json::from_slice(&Req.parameter).unwrap_or(serde_json::Value::Null)
480 };
481
482 match Req.method.as_str() {
483 "fs.readFile" | "file:read" => {
485 let Path = Params
486 .as_str()
487 .or_else(|| Params.get("path").and_then(|V| V.as_str()))
488 .unwrap_or("");
489
490 match tokio::fs::read(Path).await {
491 Ok(Content) => Ok(OkResponse(RequestId, &Content)),
492
493 Err(Error) => Ok(ErrResponse(RequestId, -32000, format!("fs.readFile: {}", Error))),
494 }
495 },
496
497 "fs.writeFile" | "file:write" => {
498 let Path = Params.get("path").and_then(|V| V.as_str()).unwrap_or("");
499
500 let Content:Vec<u8> = Params
501 .get("content")
502 .and_then(|V| V.as_array())
503 .map(|A| A.iter().filter_map(|B| B.as_u64().map(|N| N as u8)).collect())
504 .unwrap_or_default();
505
506 match tokio::fs::write(Path, &Content).await {
507 Ok(()) => Ok(OkResponse(RequestId, &serde_json::Value::Null)),
508
509 Err(Error) => Ok(ErrResponse(RequestId, -32000, format!("fs.writeFile: {}", Error))),
510 }
511 },
512
513 "fs.stat" | "file:stat" => {
514 let Path = Params
515 .as_str()
516 .or_else(|| Params.get("path").and_then(|V| V.as_str()))
517 .unwrap_or("");
518
519 match tokio::fs::metadata(Path).await {
520 Ok(Meta) => {
521 let Mtime = Meta
522 .modified()
523 .ok()
524 .and_then(|T| T.duration_since(UNIX_EPOCH).ok())
525 .map(|D| D.as_millis() as u64)
526 .unwrap_or(0);
527
528 Ok(OkResponse(
529 RequestId,
530 &json!({
531 "type": if Meta.is_dir() { 2 } else { 1 },
532 "is_file": Meta.is_file(),
533 "is_directory": Meta.is_dir(),
534 "size": Meta.len(),
535 "mtime": Mtime,
536 }),
537 ))
538 },
539
540 Err(Error) => Ok(ErrResponse(RequestId, -32000, format!("fs.stat: {}", Error))),
541 }
542 },
543
544 "fs.listDir" | "fs.readdir" | "file:readdir" => {
545 let Path = Params
546 .as_str()
547 .or_else(|| Params.get("path").and_then(|V| V.as_str()))
548 .unwrap_or("");
549
550 match tokio::fs::read_dir(Path).await {
551 Ok(mut Entries) => {
552 let mut Items:Vec<serde_json::Value> = Vec::new();
554
555 while let Ok(Some(Entry)) = Entries.next_entry().await {
556 if let Some(Name) = Entry.file_name().to_str() {
557 let IsDir = Entry.file_type().await.map(|T| T.is_dir()).unwrap_or(false);
558
559 Items.push(json!({ "name": Name, "type": if IsDir { 2u32 } else { 1u32 } }));
560 }
561 }
562
563 Ok(OkResponse(RequestId, &Items))
564 },
565
566 Err(Error) => Ok(ErrResponse(RequestId, -32000, format!("fs.listDir: {}", Error))),
567 }
568 },
569
570 "fs.createDir" | "file:mkdir" => {
571 let Path = Params
572 .as_str()
573 .or_else(|| Params.get("path").and_then(|V| V.as_str()))
574 .unwrap_or("");
575
576 match tokio::fs::create_dir_all(Path).await {
577 Ok(()) => Ok(OkResponse(RequestId, &serde_json::Value::Null)),
578
579 Err(Error) => Ok(ErrResponse(RequestId, -32000, format!("fs.createDir: {}", Error))),
580 }
581 },
582
583 "fs.delete" | "file:delete" => {
584 let Path = Params
585 .as_str()
586 .or_else(|| Params.get("path").and_then(|V| V.as_str()))
587 .unwrap_or("");
588
589 let Result = if std::path::Path::new(Path).is_dir() {
590 tokio::fs::remove_dir_all(Path).await
591 } else {
592 tokio::fs::remove_file(Path).await
593 };
594
595 match Result {
596 Ok(()) => Ok(OkResponse(RequestId, &serde_json::Value::Null)),
597
598 Err(Error) => Ok(ErrResponse(RequestId, -32000, format!("fs.delete: {}", Error))),
599 }
600 },
601
602 "fs.rename" | "file:move" => {
603 let From = Params.get("from").and_then(|V| V.as_str()).unwrap_or("");
604
605 let To = Params.get("to").and_then(|V| V.as_str()).unwrap_or("");
606
607 match tokio::fs::rename(From, To).await {
608 Ok(()) => Ok(OkResponse(RequestId, &serde_json::Value::Null)),
609
610 Err(Error) => Ok(ErrResponse(RequestId, -32000, format!("fs.rename: {}", Error))),
611 }
612 },
613
614 "commands.execute" => {
616 let CommandId = Params.get("id").and_then(|V| V.as_str()).unwrap_or("").to_string();
617
618 let Arg = Params.get("arg").cloned().unwrap_or(serde_json::Value::Null);
619
620 match self.environment.ExecuteCommand(CommandId, Arg).await {
621 Ok(Value) => Ok(OkResponse(RequestId, &Value)),
622
623 Err(Error) => Ok(ErrResponse(RequestId, -32000, Error.to_string())),
624 }
625 },
626
627 "executeCommand" => {
629 let CommandId = Params.get("commandId").and_then(|V| V.as_str()).unwrap_or("").to_string();
630
631 let Arg = Params
632 .get("arguments")
633 .and_then(|A| A.as_array())
634 .and_then(|A| A.first())
635 .cloned()
636 .unwrap_or(serde_json::Value::Null);
637
638 match self.environment.ExecuteCommand(CommandId, Arg).await {
639 Ok(Value) => Ok(OkResponse(RequestId, &json!({ "result": Value }))),
640
641 Err(Error) => Ok(ErrResponse(RequestId, -32000, Error.to_string())),
642 }
643 },
644
645 "unregisterCommand" => {
646 let ExtensionId = Params.get("extensionId").and_then(|V| V.as_str()).unwrap_or("").to_string();
647
648 let CommandId = Params.get("commandId").and_then(|V| V.as_str()).unwrap_or("").to_string();
649
650 match self.environment.UnregisterCommand(ExtensionId, CommandId).await {
651 Ok(()) => Ok(OkResponse(RequestId, &json!({ "success": true }))),
652
653 Err(Error) => Ok(ErrResponse(RequestId, -32000, Error.to_string())),
654 }
655 },
656
657 "UserInterface.ShowOpenDialog" => {
659 use CommonLibrary::UserInterface::{
660 DTO::OpenDialogOptionsDTO::OpenDialogOptionsDTO,
661 UserInterfaceProvider::UserInterfaceProvider,
662 };
663
664 let Title = Params
665 .get(0)
666 .and_then(|V| V.get("title"))
667 .and_then(|T| T.as_str())
668 .map(|S| S.to_string());
669
670 let Options = OpenDialogOptionsDTO {
671 Base:CommonLibrary::UserInterface::DTO::DialogOptionsDTO::DialogOptionsDTO {
672 Title,
673 ..Default::default()
674 },
675 ..OpenDialogOptionsDTO::default()
676 };
677
678 match self.environment.ShowOpenDialog(Some(Options)).await {
679 Ok(Some(Paths)) => {
680 let Uris:Vec<String> = Paths.iter().map(|P| format!("file://{}", P.display())).collect();
681
682 Ok(OkResponse(RequestId, &json!(Uris)))
683 },
684
685 Ok(None) => Ok(OkResponse(RequestId, &json!(serde_json::Value::Array(vec![])))),
686
687 Err(Error) => Ok(ErrResponse(RequestId, -32000, Error.to_string())),
688 }
689 },
690
691 "UserInterface.ShowSaveDialog" => {
692 use CommonLibrary::UserInterface::{
693 DTO::SaveDialogOptionsDTO::SaveDialogOptionsDTO,
694 UserInterfaceProvider::UserInterfaceProvider,
695 };
696
697 let Title = Params
698 .get(0)
699 .and_then(|V| V.get("title"))
700 .and_then(|T| T.as_str())
701 .map(|S| S.to_string());
702
703 let Options = SaveDialogOptionsDTO {
704 Base:CommonLibrary::UserInterface::DTO::DialogOptionsDTO::DialogOptionsDTO {
705 Title,
706 ..Default::default()
707 },
708 ..SaveDialogOptionsDTO::default()
709 };
710
711 match self.environment.ShowSaveDialog(Some(Options)).await {
712 Ok(Some(Path)) => Ok(OkResponse(RequestId, &json!(format!("file://{}", Path.display())))),
713
714 Ok(None) => Ok(OkResponse(RequestId, &serde_json::Value::Null)),
715
716 Err(Error) => Ok(ErrResponse(RequestId, -32000, Error.to_string())),
717 }
718 },
719
720 "UserInterface.ShowInputBox" => {
721 use CommonLibrary::UserInterface::{
722 DTO::InputBoxOptionsDTO::InputBoxOptionsDTO,
723 UserInterfaceProvider::UserInterfaceProvider,
724 };
725
726 let Opts = Params.get(0);
727
728 let Options = InputBoxOptionsDTO {
729 Prompt:Opts
730 .and_then(|V| V.get("prompt"))
731 .and_then(|P| P.as_str())
732 .map(|S| S.to_string()),
733
734 PlaceHolder:Opts
735 .and_then(|V| V.get("placeHolder"))
736 .and_then(|P| P.as_str())
737 .map(|S| S.to_string()),
738
739 IsPassword:Some(Opts.and_then(|V| V.get("password")).and_then(|B| B.as_bool()).unwrap_or(false)),
740
741 Value:Opts
742 .and_then(|V| V.get("value"))
743 .and_then(|V| V.as_str())
744 .map(|S| S.to_string()),
745
746 Title:None,
747
748 IgnoreFocusOut:None,
749 };
750
751 match self.environment.ShowInputBox(Some(Options)).await {
752 Ok(Some(Text)) => Ok(OkResponse(RequestId, &json!(Text))),
753
754 Ok(None) => Ok(OkResponse(RequestId, &serde_json::Value::Null)),
755
756 Err(Error) => Ok(ErrResponse(RequestId, -32000, Error.to_string())),
757 }
758 },
759
760 "openExternal" => {
762 use tauri::Emitter;
763
764 let Url = Params
765 .as_str()
766 .or_else(|| Params.get("url").and_then(|V| V.as_str()))
767 .unwrap_or("")
768 .to_string();
769
770 let _ = self
772 .environment
773 .ApplicationHandle
774 .emit("sky://native/openExternal", json!({ "url": Url }));
775
776 Ok(OkResponse(RequestId, &json!({ "success": true })))
777 },
778
779 "showTextDocument" => {
781 use tauri::Emitter;
782
783 let Uri = Params
784 .get("uri")
785 .and_then(|V| V.get("value").or(Some(V)))
786 .and_then(|V| V.as_str())
787 .unwrap_or("")
788 .to_string();
789
790 let ViewColumn = Params.get("viewColumn").and_then(|V| V.as_i64()).map(|N| N + 2);
791
792 let PreserveFocus = Params.get("preserveFocus").and_then(|V| V.as_bool()).unwrap_or(false);
793
794 let _ = self.environment.ApplicationHandle.emit(
795 "sky://editor/openDocument",
796 json!({ "uri": Uri, "viewColumn": ViewColumn, "preserveFocus": PreserveFocus }),
797 );
798
799 Ok(OkResponse(RequestId, &json!({ "success": true })))
800 },
801
802 "showInformation" => {
803 use CommonLibrary::UserInterface::{
804 DTO::MessageSeverity::MessageSeverity,
805 UserInterfaceProvider::UserInterfaceProvider,
806 };
807
808 let Message = Params.get("message").and_then(|V| V.as_str()).unwrap_or("").to_string();
809
810 let Items:Option<serde_json::Value> = Params
811 .get("items")
812 .cloned()
813 .filter(|V| V.is_array() && !V.as_array().unwrap().is_empty());
814
815 match self.environment.ShowMessage(MessageSeverity::Info, Message, Items).await {
816 Ok(Some(Selected)) => Ok(OkResponse(RequestId, &json!({ "selectedItem": Selected }))),
817
818 Ok(None) => Ok(OkResponse(RequestId, &serde_json::Value::Null)),
819
820 Err(Error) => Ok(ErrResponse(RequestId, -32000, Error.to_string())),
821 }
822 },
823
824 "showWarning" => {
825 use CommonLibrary::UserInterface::{
826 DTO::MessageSeverity::MessageSeverity,
827 UserInterfaceProvider::UserInterfaceProvider,
828 };
829
830 let Message = Params.get("message").and_then(|V| V.as_str()).unwrap_or("").to_string();
831
832 let Items:Option<serde_json::Value> = Params
833 .get("items")
834 .cloned()
835 .filter(|V| V.is_array() && !V.as_array().unwrap().is_empty());
836
837 match self.environment.ShowMessage(MessageSeverity::Warning, Message, Items).await {
838 Ok(Some(Selected)) => Ok(OkResponse(RequestId, &json!({ "selectedItem": Selected }))),
839
840 Ok(None) => Ok(OkResponse(RequestId, &serde_json::Value::Null)),
841
842 Err(Error) => Ok(ErrResponse(RequestId, -32000, Error.to_string())),
843 }
844 },
845
846 "showError" => {
847 use CommonLibrary::UserInterface::{
848 DTO::MessageSeverity::MessageSeverity,
849 UserInterfaceProvider::UserInterfaceProvider,
850 };
851
852 let Message = Params.get("message").and_then(|V| V.as_str()).unwrap_or("").to_string();
853
854 let Items:Option<serde_json::Value> = Params
855 .get("items")
856 .cloned()
857 .filter(|V| V.is_array() && !V.as_array().unwrap().is_empty());
858
859 match self.environment.ShowMessage(MessageSeverity::Error, Message, Items).await {
860 Ok(Some(Selected)) => Ok(OkResponse(RequestId, &json!({ "selectedItem": Selected }))),
861
862 Ok(None) => Ok(OkResponse(RequestId, &serde_json::Value::Null)),
863
864 Err(Error) => Ok(ErrResponse(RequestId, -32000, Error.to_string())),
865 }
866 },
867
868 "createStatusBarItem" => {
869 use tauri::Emitter;
870
871 let Id = Params.get("id").and_then(|V| V.as_str()).unwrap_or("").to_string();
872
873 let Text = Params.get("text").and_then(|V| V.as_str()).unwrap_or("").to_string();
874
875 let Tooltip = Params.get("tooltip").and_then(|V| V.as_str()).unwrap_or("").to_string();
876
877 let _ = self.environment.ApplicationHandle.emit(
884 "sky://statusbar/set-entry",
885 json!({ "id": Id, "text": Text, "tooltip": Tooltip }),
886 );
887
888 Ok(OkResponse(RequestId, &json!({ "itemId": Id })))
889 },
890
891 "setStatusBarText" => {
892 use tauri::Emitter;
893
894 let ItemId = Params.get("itemId").and_then(|V| V.as_str()).unwrap_or("").to_string();
895
896 let Text = Params.get("text").and_then(|V| V.as_str()).unwrap_or("").to_string();
897
898 let _ = self
899 .environment
900 .ApplicationHandle
901 .emit("sky://statusbar/update", json!({ "id": ItemId, "text": Text }));
902
903 Ok(OkResponse(RequestId, &json!({ "success": true })))
904 },
905
906 "createWebviewPanel" => {
907 use tauri::Emitter;
908
909 let ViewType = Params.get("viewType").and_then(|V| V.as_str()).unwrap_or("").to_string();
910
911 let Title = Params.get("title").and_then(|V| V.as_str()).unwrap_or("").to_string();
912
913 let Handle = std::time::SystemTime::now()
914 .duration_since(std::time::UNIX_EPOCH)
915 .map(|D| D.as_millis() as u64)
916 .unwrap_or(0);
917
918 let _ = self.environment.ApplicationHandle.emit("sky://webview/create", json!({ "handle": Handle, "viewType": ViewType, "title": Title, "viewColumn": Params.get("viewColumn"), "preserveFocus": Params.get("preserveFocus").and_then(|V| V.as_bool()).unwrap_or(false) }));
919
920 Ok(OkResponse(RequestId, &json!({ "handle": Handle })))
921 },
922
923 "setWebviewHtml" => {
924 use tauri::Emitter;
925
926 let Handle = Params.get("handle").and_then(|V| V.as_u64()).unwrap_or(0);
927
928 let Html = Params.get("html").and_then(|V| V.as_str()).unwrap_or("").to_string();
929
930 let _ = self
932 .environment
933 .ApplicationHandle
934 .emit("sky://webview/set-html", json!({ "handle": Handle, "html": Html }));
935
936 Ok(OkResponse(RequestId, &json!({ "success": true })))
937 },
938
939 "findFiles" => {
951 use CommonLibrary::Workspace::WorkspaceProvider::WorkspaceProvider;
952
953 let Include = Params
954 .get("pattern")
955 .cloned()
956 .or_else(|| Params.get("include").cloned())
957 .unwrap_or(serde_json::Value::String("**".into()));
958
959 let Exclude = Params.get("exclude").cloned().filter(|V| !V.is_null());
960
961 let MaxResults = Params.get("maxResults").and_then(|V| V.as_u64()).map(|N| N as usize);
962
963 let UseIgnoreFiles = Params.get("useIgnoreFiles").and_then(|V| V.as_bool()).unwrap_or(true);
964
965 let FollowSymlinks = Params.get("followSymlinks").and_then(|V| V.as_bool()).unwrap_or(false);
966
967 match self
968 .environment
969 .FindFilesInWorkspace(Include, Exclude, MaxResults, UseIgnoreFiles, FollowSymlinks)
970 .await
971 {
972 Ok(Urls) => {
973 Ok(OkResponse(
974 RequestId,
975 &json!({ "uris": Urls.into_iter().map(|U| U.to_string()).collect::<Vec<_>>() }),
976 ))
977 },
978
979 Err(Error) => Ok(ErrResponse(RequestId, -32000, format!("findFiles: {}", Error))),
980 }
981 },
982
983 "findTextInFiles" => {
984 use CommonLibrary::Search::SearchProvider::SearchProvider;
985
986 let QueryValue = if Params.get("pattern").map(|V| V.is_object()).unwrap_or(false) {
990 Params.get("pattern").cloned().unwrap_or(serde_json::Value::Null)
991 } else if Params.get("pattern").map(|V| V.is_string()).unwrap_or(false) {
992 json!({
993 "pattern": Params.get("pattern").and_then(|V| V.as_str()).unwrap_or(""),
994 "isRegExp": Params.get("isRegExp").and_then(|V| V.as_bool()).unwrap_or(false),
995 "isCaseSensitive": Params.get("isCaseSensitive").and_then(|V| V.as_bool()).unwrap_or(false),
996 "isWordMatch": Params.get("isWordMatch").and_then(|V| V.as_bool()).unwrap_or(false),
997 })
998 } else {
999 Params.clone()
1000 };
1001
1002 let OptionsValue = Params.get("options").cloned().unwrap_or(serde_json::Value::Null);
1003
1004 match self.environment.TextSearch(QueryValue, OptionsValue).await {
1005 Ok(Matches) => Ok(OkResponse(RequestId, &json!({ "matches": Matches }))),
1006
1007 Err(Error) => Ok(ErrResponse(RequestId, -32000, format!("findTextInFiles: {}", Error))),
1008 }
1009 },
1010
1011 "openDocument" => {
1012 use tauri::Emitter;
1013
1014 let Uri = Params
1015 .get("uri")
1016 .and_then(|V| V.get("value").or(Some(V)))
1017 .and_then(|V| V.as_str())
1018 .unwrap_or("")
1019 .to_string();
1020
1021 let ViewColumn = Params.get("viewColumn").and_then(|V| V.as_i64());
1022
1023 let _ = self
1024 .environment
1025 .ApplicationHandle
1026 .emit("sky://editor/openDocument", json!({ "uri": Uri, "viewColumn": ViewColumn }));
1027
1028 Ok(OkResponse(RequestId, &json!({ "success": true })))
1029 },
1030
1031 "saveAll" => {
1032 use tauri::Emitter;
1033
1034 let IncludeUntitled = Params.get("includeUntitled").and_then(|V| V.as_bool()).unwrap_or(false);
1035
1036 let _ = self
1037 .environment
1038 .ApplicationHandle
1039 .emit("sky://editor/saveAll", json!({ "includeUntitled": IncludeUntitled }));
1040
1041 Ok(OkResponse(RequestId, &json!({ "success": true })))
1042 },
1043
1044 "applyEdit" => {
1045 use tauri::Emitter;
1046
1047 let Uri = Params
1048 .get("uri")
1049 .and_then(|V| V.get("value").or(Some(V)))
1050 .and_then(|V| V.as_str())
1051 .unwrap_or("")
1052 .to_string();
1053
1054 let Edits = Params.get("edits").cloned().unwrap_or(json!([]));
1055
1056 let _ = self
1057 .environment
1058 .ApplicationHandle
1059 .emit("sky://editor/applyEdits", json!({ "uri": Uri, "edits": Edits }));
1060
1061 Ok(OkResponse(RequestId, &json!({ "success": true })))
1062 },
1063
1064 "getSecret" => {
1066 use CommonLibrary::Secret::SecretProvider::SecretProvider;
1067
1068 let ExtensionId = Params.get("extensionId").and_then(|V| V.as_str()).unwrap_or("").to_string();
1069
1070 let Key = Params.get("key").and_then(|V| V.as_str()).unwrap_or("").to_string();
1071
1072 match self.environment.GetSecret(ExtensionId, Key).await {
1073 Ok(Some(Value)) => Ok(OkResponse(RequestId, &json!({ "value": Value }))),
1074
1075 Ok(None) => Ok(OkResponse(RequestId, &serde_json::Value::Null)),
1076
1077 Err(Error) => Ok(ErrResponse(RequestId, -32000, Error.to_string())),
1078 }
1079 },
1080
1081 "storeSecret" => {
1082 use CommonLibrary::Secret::SecretProvider::SecretProvider;
1083
1084 let ExtensionId = Params.get("extensionId").and_then(|V| V.as_str()).unwrap_or("").to_string();
1085
1086 let Key = Params.get("key").and_then(|V| V.as_str()).unwrap_or("").to_string();
1087
1088 let Value = Params.get("value").and_then(|V| V.as_str()).unwrap_or("").to_string();
1089
1090 match self.environment.StoreSecret(ExtensionId, Key, Value).await {
1091 Ok(()) => Ok(OkResponse(RequestId, &json!({ "success": true }))),
1092
1093 Err(Error) => Ok(ErrResponse(RequestId, -32000, Error.to_string())),
1094 }
1095 },
1096
1097 "deleteSecret" => {
1098 use CommonLibrary::Secret::SecretProvider::SecretProvider;
1099
1100 let ExtensionId = Params.get("extensionId").and_then(|V| V.as_str()).unwrap_or("").to_string();
1101
1102 let Key = Params.get("key").and_then(|V| V.as_str()).unwrap_or("").to_string();
1103
1104 match self.environment.DeleteSecret(ExtensionId, Key).await {
1105 Ok(()) => Ok(OkResponse(RequestId, &json!({ "success": true }))),
1106
1107 Err(Error) => Ok(ErrResponse(RequestId, -32000, Error.to_string())),
1108 }
1109 },
1110
1111 "readFile" => {
1113 let Uri = Params
1114 .get("uri")
1115 .and_then(|V| V.as_str())
1116 .or_else(|| Params.as_str())
1117 .unwrap_or("")
1118 .replace("file://", "");
1119
1120 match tokio::fs::read(&Uri).await {
1121 Ok(Content) => Ok(OkResponse(RequestId, &Content)),
1122
1123 Err(Error) => Ok(ErrResponse(RequestId, -32000, format!("readFile: {}", Error))),
1124 }
1125 },
1126
1127 "writeFile" => {
1128 let Uri = Params.get("uri").and_then(|V| V.as_str()).unwrap_or("").replace("file://", "");
1129
1130 let Content:Vec<u8> = Params
1131 .get("content")
1132 .and_then(|V| V.as_array())
1133 .map(|A| A.iter().filter_map(|B| B.as_u64().map(|N| N as u8)).collect())
1134 .unwrap_or_default();
1135
1136 match tokio::fs::write(&Uri, &Content).await {
1137 Ok(()) => Ok(OkResponse(RequestId, &serde_json::Value::Null)),
1138
1139 Err(Error) => Ok(ErrResponse(RequestId, -32000, format!("writeFile: {}", Error))),
1140 }
1141 },
1142
1143 "stat" => {
1144 let Uri = Params
1145 .get("uri")
1146 .and_then(|V| V.as_str())
1147 .or_else(|| Params.as_str())
1148 .unwrap_or("")
1149 .replace("file://", "");
1150
1151 match tokio::fs::metadata(&Uri).await {
1152 Ok(Meta) => {
1153 let Mtime = Meta
1154 .modified()
1155 .ok()
1156 .and_then(|T| T.duration_since(UNIX_EPOCH).ok())
1157 .map(|D| D.as_millis() as u64)
1158 .unwrap_or(0);
1159
1160 Ok(OkResponse(
1161 RequestId,
1162 &json!({ "type": if Meta.is_dir() { 2 } else { 1 }, "is_file": Meta.is_file(), "is_directory": Meta.is_dir(), "size": Meta.len(), "mtime": Mtime }),
1163 ))
1164 },
1165
1166 Err(Error) => Ok(ErrResponse(RequestId, -32000, format!("stat: {}", Error))),
1167 }
1168 },
1169
1170 "readdir" => {
1171 let Uri = Params
1172 .get("uri")
1173 .and_then(|V| V.as_str())
1174 .or_else(|| Params.as_str())
1175 .unwrap_or("")
1176 .replace("file://", "");
1177
1178 match tokio::fs::read_dir(&Uri).await {
1179 Ok(mut Entries) => {
1180 let mut Names:Vec<String> = Vec::new();
1181
1182 while let Ok(Some(Entry)) = Entries.next_entry().await {
1183 if let Some(Name) = Entry.file_name().to_str() {
1184 Names.push(Name.to_string());
1185 }
1186 }
1187
1188 Ok(OkResponse(RequestId, &Names))
1189 },
1190
1191 Err(Error) => Ok(ErrResponse(RequestId, -32000, format!("readdir: {}", Error))),
1192 }
1193 },
1194
1195 _ => {
1197 dev_log!("cocoon", "warn: [CocoonService] Unknown generic method: {}", Req.method);
1198
1199 Ok(ErrResponse(RequestId, -32601, format!("Method '{}' not found", Req.method)))
1200 },
1201 }
1202 }
1203
1204 async fn send_mountain_notification(
1209 &self,
1210
1211 request:Request<GenericNotificationMsg>,
1212 ) -> Result<Response<Empty>, Status> {
1213 let notification = request.into_inner();
1214
1215 dev_log!(
1216 "cocoon",
1217 "[CocoonService] Notification router: method='{}'",
1218 notification.method
1219 );
1220
1221 let Params:serde_json::Value = if notification.parameter.is_empty() {
1223 serde_json::Value::Null
1224 } else {
1225 serde_json::from_slice(¬ification.parameter).unwrap_or(serde_json::Value::Null)
1226 };
1227
1228 match notification.method.as_str() {
1229 "registerCommand" => {
1231 let CommandId = Params.get("commandId").and_then(|V| V.as_str()).unwrap_or("").to_string();
1232
1233 let ExtensionId = Params.get("extensionId").and_then(|V| V.as_str()).unwrap_or("").to_string();
1234
1235 if let Err(Error) = self.environment.RegisterCommand(ExtensionId, CommandId.clone()).await {
1236 dev_log!(
1237 "cocoon",
1238 "warn: [CocoonService] notification: registerCommand '{}' failed: {:?}",
1239 CommandId,
1240 Error
1241 );
1242 }
1243 },
1244
1245 "unregisterCommand" => {
1246 let ExtensionId = Params.get("extensionId").and_then(|V| V.as_str()).unwrap_or("").to_string();
1247
1248 let CommandId = Params.get("commandId").and_then(|V| V.as_str()).unwrap_or("").to_string();
1249
1250 let _ = self.environment.UnregisterCommand(ExtensionId, CommandId).await;
1251 },
1252
1253 "register_hover_provider" => {
1255 let Handle = Params.get("handle").and_then(|V| V.as_u64()).unwrap_or(0) as u32;
1256
1257 let Selector = Params.get("language_selector").and_then(|V| V.as_str()).unwrap_or("*");
1258
1259 let ExtId = Params.get("extension_id").and_then(|V| V.as_str()).unwrap_or("");
1260
1261 self.RegisterProvider(Handle, ProviderType::Hover, Selector, ExtId);
1262 },
1263
1264 "register_completion_item_provider" => {
1265 let Handle = Params.get("handle").and_then(|V| V.as_u64()).unwrap_or(0) as u32;
1266
1267 let Selector = Params.get("language_selector").and_then(|V| V.as_str()).unwrap_or("*");
1268
1269 let ExtId = Params.get("extension_id").and_then(|V| V.as_str()).unwrap_or("");
1270
1271 self.RegisterProvider(Handle, ProviderType::Completion, Selector, ExtId);
1272 },
1273
1274 "register_definition_provider" => {
1275 let Handle = Params.get("handle").and_then(|V| V.as_u64()).unwrap_or(0) as u32;
1276
1277 let Selector = Params.get("language_selector").and_then(|V| V.as_str()).unwrap_or("*");
1278
1279 let ExtId = Params.get("extension_id").and_then(|V| V.as_str()).unwrap_or("");
1280
1281 self.RegisterProvider(Handle, ProviderType::Definition, Selector, ExtId);
1282 },
1283
1284 "register_reference_provider" => {
1285 let Handle = Params.get("handle").and_then(|V| V.as_u64()).unwrap_or(0) as u32;
1286
1287 let Selector = Params.get("language_selector").and_then(|V| V.as_str()).unwrap_or("*");
1288
1289 let ExtId = Params.get("extension_id").and_then(|V| V.as_str()).unwrap_or("");
1290
1291 self.RegisterProvider(Handle, ProviderType::References, Selector, ExtId);
1292 },
1293
1294 "register_code_actions_provider" => {
1295 let Handle = Params.get("handle").and_then(|V| V.as_u64()).unwrap_or(0) as u32;
1296
1297 let Selector = Params.get("language_selector").and_then(|V| V.as_str()).unwrap_or("*");
1298
1299 let ExtId = Params.get("extension_id").and_then(|V| V.as_str()).unwrap_or("");
1300
1301 self.RegisterProvider(Handle, ProviderType::CodeAction, Selector, ExtId);
1302 },
1303
1304 "register_document_highlight_provider" => {
1305 let Handle = Params.get("handle").and_then(|V| V.as_u64()).unwrap_or(0) as u32;
1306
1307 let Selector = Params.get("language_selector").and_then(|V| V.as_str()).unwrap_or("*");
1308
1309 let ExtId = Params.get("extension_id").and_then(|V| V.as_str()).unwrap_or("");
1310
1311 self.RegisterProvider(Handle, ProviderType::DocumentHighlight, Selector, ExtId);
1312 },
1313
1314 "register_document_symbol_provider" => {
1315 let Handle = Params.get("handle").and_then(|V| V.as_u64()).unwrap_or(0) as u32;
1316
1317 let Selector = Params.get("language_selector").and_then(|V| V.as_str()).unwrap_or("*");
1318
1319 let ExtId = Params.get("extension_id").and_then(|V| V.as_str()).unwrap_or("");
1320
1321 self.RegisterProvider(Handle, ProviderType::DocumentSymbol, Selector, ExtId);
1322 },
1323
1324 "register_workspace_symbol_provider" => {
1325 let Handle = Params.get("handle").and_then(|V| V.as_u64()).unwrap_or(0) as u32;
1326
1327 let Selector = Params.get("language_selector").and_then(|V| V.as_str()).unwrap_or("*");
1328
1329 let ExtId = Params.get("extension_id").and_then(|V| V.as_str()).unwrap_or("");
1330
1331 self.RegisterProvider(Handle, ProviderType::WorkspaceSymbol, Selector, ExtId);
1332 },
1333
1334 "register_rename_provider" => {
1335 let Handle = Params.get("handle").and_then(|V| V.as_u64()).unwrap_or(0) as u32;
1336
1337 let Selector = Params.get("language_selector").and_then(|V| V.as_str()).unwrap_or("*");
1338
1339 let ExtId = Params.get("extension_id").and_then(|V| V.as_str()).unwrap_or("");
1340
1341 self.RegisterProvider(Handle, ProviderType::Rename, Selector, ExtId);
1342 },
1343
1344 "register_document_formatting_provider" => {
1345 let Handle = Params.get("handle").and_then(|V| V.as_u64()).unwrap_or(0) as u32;
1346
1347 let Selector = Params.get("language_selector").and_then(|V| V.as_str()).unwrap_or("*");
1348
1349 let ExtId = Params.get("extension_id").and_then(|V| V.as_str()).unwrap_or("");
1350
1351 self.RegisterProvider(Handle, ProviderType::DocumentFormatting, Selector, ExtId);
1352 },
1353
1354 "register_document_range_formatting_provider" => {
1355 let Handle = Params.get("handle").and_then(|V| V.as_u64()).unwrap_or(0) as u32;
1356
1357 let Selector = Params.get("language_selector").and_then(|V| V.as_str()).unwrap_or("*");
1358
1359 let ExtId = Params.get("extension_id").and_then(|V| V.as_str()).unwrap_or("");
1360
1361 self.RegisterProvider(Handle, ProviderType::DocumentRangeFormatting, Selector, ExtId);
1362 },
1363
1364 "register_on_type_formatting_provider" => {
1365 let Handle = Params.get("handle").and_then(|V| V.as_u64()).unwrap_or(0) as u32;
1366
1367 let Selector = Params.get("language_selector").and_then(|V| V.as_str()).unwrap_or("*");
1368
1369 let ExtId = Params.get("extension_id").and_then(|V| V.as_str()).unwrap_or("");
1370
1371 self.RegisterProvider(Handle, ProviderType::OnTypeFormatting, Selector, ExtId);
1372 },
1373
1374 "register_signature_help_provider" => {
1375 let Handle = Params.get("handle").and_then(|V| V.as_u64()).unwrap_or(0) as u32;
1376
1377 let Selector = Params.get("language_selector").and_then(|V| V.as_str()).unwrap_or("*");
1378
1379 let ExtId = Params.get("extension_id").and_then(|V| V.as_str()).unwrap_or("");
1380
1381 self.RegisterProvider(Handle, ProviderType::SignatureHelp, Selector, ExtId);
1382 },
1383
1384 "register_code_lens_provider" => {
1385 let Handle = Params.get("handle").and_then(|V| V.as_u64()).unwrap_or(0) as u32;
1386
1387 let Selector = Params.get("language_selector").and_then(|V| V.as_str()).unwrap_or("*");
1388
1389 let ExtId = Params.get("extension_id").and_then(|V| V.as_str()).unwrap_or("");
1390
1391 self.RegisterProvider(Handle, ProviderType::CodeLens, Selector, ExtId);
1392 },
1393
1394 "register_folding_range_provider" => {
1395 let Handle = Params.get("handle").and_then(|V| V.as_u64()).unwrap_or(0) as u32;
1396
1397 let Selector = Params.get("language_selector").and_then(|V| V.as_str()).unwrap_or("*");
1398
1399 let ExtId = Params.get("extension_id").and_then(|V| V.as_str()).unwrap_or("");
1400
1401 self.RegisterProvider(Handle, ProviderType::FoldingRange, Selector, ExtId);
1402 },
1403
1404 "register_selection_range_provider" => {
1405 let Handle = Params.get("handle").and_then(|V| V.as_u64()).unwrap_or(0) as u32;
1406
1407 let Selector = Params.get("language_selector").and_then(|V| V.as_str()).unwrap_or("*");
1408
1409 let ExtId = Params.get("extension_id").and_then(|V| V.as_str()).unwrap_or("");
1410
1411 self.RegisterProvider(Handle, ProviderType::SelectionRange, Selector, ExtId);
1412 },
1413
1414 "register_semantic_tokens_provider" => {
1415 let Handle = Params.get("handle").and_then(|V| V.as_u64()).unwrap_or(0) as u32;
1416
1417 let Selector = Params.get("language_selector").and_then(|V| V.as_str()).unwrap_or("*");
1418
1419 let ExtId = Params.get("extension_id").and_then(|V| V.as_str()).unwrap_or("");
1420
1421 self.RegisterProvider(Handle, ProviderType::SemanticTokens, Selector, ExtId);
1422 },
1423
1424 "register_inlay_hints_provider" => {
1425 let Handle = Params.get("handle").and_then(|V| V.as_u64()).unwrap_or(0) as u32;
1426
1427 let Selector = Params.get("language_selector").and_then(|V| V.as_str()).unwrap_or("*");
1428
1429 let ExtId = Params.get("extension_id").and_then(|V| V.as_str()).unwrap_or("");
1430
1431 self.RegisterProvider(Handle, ProviderType::InlayHint, Selector, ExtId);
1432 },
1433
1434 "register_type_hierarchy_provider" => {
1435 let Handle = Params.get("handle").and_then(|V| V.as_u64()).unwrap_or(0) as u32;
1436
1437 let Selector = Params.get("language_selector").and_then(|V| V.as_str()).unwrap_or("*");
1438
1439 let ExtId = Params.get("extension_id").and_then(|V| V.as_str()).unwrap_or("");
1440
1441 self.RegisterProvider(Handle, ProviderType::TypeHierarchy, Selector, ExtId);
1442 },
1443
1444 "register_call_hierarchy_provider" => {
1445 let Handle = Params.get("handle").and_then(|V| V.as_u64()).unwrap_or(0) as u32;
1446
1447 let Selector = Params.get("language_selector").and_then(|V| V.as_str()).unwrap_or("*");
1448
1449 let ExtId = Params.get("extension_id").and_then(|V| V.as_str()).unwrap_or("");
1450
1451 self.RegisterProvider(Handle, ProviderType::CallHierarchy, Selector, ExtId);
1452 },
1453
1454 "register_linked_editing_range_provider" => {
1455 let Handle = Params.get("handle").and_then(|V| V.as_u64()).unwrap_or(0) as u32;
1456
1457 let Selector = Params.get("language_selector").and_then(|V| V.as_str()).unwrap_or("*");
1458
1459 let ExtId = Params.get("extension_id").and_then(|V| V.as_str()).unwrap_or("");
1460
1461 self.RegisterProvider(Handle, ProviderType::LinkedEditingRange, Selector, ExtId);
1462 },
1463
1464 "register_document_link_provider" => {
1465 let Handle = Params.get("handle").and_then(|V| V.as_u64()).unwrap_or(0) as u32;
1466
1467 let Selector = Params.get("language_selector").and_then(|V| V.as_str()).unwrap_or("*");
1468
1469 let ExtId = Params.get("extension_id").and_then(|V| V.as_str()).unwrap_or("");
1470
1471 self.RegisterProvider(Handle, ProviderType::DocumentLink, Selector, ExtId);
1472 },
1473
1474 "register_color_provider" => {
1475 let Handle = Params.get("handle").and_then(|V| V.as_u64()).unwrap_or(0) as u32;
1476
1477 let Selector = Params.get("language_selector").and_then(|V| V.as_str()).unwrap_or("*");
1478
1479 let ExtId = Params.get("extension_id").and_then(|V| V.as_str()).unwrap_or("");
1480
1481 self.RegisterProvider(Handle, ProviderType::Color, Selector, ExtId);
1482 },
1483
1484 "register_implementation_provider" => {
1485 let Handle = Params.get("handle").and_then(|V| V.as_u64()).unwrap_or(0) as u32;
1486
1487 let Selector = Params.get("language_selector").and_then(|V| V.as_str()).unwrap_or("*");
1488
1489 let ExtId = Params.get("extension_id").and_then(|V| V.as_str()).unwrap_or("");
1490
1491 self.RegisterProvider(Handle, ProviderType::Implementation, Selector, ExtId);
1492 },
1493
1494 "register_type_definition_provider" => {
1495 let Handle = Params.get("handle").and_then(|V| V.as_u64()).unwrap_or(0) as u32;
1496
1497 let Selector = Params.get("language_selector").and_then(|V| V.as_str()).unwrap_or("*");
1498
1499 let ExtId = Params.get("extension_id").and_then(|V| V.as_str()).unwrap_or("");
1500
1501 self.RegisterProvider(Handle, ProviderType::TypeDefinition, Selector, ExtId);
1502 },
1503
1504 "register_declaration_provider" => {
1505 let Handle = Params.get("handle").and_then(|V| V.as_u64()).unwrap_or(0) as u32;
1506
1507 let Selector = Params.get("language_selector").and_then(|V| V.as_str()).unwrap_or("*");
1508
1509 let ExtId = Params.get("extension_id").and_then(|V| V.as_str()).unwrap_or("");
1510
1511 self.RegisterProvider(Handle, ProviderType::Declaration, Selector, ExtId);
1512 },
1513
1514 "register_evaluatable_expression_provider" => {
1515 let Handle = Params.get("handle").and_then(|V| V.as_u64()).unwrap_or(0) as u32;
1516
1517 let Selector = Params.get("language_selector").and_then(|V| V.as_str()).unwrap_or("*");
1518
1519 let ExtId = Params.get("extension_id").and_then(|V| V.as_str()).unwrap_or("");
1520
1521 self.RegisterProvider(Handle, ProviderType::EvaluatableExpression, Selector, ExtId);
1522 },
1523
1524 "register_inline_values_provider" => {
1525 let Handle = Params.get("handle").and_then(|V| V.as_u64()).unwrap_or(0) as u32;
1526
1527 let Selector = Params.get("language_selector").and_then(|V| V.as_str()).unwrap_or("*");
1528
1529 let ExtId = Params.get("extension_id").and_then(|V| V.as_str()).unwrap_or("");
1530
1531 self.RegisterProvider(Handle, ProviderType::InlineValues, Selector, ExtId);
1532 },
1533
1534 "onDidReceiveMessage" => {
1536 use tauri::Emitter;
1537
1538 let Handle = Params.get("handle").and_then(|V| V.as_u64()).unwrap_or(0);
1539
1540 let Message = Params
1541 .get("stringMessage")
1542 .and_then(|V| V.as_str())
1543 .map(|S| S.to_string())
1544 .or_else(|| Params.get("bytesMessage").map(|_| "[binary]".to_string()))
1545 .unwrap_or_default();
1546
1547 let _ = self
1548 .environment
1549 .ApplicationHandle
1550 .emit("sky://webview/post-message", json!({ "handle": Handle, "message": Message }));
1551 },
1552
1553 "storeSecret" => {
1555 use CommonLibrary::Secret::SecretProvider::SecretProvider;
1556
1557 let ExtensionId = Params.get("extensionId").and_then(|V| V.as_str()).unwrap_or("").to_string();
1558
1559 let Key = Params.get("key").and_then(|V| V.as_str()).unwrap_or("").to_string();
1560
1561 let Value = Params.get("value").and_then(|V| V.as_str()).unwrap_or("").to_string();
1562
1563 let _ = self.environment.StoreSecret(ExtensionId, Key, Value).await;
1564 },
1565
1566 "deleteSecret" => {
1567 use CommonLibrary::Secret::SecretProvider::SecretProvider;
1568
1569 let ExtensionId = Params.get("extensionId").and_then(|V| V.as_str()).unwrap_or("").to_string();
1570
1571 let Key = Params.get("key").and_then(|V| V.as_str()).unwrap_or("").to_string();
1572
1573 let _ = self.environment.DeleteSecret(ExtensionId, Key).await;
1574 },
1575
1576 "writeFile" => {
1578 let Uri = Params
1579 .get("uri")
1580 .and_then(|V| V.get("value").or(Some(V)))
1581 .and_then(|V| V.as_str())
1582 .unwrap_or("")
1583 .replace("file://", "");
1584
1585 let Content:Vec<u8> = Params
1586 .get("content")
1587 .and_then(|V| V.as_array())
1588 .map(|A| A.iter().filter_map(|B| B.as_u64().map(|N| N as u8)).collect())
1589 .unwrap_or_default();
1590
1591 let _ = tokio::fs::write(&Uri, &Content).await;
1592 },
1593
1594 "webview.postMessage" => {
1596 use tauri::Emitter;
1597
1598 let PanelId = Params.get("panelId").and_then(|V| V.as_str()).unwrap_or("").to_string();
1599
1600 let Method = Params.get("method").and_then(|V| V.as_str()).unwrap_or("").to_string();
1601
1602 let MsgParams = Params.get("params").cloned().unwrap_or(serde_json::Value::Null);
1603
1604 let _ = self.environment.ApplicationHandle.emit(
1605 "sky://webview/message",
1606 json!({ "panelId": PanelId, "method": Method, "params": MsgParams }),
1607 );
1608 },
1609
1610 "webview.dispose" => {
1611 use tauri::Emitter;
1612
1613 let PanelId = Params.get("panelId").and_then(|V| V.as_str()).unwrap_or("").to_string();
1614
1615 let _ = self
1616 .environment
1617 .ApplicationHandle
1618 .emit("sky://webview/dispose", json!({ "panelId": PanelId }));
1619 },
1620
1621 "progress.start" => {
1623 use tauri::Emitter;
1624
1625 let Id = Params.get("id").and_then(|V| V.as_str()).unwrap_or("").to_string();
1626
1627 let Title = Params.get("title").and_then(|V| V.as_str()).map(|S| S.to_string());
1628
1629 let Location = Params.get("location").cloned();
1630
1631 let Cancellable = Params.get("cancellable").and_then(|V| V.as_bool()).unwrap_or(false);
1632
1633 let _ = self.environment.ApplicationHandle.emit(
1634 "sky://progress/start",
1635 json!({ "id": Id, "title": Title, "location": Location, "cancellable": Cancellable }),
1636 );
1637 },
1638
1639 "progress.update" => {
1640 use tauri::Emitter;
1641
1642 let Id = Params.get("id").and_then(|V| V.as_str()).unwrap_or("").to_string();
1643
1644 let Message = Params.get("message").and_then(|V| V.as_str()).map(|S| S.to_string());
1645
1646 let Increment = Params.get("increment").and_then(|V| V.as_f64());
1647
1648 let _ = self.environment.ApplicationHandle.emit(
1649 "sky://progress/update",
1650 json!({ "id": Id, "message": Message, "increment": Increment }),
1651 );
1652 },
1653
1654 "progress.complete" => {
1655 use tauri::Emitter;
1656
1657 let Id = Params.get("id").and_then(|V| V.as_str()).unwrap_or("").to_string();
1658
1659 let _ = self
1660 .environment
1661 .ApplicationHandle
1662 .emit("sky://progress/complete", json!({ "id": Id }));
1663 },
1664
1665 "openExternal" => {
1667 use tauri::Emitter;
1668
1669 let Url = Params.get("url").and_then(|V| V.as_str()).unwrap_or("").to_string();
1670
1671 let _ = self
1672 .environment
1673 .ApplicationHandle
1674 .emit("sky://native/openExternal", json!({ "url": Url }));
1675 },
1676
1677 "setStatusBarText" | "statusBar.setText" => {
1679 use tauri::Emitter;
1680
1681 let ItemId = Params.get("itemId").and_then(|V| V.as_str()).unwrap_or("").to_string();
1682
1683 let Text = Params.get("text").and_then(|V| V.as_str()).unwrap_or("").to_string();
1684
1685 let _ = self
1686 .environment
1687 .ApplicationHandle
1688 .emit("sky://statusbar/update", json!({ "id": ItemId, "text": Text }));
1689 },
1690
1691 "disposeStatusBarItem" | "statusBar.dispose" => {
1692 use tauri::Emitter;
1693
1694 let ItemId = Params.get("itemId").and_then(|V| V.as_str()).unwrap_or("").to_string();
1695
1696 let _ = self
1697 .environment
1698 .ApplicationHandle
1699 .emit("sky://statusbar/dispose", json!({ "id": ItemId }));
1700 },
1701
1702 "output.create" => {
1704 use tauri::Emitter;
1705
1706 let Id = Params.get("id").and_then(|V| V.as_str()).unwrap_or("").to_string();
1707
1708 let Name = Params.get("name").and_then(|V| V.as_str()).unwrap_or("").to_string();
1709
1710 let _ = self
1711 .environment
1712 .ApplicationHandle
1713 .emit("sky://output/create", json!({ "id": Id, "name": Name }));
1714 },
1715
1716 "output.append" => {
1717 use tauri::Emitter;
1718
1719 let Channel = Params.get("channel").and_then(|V| V.as_str()).unwrap_or("").to_string();
1720
1721 let Text = Params.get("value").and_then(|V| V.as_str()).unwrap_or("").to_string();
1722
1723 let _ = self
1724 .environment
1725 .ApplicationHandle
1726 .emit("sky://output/append", json!({ "channel": Channel, "text": Text }));
1727 },
1728
1729 "output.appendLine" => {
1730 use tauri::Emitter;
1731
1732 let Channel = Params.get("channel").and_then(|V| V.as_str()).unwrap_or("").to_string();
1733
1734 let Line = Params.get("value").and_then(|V| V.as_str()).unwrap_or("").to_string();
1735
1736 let _ = self.environment.ApplicationHandle.emit(
1737 "sky://output/append",
1738 json!({ "channel": Channel, "text": format!("{}\n", Line) }),
1739 );
1740 },
1741
1742 "output.clear" => {
1743 use tauri::Emitter;
1744
1745 let Channel = Params.get("channel").and_then(|V| V.as_str()).unwrap_or("").to_string();
1746
1747 let _ = self
1748 .environment
1749 .ApplicationHandle
1750 .emit("sky://output/clear", json!({ "channel": Channel }));
1751 },
1752
1753 "output.show" => {
1754 use tauri::Emitter;
1755
1756 let Channel = Params.get("channel").and_then(|V| V.as_str()).unwrap_or("").to_string();
1757
1758 let _ = self
1759 .environment
1760 .ApplicationHandle
1761 .emit("sky://output/show", json!({ "channel": Channel }));
1762 },
1763
1764 "output.dispose" => {
1765 use tauri::Emitter;
1766
1767 let Channel = Params.get("channel").and_then(|V| V.as_str()).unwrap_or("").to_string();
1768
1769 let _ = self
1770 .environment
1771 .ApplicationHandle
1772 .emit("sky://output/dispose", json!({ "channel": Channel }));
1773 },
1774
1775 "set_language_configuration" => {
1777 use tauri::Emitter;
1779
1780 let Language = Params.get("language").and_then(|V| V.as_str()).unwrap_or("").to_string();
1781
1782 let _ = self
1783 .environment
1784 .ApplicationHandle
1785 .emit("sky://language/configure", json!({ "language": Language }));
1786 },
1787
1788 _ => {
1789 dev_log!(
1790 "cocoon",
1791 "[CocoonService] Unknown notification method: '{}'",
1792 notification.method
1793 );
1794 },
1795 }
1796
1797 Ok(Response::new(Empty {}))
1798 }
1799
1800 async fn cancel_operation(&self, request:Request<CancelOperationRequest>) -> Result<Response<Empty>, Status> {
1803 Initialization::CancelOperation::Fn(self, request.into_inner()).await
1804 }
1805
1806 async fn initial_handshake(&self, request:Request<Empty>) -> Result<Response<Empty>, Status> {
1807 Initialization::InitialHandshake::Fn(self, request.into_inner()).await
1808 }
1809
1810 async fn init_extension_host(&self, request:Request<InitExtensionHostRequest>) -> Result<Response<Empty>, Status> {
1811 Initialization::InitExtensionHost::Fn(self, request.into_inner()).await
1812 }
1813
1814 async fn register_command(&self, request:Request<RegisterCommandRequest>) -> Result<Response<Empty>, Status> {
1815 Command::RegisterCommand::Fn(self, request.into_inner()).await
1816 }
1817
1818 async fn execute_contributed_command(
1819 &self,
1820
1821 request:Request<ExecuteCommandRequest>,
1822 ) -> Result<Response<ExecuteCommandResponse>, Status> {
1823 Command::ExecuteContributedCommand::Fn(self, request.into_inner()).await
1824 }
1825
1826 async fn unregister_command(&self, request:Request<UnregisterCommandRequest>) -> Result<Response<Empty>, Status> {
1827 Command::UnregisterCommand::Fn(self, request.into_inner()).await
1828 }
1829
1830 async fn register_hover_provider(
1831 &self,
1832
1833 request:Request<RegisterProviderRequest>,
1834 ) -> Result<Response<Empty>, Status> {
1835 Provider::RegisterHoverProvider::Fn(self, request.into_inner()).await
1836 }
1837
1838 async fn provide_hover(
1839 &self,
1840
1841 request:Request<ProvideHoverRequest>,
1842 ) -> Result<Response<ProvideHoverResponse>, Status> {
1843 Provider::ProvideHover::Fn(self, request.into_inner()).await
1844 }
1845
1846 async fn register_completion_item_provider(
1847 &self,
1848
1849 request:Request<RegisterProviderRequest>,
1850 ) -> Result<Response<Empty>, Status> {
1851 Provider::RegisterCompletionItemProvider::Fn(self, request.into_inner()).await
1852 }
1853
1854 async fn provide_completion_items(
1855 &self,
1856
1857 request:Request<ProvideCompletionItemsRequest>,
1858 ) -> Result<Response<ProvideCompletionItemsResponse>, Status> {
1859 Provider::ProvideCompletionItems::Fn(self, request.into_inner()).await
1860 }
1861
1862 async fn register_definition_provider(
1863 &self,
1864
1865 request:Request<RegisterProviderRequest>,
1866 ) -> Result<Response<Empty>, Status> {
1867 Provider::RegisterDefinitionProvider::Fn(self, request.into_inner()).await
1868 }
1869
1870 async fn provide_definition(
1871 &self,
1872
1873 request:Request<ProvideDefinitionRequest>,
1874 ) -> Result<Response<ProvideDefinitionResponse>, Status> {
1875 Provider::ProvideDefinition::Fn(self, request.into_inner()).await
1876 }
1877
1878 async fn register_reference_provider(
1879 &self,
1880
1881 request:Request<RegisterProviderRequest>,
1882 ) -> Result<Response<Empty>, Status> {
1883 Provider::RegisterReferenceProvider::Fn(self, request.into_inner()).await
1884 }
1885
1886 async fn provide_references(
1887 &self,
1888
1889 request:Request<ProvideReferencesRequest>,
1890 ) -> Result<Response<ProvideReferencesResponse>, Status> {
1891 Provider::ProvideReferences::Fn(self, request.into_inner()).await
1892 }
1893
1894 async fn register_code_actions_provider(
1895 &self,
1896
1897 request:Request<RegisterProviderRequest>,
1898 ) -> Result<Response<Empty>, Status> {
1899 Provider::RegisterCodeActionsProvider::Fn(self, request.into_inner()).await
1900 }
1901
1902 async fn provide_code_actions(
1903 &self,
1904
1905 request:Request<ProvideCodeActionsRequest>,
1906 ) -> Result<Response<ProvideCodeActionsResponse>, Status> {
1907 Provider::ProvideCodeActions::Fn(self, request.into_inner()).await
1908 }
1909
1910 async fn show_text_document(
1911 &self,
1912
1913 request:Request<ShowTextDocumentRequest>,
1914 ) -> Result<Response<ShowTextDocumentResponse>, Status> {
1915 Window::ShowTextDocument::Fn(self, request.into_inner()).await
1916 }
1917
1918 async fn show_information_message(
1919 &self,
1920
1921 request:Request<ShowMessageRequest>,
1922 ) -> Result<Response<ShowMessageResponse>, Status> {
1923 Window::ShowInformationMessage::Fn(self, request.into_inner()).await
1924 }
1925
1926 async fn show_warning_message(
1927 &self,
1928
1929 request:Request<ShowMessageRequest>,
1930 ) -> Result<Response<ShowMessageResponse>, Status> {
1931 Window::ShowWarningMessage::Fn(self, request.into_inner()).await
1932 }
1933
1934 async fn show_error_message(
1935 &self,
1936
1937 request:Request<ShowMessageRequest>,
1938 ) -> Result<Response<ShowMessageResponse>, Status> {
1939 Window::ShowErrorMessage::Fn(self, request.into_inner()).await
1940 }
1941
1942 async fn create_status_bar_item(
1943 &self,
1944
1945 request:Request<CreateStatusBarItemRequest>,
1946 ) -> Result<Response<CreateStatusBarItemResponse>, Status> {
1947 Window::CreateStatusBarItem::Fn(self, request.into_inner()).await
1948 }
1949
1950 async fn set_status_bar_text(&self, request:Request<SetStatusBarTextRequest>) -> Result<Response<Empty>, Status> {
1951 Window::SetStatusBarText::Fn(self, request.into_inner()).await
1952 }
1953
1954 async fn create_webview_panel(
1955 &self,
1956
1957 request:Request<CreateWebviewPanelRequest>,
1958 ) -> Result<Response<CreateWebviewPanelResponse>, Status> {
1959 Window::CreateWebviewPanel::Fn(self, request.into_inner()).await
1960 }
1961
1962 async fn set_webview_html(&self, request:Request<SetWebviewHtmlRequest>) -> Result<Response<Empty>, Status> {
1963 Window::SetWebviewHtml::Fn(self, request.into_inner()).await
1964 }
1965
1966 async fn on_did_receive_message(
1967 &self,
1968
1969 request:Request<OnDidReceiveMessageRequest>,
1970 ) -> Result<Response<Empty>, Status> {
1971 Window::OnDidReceiveMessage::Fn(self, request.into_inner()).await
1972 }
1973
1974 async fn post_webview_message(
1975 &self,
1976
1977 request:Request<PostWebviewMessageRequest>,
1978 ) -> Result<Response<Empty>, Status> {
1979 Window::PostWebviewMessage::Fn(self, request.into_inner()).await
1980 }
1981
1982 async fn dispose_webview_panel(
1983 &self,
1984
1985 request:Request<DisposeWebviewPanelRequest>,
1986 ) -> Result<Response<Empty>, Status> {
1987 Window::DisposeWebviewPanel::Fn(self, request.into_inner()).await
1988 }
1989
1990 async fn read_file(&self, request:Request<ReadFileRequest>) -> Result<Response<ReadFileResponse>, Status> {
1991 FileSystem::ReadFile::Fn(self, request.into_inner()).await
1992 }
1993
1994 async fn write_file(&self, request:Request<WriteFileRequest>) -> Result<Response<Empty>, Status> {
1995 FileSystem::WriteFile::Fn(self, request.into_inner()).await
1996 }
1997
1998 async fn stat(&self, request:Request<StatRequest>) -> Result<Response<StatResponse>, Status> {
1999 FileSystem::Stat::Fn(self, request.into_inner()).await
2000 }
2001
2002 async fn readdir(&self, request:Request<ReaddirRequest>) -> Result<Response<ReaddirResponse>, Status> {
2003 FileSystem::Readdir::Fn(self, request.into_inner()).await
2004 }
2005
2006 async fn watch_file(&self, request:Request<WatchFileRequest>) -> Result<Response<Empty>, Status> {
2007 FileSystem::WatchFile::Fn(self, request.into_inner()).await
2008 }
2009
2010 async fn find_files(&self, request:Request<FindFilesRequest>) -> Result<Response<FindFilesResponse>, Status> {
2011 FileSystem::FindFiles::Fn(self, request.into_inner()).await
2012 }
2013
2014 async fn find_text_in_files(
2015 &self,
2016
2017 request:Request<FindTextInFilesRequest>,
2018 ) -> Result<Response<FindTextInFilesResponse>, Status> {
2019 FileSystem::FindTextInFiles::Fn(self, request.into_inner()).await
2020 }
2021
2022 async fn delete_file(&self, request:Request<DeleteFileRequest>) -> Result<Response<Empty>, Status> {
2023 FileSystem::DeleteFile::Fn(self, request.into_inner()).await
2024 }
2025
2026 async fn rename_file(&self, request:Request<RenameFileRequest>) -> Result<Response<Empty>, Status> {
2027 FileSystem::RenameFile::Fn(self, request.into_inner()).await
2028 }
2029
2030 async fn copy_file(&self, request:Request<CopyFileRequest>) -> Result<Response<Empty>, Status> {
2031 FileSystem::CopyFile::Fn(self, request.into_inner()).await
2032 }
2033
2034 async fn create_directory(&self, request:Request<CreateDirectoryRequest>) -> Result<Response<Empty>, Status> {
2035 FileSystem::CreateDirectory::Fn(self, request.into_inner()).await
2036 }
2037
2038 async fn open_document(
2039 &self,
2040
2041 request:Request<OpenDocumentRequest>,
2042 ) -> Result<Response<OpenDocumentResponse>, Status> {
2043 Workspace::OpenDocument::Fn(self, request.into_inner()).await
2044 }
2045
2046 async fn save_all(&self, request:Request<SaveAllRequest>) -> Result<Response<SaveAllResponse>, Status> {
2047 Workspace::SaveAll::Fn(self, request.into_inner()).await
2048 }
2049
2050 async fn apply_edit(&self, request:Request<ApplyEditRequest>) -> Result<Response<ApplyEditResponse>, Status> {
2051 Workspace::ApplyEdit::Fn(self, request.into_inner()).await
2052 }
2053
2054 async fn update_configuration(
2055 &self,
2056
2057 request:Request<UpdateConfigurationRequest>,
2058 ) -> Result<Response<Empty>, Status> {
2059 Workspace::UpdateConfiguration::Fn(self, request.into_inner()).await
2060 }
2061
2062 async fn update_workspace_folders(
2063 &self,
2064
2065 request:Request<UpdateWorkspaceFoldersRequest>,
2066 ) -> Result<Response<Empty>, Status> {
2067 Workspace::UpdateWorkspaceFolders::Fn(self, request.into_inner()).await
2068 }
2069
2070 async fn open_terminal(&self, request:Request<OpenTerminalRequest>) -> Result<Response<Empty>, Status> {
2071 Terminal::OpenTerminal::Fn(self, request.into_inner()).await
2072 }
2073
2074 async fn terminal_input(&self, request:Request<TerminalInputRequest>) -> Result<Response<Empty>, Status> {
2075 Terminal::TerminalInput::Fn(self, request.into_inner()).await
2076 }
2077
2078 async fn close_terminal(&self, request:Request<CloseTerminalRequest>) -> Result<Response<Empty>, Status> {
2079 Terminal::CloseTerminal::Fn(self, request.into_inner()).await
2080 }
2081
2082 async fn accept_terminal_opened(
2083 &self,
2084
2085 request:Request<TerminalOpenedNotification>,
2086 ) -> Result<Response<Empty>, Status> {
2087 Terminal::AcceptTerminalOpened::Fn(self, request.into_inner()).await
2088 }
2089
2090 async fn accept_terminal_closed(
2091 &self,
2092
2093 request:Request<TerminalClosedNotification>,
2094 ) -> Result<Response<Empty>, Status> {
2095 Terminal::AcceptTerminalClosed::Fn(self, request.into_inner()).await
2096 }
2097
2098 async fn accept_terminal_process_id(
2099 &self,
2100
2101 request:Request<TerminalProcessIdNotification>,
2102 ) -> Result<Response<Empty>, Status> {
2103 Terminal::AcceptTerminalProcessId::Fn(self, request.into_inner()).await
2104 }
2105
2106 async fn accept_terminal_process_data(
2107 &self,
2108
2109 request:Request<TerminalDataNotification>,
2110 ) -> Result<Response<Empty>, Status> {
2111 Terminal::AcceptTerminalProcessData::Fn(self, request.into_inner()).await
2112 }
2113
2114 async fn resize_terminal(&self, request:Request<ResizeTerminalRequest>) -> Result<Response<Empty>, Status> {
2115 Terminal::ResizeTerminal::Fn(self, request.into_inner()).await
2116 }
2117
2118 async fn register_tree_view_provider(
2119 &self,
2120
2121 request:Request<RegisterTreeViewProviderRequest>,
2122 ) -> Result<Response<Empty>, Status> {
2123 TreeView::RegisterTreeViewProvider::Fn(self, request.into_inner()).await
2124 }
2125
2126 async fn get_tree_children(
2127 &self,
2128
2129 request:Request<GetTreeChildrenRequest>,
2130 ) -> Result<Response<GetTreeChildrenResponse>, Status> {
2131 TreeView::GetTreeChildren::Fn(self, request.into_inner()).await
2132 }
2133
2134 async fn register_scm_provider(
2135 &self,
2136
2137 request:Request<RegisterScmProviderRequest>,
2138 ) -> Result<Response<Empty>, Status> {
2139 SCM::RegisterScmProvider::Fn(self, request.into_inner()).await
2140 }
2141
2142 async fn update_scm_group(&self, request:Request<UpdateScmGroupRequest>) -> Result<Response<Empty>, Status> {
2143 SCM::UpdateScmGroup::Fn(self, request.into_inner()).await
2144 }
2145
2146 async fn git_exec(&self, request:Request<GitExecRequest>) -> Result<Response<GitExecResponse>, Status> {
2147 SCM::GitExec::Fn(self, request.into_inner()).await
2148 }
2149
2150 async fn register_debug_adapter(
2151 &self,
2152
2153 request:Request<RegisterDebugAdapterRequest>,
2154 ) -> Result<Response<Empty>, Status> {
2155 Debug::RegisterDebugAdapter::Fn(self, request.into_inner()).await
2156 }
2157
2158 async fn start_debugging(
2159 &self,
2160
2161 request:Request<StartDebuggingRequest>,
2162 ) -> Result<Response<StartDebuggingResponse>, Status> {
2163 Debug::StartDebugging::Fn(self, request.into_inner()).await
2164 }
2165
2166 async fn stop_debugging(&self, request:Request<StopDebuggingRequest>) -> Result<Response<Empty>, Status> {
2167 Debug::StopDebugging::Fn(self, request.into_inner()).await
2168 }
2169
2170 async fn participate_in_save(
2171 &self,
2172
2173 request:Request<ParticipateInSaveRequest>,
2174 ) -> Result<Response<ParticipateInSaveResponse>, Status> {
2175 Save::ParticipateInSave(self, request.into_inner()).await
2176 }
2177
2178 async fn get_secret(&self, request:Request<GetSecretRequest>) -> Result<Response<GetSecretResponse>, Status> {
2179 Secret::GetSecret::Fn(self, request.into_inner()).await
2180 }
2181
2182 async fn store_secret(&self, request:Request<StoreSecretRequest>) -> Result<Response<Empty>, Status> {
2183 Secret::StoreSecret::Fn(self, request.into_inner()).await
2184 }
2185
2186 async fn delete_secret(&self, request:Request<DeleteSecretRequest>) -> Result<Response<Empty>, Status> {
2187 Secret::DeleteSecret::Fn(self, request.into_inner()).await
2188 }
2189
2190 async fn register_document_highlight_provider(
2191 &self,
2192
2193 request:Request<RegisterProviderRequest>,
2194 ) -> Result<Response<Empty>, Status> {
2195 Provider::RegisterDocumentHighlightProvider::Fn(self, request.into_inner()).await
2196 }
2197
2198 async fn provide_document_highlights(
2199 &self,
2200
2201 request:Request<ProvideDocumentHighlightsRequest>,
2202 ) -> Result<Response<ProvideDocumentHighlightsResponse>, Status> {
2203 Provider::ProvideDocumentHighlights::Fn(self, request.into_inner()).await
2204 }
2205
2206 async fn register_document_symbol_provider(
2207 &self,
2208
2209 request:Request<RegisterProviderRequest>,
2210 ) -> Result<Response<Empty>, Status> {
2211 Provider::RegisterDocumentSymbolProvider::Fn(self, request.into_inner()).await
2212 }
2213
2214 async fn provide_document_symbols(
2215 &self,
2216
2217 request:Request<ProvideDocumentSymbolsRequest>,
2218 ) -> Result<Response<ProvideDocumentSymbolsResponse>, Status> {
2219 Provider::ProvideDocumentSymbols::Fn(self, request.into_inner()).await
2220 }
2221
2222 async fn register_workspace_symbol_provider(
2223 &self,
2224
2225 request:Request<RegisterProviderRequest>,
2226 ) -> Result<Response<Empty>, Status> {
2227 Provider::RegisterWorkspaceSymbolProvider::Fn(self, request.into_inner()).await
2228 }
2229
2230 async fn provide_workspace_symbols(
2231 &self,
2232
2233 request:Request<ProvideWorkspaceSymbolsRequest>,
2234 ) -> Result<Response<ProvideWorkspaceSymbolsResponse>, Status> {
2235 Provider::ProvideWorkspaceSymbols::Fn(self, request.into_inner()).await
2236 }
2237
2238 async fn register_rename_provider(
2239 &self,
2240
2241 request:Request<RegisterProviderRequest>,
2242 ) -> Result<Response<Empty>, Status> {
2243 Provider::RegisterRenameProvider::Fn(self, request.into_inner()).await
2244 }
2245
2246 async fn provide_rename_edits(
2247 &self,
2248
2249 request:Request<ProvideRenameEditsRequest>,
2250 ) -> Result<Response<ProvideRenameEditsResponse>, Status> {
2251 Provider::ProvideRenameEdits::Fn(self, request.into_inner()).await
2252 }
2253
2254 async fn register_document_formatting_provider(
2255 &self,
2256
2257 request:Request<RegisterProviderRequest>,
2258 ) -> Result<Response<Empty>, Status> {
2259 Provider::RegisterDocumentFormattingProvider::Fn(self, request.into_inner()).await
2260 }
2261
2262 async fn provide_document_formatting(
2263 &self,
2264
2265 request:Request<ProvideDocumentFormattingRequest>,
2266 ) -> Result<Response<ProvideDocumentFormattingResponse>, Status> {
2267 Provider::ProvideDocumentFormatting::Fn(self, request.into_inner()).await
2268 }
2269
2270 async fn register_document_range_formatting_provider(
2271 &self,
2272
2273 request:Request<RegisterProviderRequest>,
2274 ) -> Result<Response<Empty>, Status> {
2275 Provider::RegisterDocumentRangeFormattingProvider::Fn(self, request.into_inner()).await
2276 }
2277
2278 async fn provide_document_range_formatting(
2279 &self,
2280
2281 request:Request<ProvideDocumentRangeFormattingRequest>,
2282 ) -> Result<Response<ProvideDocumentRangeFormattingResponse>, Status> {
2283 Provider::ProvideDocumentRangeFormatting::Fn(self, request.into_inner()).await
2284 }
2285
2286 async fn register_on_type_formatting_provider(
2287 &self,
2288
2289 request:Request<RegisterOnTypeFormattingProviderRequest>,
2290 ) -> Result<Response<Empty>, Status> {
2291 Provider::RegisterOnTypeFormattingProvider::Fn(self, request.into_inner()).await
2292 }
2293
2294 async fn provide_on_type_formatting(
2295 &self,
2296
2297 request:Request<ProvideOnTypeFormattingRequest>,
2298 ) -> Result<Response<ProvideOnTypeFormattingResponse>, Status> {
2299 Provider::ProvideOnTypeFormatting::Fn(self, request.into_inner()).await
2300 }
2301
2302 async fn register_signature_help_provider(
2303 &self,
2304
2305 request:Request<RegisterSignatureHelpProviderRequest>,
2306 ) -> Result<Response<Empty>, Status> {
2307 Provider::RegisterSignatureHelpProvider::Fn(self, request.into_inner()).await
2308 }
2309
2310 async fn provide_signature_help(
2311 &self,
2312
2313 request:Request<ProvideSignatureHelpRequest>,
2314 ) -> Result<Response<ProvideSignatureHelpResponse>, Status> {
2315 Provider::ProvideSignatureHelp::Fn(self, request.into_inner()).await
2316 }
2317
2318 async fn register_code_lens_provider(
2319 &self,
2320
2321 request:Request<RegisterProviderRequest>,
2322 ) -> Result<Response<Empty>, Status> {
2323 Provider::RegisterCodeLensProvider::Fn(self, request.into_inner()).await
2324 }
2325
2326 async fn provide_code_lenses(
2327 &self,
2328
2329 request:Request<ProvideCodeLensesRequest>,
2330 ) -> Result<Response<ProvideCodeLensesResponse>, Status> {
2331 Provider::ProvideCodeLenses::Fn(self, request.into_inner()).await
2332 }
2333
2334 async fn register_folding_range_provider(
2335 &self,
2336
2337 request:Request<RegisterProviderRequest>,
2338 ) -> Result<Response<Empty>, Status> {
2339 Provider::RegisterFoldingRangeProvider::Fn(self, request.into_inner()).await
2340 }
2341
2342 async fn provide_folding_ranges(
2343 &self,
2344
2345 request:Request<ProvideFoldingRangesRequest>,
2346 ) -> Result<Response<ProvideFoldingRangesResponse>, Status> {
2347 Provider::ProvideFoldingRanges::Fn(self, request.into_inner()).await
2348 }
2349
2350 async fn register_selection_range_provider(
2351 &self,
2352
2353 request:Request<RegisterProviderRequest>,
2354 ) -> Result<Response<Empty>, Status> {
2355 Provider::RegisterSelectionRangeProvider::Fn(self, request.into_inner()).await
2356 }
2357
2358 async fn provide_selection_ranges(
2359 &self,
2360
2361 request:Request<ProvideSelectionRangesRequest>,
2362 ) -> Result<Response<ProvideSelectionRangesResponse>, Status> {
2363 Provider::ProvideSelectionRanges::Fn(self, request.into_inner()).await
2364 }
2365
2366 async fn register_semantic_tokens_provider(
2367 &self,
2368
2369 request:Request<RegisterSemanticTokensProviderRequest>,
2370 ) -> Result<Response<Empty>, Status> {
2371 Provider::RegisterSemanticTokensProvider::Fn(self, request.into_inner()).await
2372 }
2373
2374 async fn provide_semantic_tokens_full(
2375 &self,
2376
2377 request:Request<ProvideSemanticTokensRequest>,
2378 ) -> Result<Response<ProvideSemanticTokensResponse>, Status> {
2379 Provider::ProvideSemanticTokensFull::Fn(self, request.into_inner()).await
2380 }
2381
2382 async fn register_inlay_hints_provider(
2383 &self,
2384
2385 request:Request<RegisterProviderRequest>,
2386 ) -> Result<Response<Empty>, Status> {
2387 Provider::RegisterInlayHintsProvider::Fn(self, request.into_inner()).await
2388 }
2389
2390 async fn provide_inlay_hints(
2391 &self,
2392
2393 request:Request<ProvideInlayHintsRequest>,
2394 ) -> Result<Response<ProvideInlayHintsResponse>, Status> {
2395 Provider::ProvideInlayHints::Fn(self, request.into_inner()).await
2396 }
2397
2398 async fn register_type_hierarchy_provider(
2399 &self,
2400
2401 request:Request<RegisterProviderRequest>,
2402 ) -> Result<Response<Empty>, Status> {
2403 Provider::RegisterTypeHierarchyProvider::Fn(self, request.into_inner()).await
2404 }
2405
2406 async fn provide_type_hierarchy_supertypes(
2407 &self,
2408
2409 request:Request<ProvideTypeHierarchyRequest>,
2410 ) -> Result<Response<ProvideTypeHierarchyResponse>, Status> {
2411 Provider::ProvideTypeHierarchySupertypes::Fn(self, request.into_inner()).await
2412 }
2413
2414 async fn provide_type_hierarchy_subtypes(
2415 &self,
2416
2417 request:Request<ProvideTypeHierarchyRequest>,
2418 ) -> Result<Response<ProvideTypeHierarchyResponse>, Status> {
2419 Provider::ProvideTypeHierarchySubtypes::Fn(self, request.into_inner()).await
2420 }
2421
2422 async fn register_call_hierarchy_provider(
2423 &self,
2424
2425 request:Request<RegisterProviderRequest>,
2426 ) -> Result<Response<Empty>, Status> {
2427 Provider::RegisterCallHierarchyProvider::Fn(self, request.into_inner()).await
2428 }
2429
2430 async fn provide_call_hierarchy_incoming_calls(
2431 &self,
2432
2433 request:Request<ProvideCallHierarchyRequest>,
2434 ) -> Result<Response<ProvideCallHierarchyResponse>, Status> {
2435 Provider::ProvideCallHierarchyIncomingCalls::Fn(self, request.into_inner()).await
2436 }
2437
2438 async fn provide_call_hierarchy_outgoing_calls(
2439 &self,
2440
2441 request:Request<ProvideCallHierarchyRequest>,
2442 ) -> Result<Response<ProvideCallHierarchyResponse>, Status> {
2443 Provider::ProvideCallHierarchyOutgoingCalls::Fn(self, request.into_inner()).await
2444 }
2445
2446 async fn register_linked_editing_range_provider(
2447 &self,
2448
2449 request:Request<RegisterProviderRequest>,
2450 ) -> Result<Response<Empty>, Status> {
2451 Provider::RegisterLinkedEditingRangeProvider::Fn(self, request.into_inner()).await
2452 }
2453
2454 async fn provide_linked_editing_ranges(
2455 &self,
2456
2457 request:Request<ProvideLinkedEditingRangesRequest>,
2458 ) -> Result<Response<ProvideLinkedEditingRangesResponse>, Status> {
2459 Provider::ProvideLinkedEditingRanges::Fn(self, request.into_inner()).await
2460 }
2461
2462 async fn show_quick_pick(
2463 &self,
2464
2465 request:Request<ShowQuickPickRequest>,
2466 ) -> Result<Response<ShowQuickPickResponse>, Status> {
2467 Window::ShowQuickPick::Fn(self, request.into_inner()).await
2468 }
2469
2470 async fn show_input_box(
2471 &self,
2472
2473 request:Request<ShowInputBoxRequest>,
2474 ) -> Result<Response<ShowInputBoxResponse>, Status> {
2475 Window::ShowInputBox::Fn(self, request.into_inner()).await
2476 }
2477
2478 async fn show_progress(
2479 &self,
2480
2481 request:Request<ShowProgressRequest>,
2482 ) -> Result<Response<ShowProgressResponse>, Status> {
2483 Window::ShowProgress::Fn(self, request.into_inner()).await
2484 }
2485
2486 async fn report_progress(&self, request:Request<ReportProgressRequest>) -> Result<Response<Empty>, Status> {
2487 Window::ReportProgress::Fn(self, request.into_inner()).await
2488 }
2489
2490 async fn open_external(&self, request:Request<OpenExternalRequest>) -> Result<Response<Empty>, Status> {
2491 Window::OpenExternal::Fn(self, request.into_inner()).await
2492 }
2493
2494 async fn create_output_channel(
2495 &self,
2496
2497 request:Request<CreateOutputChannelRequest>,
2498 ) -> Result<Response<CreateOutputChannelResponse>, Status> {
2499 Output::CreateOutputChannel::Fn(self, request.into_inner()).await
2500 }
2501
2502 async fn append_output(&self, request:Request<AppendOutputRequest>) -> Result<Response<Empty>, Status> {
2503 Output::AppendOutput::Fn(self, request.into_inner()).await
2504 }
2505
2506 async fn clear_output(&self, request:Request<ClearOutputRequest>) -> Result<Response<Empty>, Status> {
2507 Output::ClearOutput::Fn(self, request.into_inner()).await
2508 }
2509
2510 async fn show_output(&self, request:Request<ShowOutputRequest>) -> Result<Response<Empty>, Status> {
2511 Output::ShowOutput::Fn(self, request.into_inner()).await
2512 }
2513
2514 async fn dispose_output(&self, request:Request<DisposeOutputRequest>) -> Result<Response<Empty>, Status> {
2515 Output::DisposeOutput::Fn(self, request.into_inner()).await
2516 }
2517
2518 async fn register_task_provider(
2519 &self,
2520
2521 request:Request<RegisterTaskProviderRequest>,
2522 ) -> Result<Response<Empty>, Status> {
2523 Task::RegisterTaskProvider::Fn(self, request.into_inner()).await
2524 }
2525
2526 async fn execute_task(&self, request:Request<ExecuteTaskRequest>) -> Result<Response<ExecuteTaskResponse>, Status> {
2527 Task::ExecuteTask::Fn(self, request.into_inner()).await
2528 }
2529
2530 async fn terminate_task(&self, request:Request<TerminateTaskRequest>) -> Result<Response<Empty>, Status> {
2531 Task::TerminateTask::Fn(self, request.into_inner()).await
2532 }
2533
2534 async fn get_authentication_session(
2535 &self,
2536
2537 request:Request<GetAuthenticationSessionRequest>,
2538 ) -> Result<Response<GetAuthenticationSessionResponse>, Status> {
2539 Auth::GetAuthenticationSession::Fn(self, request.into_inner()).await
2540 }
2541
2542 async fn register_authentication_provider(
2543 &self,
2544
2545 request:Request<RegisterAuthenticationProviderRequest>,
2546 ) -> Result<Response<Empty>, Status> {
2547 Auth::RegisterAuthenticationProvider::Fn(self, request.into_inner()).await
2548 }
2549
2550 async fn get_extension(
2551 &self,
2552
2553 request:Request<GetExtensionRequest>,
2554 ) -> Result<Response<GetExtensionResponse>, Status> {
2555 Extension::GetExtension::Fn(self, request.into_inner()).await
2556 }
2557
2558 async fn get_all_extensions(&self, request:Request<Empty>) -> Result<Response<GetAllExtensionsResponse>, Status> {
2559 Extension::GetAllExtensions::Fn(self, request.into_inner()).await
2560 }
2561
2562 async fn get_configuration(
2563 &self,
2564
2565 request:Request<GetConfigurationRequest>,
2566 ) -> Result<Response<GetConfigurationResponse>, Status> {
2567 Extension::GetConfiguration::Fn(self, request.into_inner()).await
2568 }
2569}