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