Skip to main content

Mountain/RPC/CocoonService/
mod.rs

1#![allow(unused_variables, dead_code, unused_imports)]
2
3// # CocoonServiceImpl - thin-wrapper dispatcher
4//
5// Domain files hold all typed RPC implementations. This module keeps:
6// - CocoonServiceImpl struct + helper methods
7// - process_mountain_request (legacy generic router, ~600 lines)
8// - send_mountain_notification (push dispatcher, ~400 lines)
9// - One-line delegates for all 78 typed RPCs
10
11pub 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};
84// Import generated protobuf types
85use crate::dev_log;
86use crate::Vine::Generated::{
87	// Service trait
88	// Extended Language + Window + FS + Output + Task + Auth + Debug + Extension types
89	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	// Common types
114	Empty,
115	ExecuteCommandRequest,
116	ExecuteCommandResponse,
117	ExecuteTaskRequest,
118	ExecuteTaskResponse,
119	ExtensionInfo,
120	// Workspace Operations
121	FindFilesRequest,
122	FindFilesResponse,
123	FindTextInFilesRequest,
124	FindTextInFilesResponse,
125	GenericNotification as GenericNotificationMsg,
126	// Common generic types
127	GenericRequest as GenericRequestMsg,
128	GenericResponse,
129	GetAllExtensionsResponse,
130	GetAuthenticationSessionRequest,
131	GetAuthenticationSessionResponse,
132	GetConfigurationRequest,
133	GetConfigurationResponse,
134	GetExtensionRequest,
135	GetExtensionResponse,
136	// Secret Storage
137	GetSecretRequest,
138	GetSecretResponse,
139	GetTreeChildrenRequest,
140	GetTreeChildrenResponse,
141	GitExecRequest,
142	GitExecResponse,
143
144	// Initialization
145	InitExtensionHostRequest,
146
147	Location,
148	OnDidReceiveMessageRequest,
149
150	OpenDocumentRequest,
151	OpenDocumentResponse,
152	OpenExternalRequest,
153	// Terminal
154	OpenTerminalRequest,
155	// Save Participants
156	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	ProvideInlineCompletionRequest,
185	ProvideInlineCompletionResponse,
186	ProvideLinkedEditingRangesRequest,
187	ProvideLinkedEditingRangesResponse,
188	ProvideOnTypeFormattingRequest,
189	ProvideOnTypeFormattingResponse,
190	ProvideReferencesRequest,
191	ProvideReferencesResponse,
192	ProvideRenameEditsRequest,
193	ProvideRenameEditsResponse,
194	ProvideSelectionRangesRequest,
195	ProvideSelectionRangesResponse,
196	ProvideSemanticTokensRequest,
197	ProvideSemanticTokensResponse,
198	ProvideSignatureHelpRequest,
199	ProvideSignatureHelpResponse,
200	ProvideTypeHierarchyRequest,
201	ProvideTypeHierarchyResponse,
202	ProvideWorkspaceSymbolsRequest,
203	ProvideWorkspaceSymbolsResponse,
204	Range,
205	// File System
206	ReadFileRequest,
207	ReadFileResponse,
208	ReaddirRequest,
209	ReaddirResponse,
210	RegisterAuthenticationProviderRequest,
211	// Commands
212	RegisterCommandRequest,
213	// Debug
214	RegisterDebugAdapterRequest,
215	RegisterOnTypeFormattingProviderRequest,
216	// Language Features
217	RegisterProviderRequest,
218	// SCM
219	RegisterScmProviderRequest,
220	RegisterSemanticTokensProviderRequest,
221	RegisterSignatureHelpProviderRequest,
222	RegisterTaskProviderRequest,
223	// Tree View
224	RegisterTreeViewProviderRequest,
225	RenameFileRequest,
226	ReportProgressRequest,
227	ResizeTerminalRequest,
228	RpcError,
229	SaveAllRequest,
230	SaveAllResponse,
231	SetStatusBarTextRequest,
232	SetWebviewHtmlRequest,
233	ShowInputBoxRequest,
234	ShowInputBoxResponse,
235	ShowMessageRequest,
236	ShowMessageResponse,
237	ShowOutputRequest,
238	ShowProgressRequest,
239	ShowProgressResponse,
240	ShowQuickPickRequest,
241	ShowQuickPickResponse,
242	// Window Operations
243	ShowTextDocumentRequest,
244	ShowTextDocumentResponse,
245	SourceControlResourceState,
246	StartDebuggingRequest,
247	StartDebuggingResponse,
248
249	StatRequest,
250	StatResponse,
251	StopDebuggingRequest,
252	StoreSecretRequest,
253	TerminalClosedNotification,
254	TerminalDataNotification,
255
256	TerminalInputRequest,
257	TerminalOpenedNotification,
258	TerminalProcessIdNotification,
259	TerminateTaskRequest,
260	TextDocumentSaveReason,
261	TextEdit,
262	TextEditForSave,
263
264	TextMatch,
265	TreeItem,
266
267	UnregisterCommandRequest,
268
269	UpdateConfigurationRequest,
270	UpdateScmGroupRequest,
271	UpdateWorkspaceFoldersRequest,
272
273	Uri,
274	ViewColumn,
275
276	WatchFileRequest,
277
278	WorkspaceFolder,
279	WriteFileRequest,
280
281	cocoon_service_server::CocoonService,
282	on_did_receive_message_request,
283	post_webview_message_request,
284};
285
286/// Implementation of the CocoonService gRPC server
287///
288/// This struct handles all incoming requests from the Cocoon extension host
289/// sidecar and dispatches them to the appropriate Mountain services.
290#[derive(Clone)]
291pub struct CocoonServiceImpl {
292	/// Mountain environment providing access to all services
293	environment:Arc<MountainEnvironment>,
294
295	/// Registry of active operations with their cancellation tokens
296	/// Maps request ID to cancellation token for operation cancellation
297	ActiveOperations:Arc<RwLock<HashMap<u64, tokio_util::sync::CancellationToken>>>,
298}
299
300impl CocoonServiceImpl {
301	/// Creates a new instance of the CocoonService server
302	///
303	/// # Parameters
304	/// - `environment`: Mountain environment with access to all services
305	///
306	/// # Returns
307	/// A new CocoonService instance
308	pub fn new(environment:Arc<MountainEnvironment>) -> Self {
309		dev_log!("cocoon", "[CocoonService] New instance created");
310
311		Self { environment, ActiveOperations:Arc::new(RwLock::new(HashMap::new())) }
312	}
313
314	/// Registers an operation for potential cancellation
315	///
316	/// # Parameters
317	/// - `request_id`: The request identifier for the operation
318	///
319	/// # Returns
320	/// A cancellation token that can be used to cancel the operation
321	pub async fn RegisterOperation(&self, request_id:u64) -> tokio_util::sync::CancellationToken {
322		let token = tokio_util::sync::CancellationToken::new();
323
324		self.ActiveOperations.write().await.insert(request_id, token.clone());
325
326		dev_log!("cocoon", "[CocoonService] Registered operation {} for cancellation", request_id);
327
328		token
329	}
330
331	/// Unregisters an operation after completion
332	///
333	/// # Parameters
334	/// - `request_id`: The request identifier to unregister
335	pub async fn UnregisterOperation(&self, request_id:u64) {
336		self.ActiveOperations.write().await.remove(&request_id);
337
338		dev_log!("cocoon", "[CocoonService] Unregistered operation {}", request_id);
339	}
340
341	/// Registers a language feature provider in ApplicationState.
342	///
343	/// Converts the gRPC request fields into a `ProviderRegistrationDTO` and
344	/// stores it in `ApplicationState.Extension.ProviderRegistration`.
345	///
346	/// # Parameters
347	/// - `handle`: Unique provider handle
348	/// - `provider_type`: The type of language feature
349	/// - `language_selector`: Language scope (e.g. "typescript")
350	/// - `extension_id`: Extension that registered this provider
351	fn RegisterProvider(&self, handle:u32, provider_type:ProviderType, language_selector:&str, extension_id:&str) {
352		// SideCarIdentifier = "cocoon-main" so FeatureMethods::invoke_provider can
353		// route back via Vine::Client::SendRequestToSideCar("cocoon-main", ...).
354		// Selector stored as array so ProviderLookup::get_matching_provider's
355		// `.as_array()` call finds the language entry: [{ "language": "typescript" }].
356		let dto = ProviderRegistrationDTO {
357			Handle:handle,
358
359			ProviderType:provider_type,
360
361			Selector:json!([{ "language": language_selector }]),
362
363			SideCarIdentifier:"cocoon-main".to_string(),
364
365			ExtensionIdentifier:json!(extension_id),
366
367			Options:None,
368		};
369
370		self.environment
371			.ApplicationState
372			.Extension
373			.ProviderRegistration
374			.RegisterProvider(handle, dto);
375
376		dev_log!(
377			"cocoon",
378			"[CocoonService] Provider {:?} registered: handle={}, language={}",
379			provider_type,
380			handle,
381			language_selector
382		);
383	}
384
385	/// Extracts a filesystem path from a URI proto message.
386	///
387	/// Handles both `file://` URIs and bare paths. Returns `None` if the URI
388	/// is absent or the path cannot be extracted.
389	fn UriToPath(uri_opt:Option<&Uri>) -> Option<std::path::PathBuf> {
390		let value = uri_opt?.value.as_str();
391
392		if value.is_empty() {
393			return None;
394		}
395
396		// Strip file:// prefix if present
397		let path_str = if let Some(Stripped) = value.strip_prefix("file://") {
398			Stripped
399		} else if value.starts_with('/') || (value.len() > 1 && value.as_bytes()[1] == b':') {
400			// Bare absolute path (Unix or Windows)
401			value
402		} else {
403			// Unknown scheme - return as-is
404			value
405		};
406
407		Some(std::path::PathBuf::from(path_str))
408	}
409}
410
411#[async_trait]
412
413impl CocoonService for CocoonServiceImpl {
414	// LAND-PATCH B7-S6 P2: bidirectional streaming channel mirror.
415	// Stub matching MountainService::open_channel_from_cocoon. The
416	// multiplexer wiring lands with Patch 14; until then this
417	// returns `Unimplemented` and callers fall back to the unary
418	// methods.
419	type OpenChannelFromMountainStream = std::pin::Pin<
420		Box<
421			dyn tonic::codegen::tokio_stream::Stream<Item = Result<crate::Vine::Generated::Envelope, tonic::Status>>
422				+ Send
423				+ 'static,
424		>,
425	>;
426
427	async fn open_channel_from_mountain(
428		&self,
429
430		_request:tonic::Request<tonic::Streaming<crate::Vine::Generated::Envelope>>,
431	) -> Result<tonic::Response<Self::OpenChannelFromMountainStream>, tonic::Status> {
432		Err(tonic::Status::unimplemented(
433			"OpenChannelFromMountain: streaming multiplexer not yet wired (Patch 14); use unary endpoints",
434		))
435	}
436
437	/// Process Mountain requests from Cocoon (generic request-response).
438	/// Implementation in `GenericRequest::Dispatcher`.
439	async fn process_mountain_request(
440		&self,
441
442		request:Request<GenericRequestMsg>,
443	) -> Result<Response<GenericResponse>, Status> {
444		return GenericRequest::Dispatcher::Fn(self, request).await;
445	}
446
447	/// Send Mountain notifications to Cocoon (generic fire-and-forget).
448	/// Implementation in `GenericNotification::Dispatcher`.
449	async fn send_mountain_notification(
450		&self,
451
452		request:Request<GenericNotificationMsg>,
453	) -> Result<Response<Empty>, Status> {
454		return GenericNotification::Dispatcher::Fn(self, request).await;
455	}
456
457	async fn cancel_operation(&self, request:Request<CancelOperationRequest>) -> Result<Response<Empty>, Status> {
458		Initialization::CancelOperation::Fn(self, request.into_inner()).await
459	}
460
461	async fn initial_handshake(&self, request:Request<Empty>) -> Result<Response<Empty>, Status> {
462		Initialization::InitialHandshake::Fn(self, request.into_inner()).await
463	}
464
465	async fn init_extension_host(&self, request:Request<InitExtensionHostRequest>) -> Result<Response<Empty>, Status> {
466		Initialization::InitExtensionHost::Fn(self, request.into_inner()).await
467	}
468
469	async fn register_command(&self, request:Request<RegisterCommandRequest>) -> Result<Response<Empty>, Status> {
470		Command::RegisterCommand::Fn(self, request.into_inner()).await
471	}
472
473	async fn execute_contributed_command(
474		&self,
475
476		request:Request<ExecuteCommandRequest>,
477	) -> Result<Response<ExecuteCommandResponse>, Status> {
478		Command::ExecuteContributedCommand::Fn(self, request.into_inner()).await
479	}
480
481	async fn unregister_command(&self, request:Request<UnregisterCommandRequest>) -> Result<Response<Empty>, Status> {
482		Command::UnregisterCommand::Fn(self, request.into_inner()).await
483	}
484
485	async fn register_hover_provider(
486		&self,
487
488		request:Request<RegisterProviderRequest>,
489	) -> Result<Response<Empty>, Status> {
490		Provider::RegisterHoverProvider::Fn(self, request.into_inner()).await
491	}
492
493	async fn provide_hover(
494		&self,
495
496		request:Request<ProvideHoverRequest>,
497	) -> Result<Response<ProvideHoverResponse>, Status> {
498		Provider::ProvideHover::Fn(self, request.into_inner()).await
499	}
500
501	async fn register_completion_item_provider(
502		&self,
503
504		request:Request<RegisterProviderRequest>,
505	) -> Result<Response<Empty>, Status> {
506		Provider::RegisterCompletionItemProvider::Fn(self, request.into_inner()).await
507	}
508
509	async fn provide_completion_items(
510		&self,
511
512		request:Request<ProvideCompletionItemsRequest>,
513	) -> Result<Response<ProvideCompletionItemsResponse>, Status> {
514		Provider::ProvideCompletionItems::Fn(self, request.into_inner()).await
515	}
516
517	async fn register_definition_provider(
518		&self,
519
520		request:Request<RegisterProviderRequest>,
521	) -> Result<Response<Empty>, Status> {
522		Provider::RegisterDefinitionProvider::Fn(self, request.into_inner()).await
523	}
524
525	async fn provide_definition(
526		&self,
527
528		request:Request<ProvideDefinitionRequest>,
529	) -> Result<Response<ProvideDefinitionResponse>, Status> {
530		Provider::ProvideDefinition::Fn(self, request.into_inner()).await
531	}
532
533	async fn register_reference_provider(
534		&self,
535
536		request:Request<RegisterProviderRequest>,
537	) -> Result<Response<Empty>, Status> {
538		Provider::RegisterReferenceProvider::Fn(self, request.into_inner()).await
539	}
540
541	async fn provide_references(
542		&self,
543
544		request:Request<ProvideReferencesRequest>,
545	) -> Result<Response<ProvideReferencesResponse>, Status> {
546		Provider::ProvideReferences::Fn(self, request.into_inner()).await
547	}
548
549	async fn register_code_actions_provider(
550		&self,
551
552		request:Request<RegisterProviderRequest>,
553	) -> Result<Response<Empty>, Status> {
554		Provider::RegisterCodeActionsProvider::Fn(self, request.into_inner()).await
555	}
556
557	async fn provide_code_actions(
558		&self,
559
560		request:Request<ProvideCodeActionsRequest>,
561	) -> Result<Response<ProvideCodeActionsResponse>, Status> {
562		Provider::ProvideCodeActions::Fn(self, request.into_inner()).await
563	}
564
565	async fn show_text_document(
566		&self,
567
568		request:Request<ShowTextDocumentRequest>,
569	) -> Result<Response<ShowTextDocumentResponse>, Status> {
570		Window::ShowTextDocument::Fn(self, request.into_inner()).await
571	}
572
573	async fn show_information_message(
574		&self,
575
576		request:Request<ShowMessageRequest>,
577	) -> Result<Response<ShowMessageResponse>, Status> {
578		Window::ShowInformationMessage::Fn(self, request.into_inner()).await
579	}
580
581	async fn show_warning_message(
582		&self,
583
584		request:Request<ShowMessageRequest>,
585	) -> Result<Response<ShowMessageResponse>, Status> {
586		Window::ShowWarningMessage::Fn(self, request.into_inner()).await
587	}
588
589	async fn show_error_message(
590		&self,
591
592		request:Request<ShowMessageRequest>,
593	) -> Result<Response<ShowMessageResponse>, Status> {
594		Window::ShowErrorMessage::Fn(self, request.into_inner()).await
595	}
596
597	async fn create_status_bar_item(
598		&self,
599
600		request:Request<CreateStatusBarItemRequest>,
601	) -> Result<Response<CreateStatusBarItemResponse>, Status> {
602		Window::CreateStatusBarItem::Fn(self, request.into_inner()).await
603	}
604
605	async fn set_status_bar_text(&self, request:Request<SetStatusBarTextRequest>) -> Result<Response<Empty>, Status> {
606		Window::SetStatusBarText::Fn(self, request.into_inner()).await
607	}
608
609	async fn create_webview_panel(
610		&self,
611
612		request:Request<CreateWebviewPanelRequest>,
613	) -> Result<Response<CreateWebviewPanelResponse>, Status> {
614		Window::CreateWebviewPanel::Fn(self, request.into_inner()).await
615	}
616
617	async fn set_webview_html(&self, request:Request<SetWebviewHtmlRequest>) -> Result<Response<Empty>, Status> {
618		Window::SetWebviewHtml::Fn(self, request.into_inner()).await
619	}
620
621	async fn on_did_receive_message(
622		&self,
623
624		request:Request<OnDidReceiveMessageRequest>,
625	) -> Result<Response<Empty>, Status> {
626		Window::OnDidReceiveMessage::Fn(self, request.into_inner()).await
627	}
628
629	async fn post_webview_message(
630		&self,
631
632		request:Request<PostWebviewMessageRequest>,
633	) -> Result<Response<Empty>, Status> {
634		Window::PostWebviewMessage::Fn(self, request.into_inner()).await
635	}
636
637	async fn dispose_webview_panel(
638		&self,
639
640		request:Request<DisposeWebviewPanelRequest>,
641	) -> Result<Response<Empty>, Status> {
642		Window::DisposeWebviewPanel::Fn(self, request.into_inner()).await
643	}
644
645	async fn read_file(&self, request:Request<ReadFileRequest>) -> Result<Response<ReadFileResponse>, Status> {
646		FileSystem::ReadFile::Fn(self, request.into_inner()).await
647	}
648
649	async fn write_file(&self, request:Request<WriteFileRequest>) -> Result<Response<Empty>, Status> {
650		FileSystem::WriteFile::Fn(self, request.into_inner()).await
651	}
652
653	async fn stat(&self, request:Request<StatRequest>) -> Result<Response<StatResponse>, Status> {
654		FileSystem::Stat::Fn(self, request.into_inner()).await
655	}
656
657	async fn readdir(&self, request:Request<ReaddirRequest>) -> Result<Response<ReaddirResponse>, Status> {
658		FileSystem::Readdir::Fn(self, request.into_inner()).await
659	}
660
661	async fn watch_file(&self, request:Request<WatchFileRequest>) -> Result<Response<Empty>, Status> {
662		FileSystem::WatchFile::Fn(self, request.into_inner()).await
663	}
664
665	async fn find_files(&self, request:Request<FindFilesRequest>) -> Result<Response<FindFilesResponse>, Status> {
666		FileSystem::FindFiles::Fn(self, request.into_inner()).await
667	}
668
669	async fn find_text_in_files(
670		&self,
671
672		request:Request<FindTextInFilesRequest>,
673	) -> Result<Response<FindTextInFilesResponse>, Status> {
674		FileSystem::FindTextInFiles::Fn(self, request.into_inner()).await
675	}
676
677	async fn delete_file(&self, request:Request<DeleteFileRequest>) -> Result<Response<Empty>, Status> {
678		FileSystem::DeleteFile::Fn(self, request.into_inner()).await
679	}
680
681	async fn rename_file(&self, request:Request<RenameFileRequest>) -> Result<Response<Empty>, Status> {
682		FileSystem::RenameFile::Fn(self, request.into_inner()).await
683	}
684
685	async fn copy_file(&self, request:Request<CopyFileRequest>) -> Result<Response<Empty>, Status> {
686		FileSystem::CopyFile::Fn(self, request.into_inner()).await
687	}
688
689	async fn create_directory(&self, request:Request<CreateDirectoryRequest>) -> Result<Response<Empty>, Status> {
690		FileSystem::CreateDirectory::Fn(self, request.into_inner()).await
691	}
692
693	async fn open_document(
694		&self,
695
696		request:Request<OpenDocumentRequest>,
697	) -> Result<Response<OpenDocumentResponse>, Status> {
698		Workspace::OpenDocument::Fn(self, request.into_inner()).await
699	}
700
701	async fn save_all(&self, request:Request<SaveAllRequest>) -> Result<Response<SaveAllResponse>, Status> {
702		Workspace::SaveAll::Fn(self, request.into_inner()).await
703	}
704
705	async fn apply_edit(&self, request:Request<ApplyEditRequest>) -> Result<Response<ApplyEditResponse>, Status> {
706		Workspace::ApplyEdit::Fn(self, request.into_inner()).await
707	}
708
709	async fn update_configuration(
710		&self,
711
712		request:Request<UpdateConfigurationRequest>,
713	) -> Result<Response<Empty>, Status> {
714		Workspace::UpdateConfiguration::Fn(self, request.into_inner()).await
715	}
716
717	async fn update_workspace_folders(
718		&self,
719
720		request:Request<UpdateWorkspaceFoldersRequest>,
721	) -> Result<Response<Empty>, Status> {
722		Workspace::UpdateWorkspaceFolders::Fn(self, request.into_inner()).await
723	}
724
725	async fn open_terminal(&self, request:Request<OpenTerminalRequest>) -> Result<Response<Empty>, Status> {
726		Terminal::OpenTerminal::Fn(self, request.into_inner()).await
727	}
728
729	async fn terminal_input(&self, request:Request<TerminalInputRequest>) -> Result<Response<Empty>, Status> {
730		Terminal::TerminalInput::Fn(self, request.into_inner()).await
731	}
732
733	async fn close_terminal(&self, request:Request<CloseTerminalRequest>) -> Result<Response<Empty>, Status> {
734		Terminal::CloseTerminal::Fn(self, request.into_inner()).await
735	}
736
737	async fn accept_terminal_opened(
738		&self,
739
740		request:Request<TerminalOpenedNotification>,
741	) -> Result<Response<Empty>, Status> {
742		Terminal::AcceptTerminalOpened::Fn(self, request.into_inner()).await
743	}
744
745	async fn accept_terminal_closed(
746		&self,
747
748		request:Request<TerminalClosedNotification>,
749	) -> Result<Response<Empty>, Status> {
750		Terminal::AcceptTerminalClosed::Fn(self, request.into_inner()).await
751	}
752
753	async fn accept_terminal_process_id(
754		&self,
755
756		request:Request<TerminalProcessIdNotification>,
757	) -> Result<Response<Empty>, Status> {
758		Terminal::AcceptTerminalProcessId::Fn(self, request.into_inner()).await
759	}
760
761	async fn accept_terminal_process_data(
762		&self,
763
764		request:Request<TerminalDataNotification>,
765	) -> Result<Response<Empty>, Status> {
766		Terminal::AcceptTerminalProcessData::Fn(self, request.into_inner()).await
767	}
768
769	async fn resize_terminal(&self, request:Request<ResizeTerminalRequest>) -> Result<Response<Empty>, Status> {
770		Terminal::ResizeTerminal::Fn(self, request.into_inner()).await
771	}
772
773	async fn register_tree_view_provider(
774		&self,
775
776		request:Request<RegisterTreeViewProviderRequest>,
777	) -> Result<Response<Empty>, Status> {
778		TreeView::RegisterTreeViewProvider::Fn(self, request.into_inner()).await
779	}
780
781	async fn get_tree_children(
782		&self,
783
784		request:Request<GetTreeChildrenRequest>,
785	) -> Result<Response<GetTreeChildrenResponse>, Status> {
786		TreeView::GetTreeChildren::Fn(self, request.into_inner()).await
787	}
788
789	async fn register_scm_provider(
790		&self,
791
792		request:Request<RegisterScmProviderRequest>,
793	) -> Result<Response<Empty>, Status> {
794		SCM::RegisterScmProvider::Fn(self, request.into_inner()).await
795	}
796
797	async fn update_scm_group(&self, request:Request<UpdateScmGroupRequest>) -> Result<Response<Empty>, Status> {
798		SCM::UpdateScmGroup::Fn(self, request.into_inner()).await
799	}
800
801	async fn git_exec(&self, request:Request<GitExecRequest>) -> Result<Response<GitExecResponse>, Status> {
802		SCM::GitExec::Fn(self, request.into_inner()).await
803	}
804
805	async fn register_debug_adapter(
806		&self,
807
808		request:Request<RegisterDebugAdapterRequest>,
809	) -> Result<Response<Empty>, Status> {
810		Debug::RegisterDebugAdapter::Fn(self, request.into_inner()).await
811	}
812
813	async fn start_debugging(
814		&self,
815
816		request:Request<StartDebuggingRequest>,
817	) -> Result<Response<StartDebuggingResponse>, Status> {
818		Debug::StartDebugging::Fn(self, request.into_inner()).await
819	}
820
821	async fn stop_debugging(&self, request:Request<StopDebuggingRequest>) -> Result<Response<Empty>, Status> {
822		Debug::StopDebugging::Fn(self, request.into_inner()).await
823	}
824
825	async fn participate_in_save(
826		&self,
827
828		request:Request<ParticipateInSaveRequest>,
829	) -> Result<Response<ParticipateInSaveResponse>, Status> {
830		Save::Fn(self, request.into_inner()).await
831	}
832
833	async fn get_secret(&self, request:Request<GetSecretRequest>) -> Result<Response<GetSecretResponse>, Status> {
834		Secret::GetSecret::Fn(self, request.into_inner()).await
835	}
836
837	async fn store_secret(&self, request:Request<StoreSecretRequest>) -> Result<Response<Empty>, Status> {
838		Secret::StoreSecret::Fn(self, request.into_inner()).await
839	}
840
841	async fn delete_secret(&self, request:Request<DeleteSecretRequest>) -> Result<Response<Empty>, Status> {
842		Secret::DeleteSecret::Fn(self, request.into_inner()).await
843	}
844
845	async fn register_document_highlight_provider(
846		&self,
847
848		request:Request<RegisterProviderRequest>,
849	) -> Result<Response<Empty>, Status> {
850		Provider::RegisterDocumentHighlightProvider::Fn(self, request.into_inner()).await
851	}
852
853	async fn provide_document_highlights(
854		&self,
855
856		request:Request<ProvideDocumentHighlightsRequest>,
857	) -> Result<Response<ProvideDocumentHighlightsResponse>, Status> {
858		Provider::ProvideDocumentHighlights::Fn(self, request.into_inner()).await
859	}
860
861	async fn register_document_symbol_provider(
862		&self,
863
864		request:Request<RegisterProviderRequest>,
865	) -> Result<Response<Empty>, Status> {
866		Provider::RegisterDocumentSymbolProvider::Fn(self, request.into_inner()).await
867	}
868
869	async fn provide_document_symbols(
870		&self,
871
872		request:Request<ProvideDocumentSymbolsRequest>,
873	) -> Result<Response<ProvideDocumentSymbolsResponse>, Status> {
874		Provider::ProvideDocumentSymbols::Fn(self, request.into_inner()).await
875	}
876
877	async fn register_workspace_symbol_provider(
878		&self,
879
880		request:Request<RegisterProviderRequest>,
881	) -> Result<Response<Empty>, Status> {
882		Provider::RegisterWorkspaceSymbolProvider::Fn(self, request.into_inner()).await
883	}
884
885	async fn provide_workspace_symbols(
886		&self,
887
888		request:Request<ProvideWorkspaceSymbolsRequest>,
889	) -> Result<Response<ProvideWorkspaceSymbolsResponse>, Status> {
890		Provider::ProvideWorkspaceSymbols::Fn(self, request.into_inner()).await
891	}
892
893	async fn register_rename_provider(
894		&self,
895
896		request:Request<RegisterProviderRequest>,
897	) -> Result<Response<Empty>, Status> {
898		Provider::RegisterRenameProvider::Fn(self, request.into_inner()).await
899	}
900
901	async fn provide_rename_edits(
902		&self,
903
904		request:Request<ProvideRenameEditsRequest>,
905	) -> Result<Response<ProvideRenameEditsResponse>, Status> {
906		Provider::ProvideRenameEdits::Fn(self, request.into_inner()).await
907	}
908
909	async fn register_document_formatting_provider(
910		&self,
911
912		request:Request<RegisterProviderRequest>,
913	) -> Result<Response<Empty>, Status> {
914		Provider::RegisterDocumentFormattingProvider::Fn(self, request.into_inner()).await
915	}
916
917	async fn provide_document_formatting(
918		&self,
919
920		request:Request<ProvideDocumentFormattingRequest>,
921	) -> Result<Response<ProvideDocumentFormattingResponse>, Status> {
922		Provider::ProvideDocumentFormatting::Fn(self, request.into_inner()).await
923	}
924
925	async fn register_document_range_formatting_provider(
926		&self,
927
928		request:Request<RegisterProviderRequest>,
929	) -> Result<Response<Empty>, Status> {
930		Provider::RegisterDocumentRangeFormattingProvider::Fn(self, request.into_inner()).await
931	}
932
933	async fn provide_document_range_formatting(
934		&self,
935
936		request:Request<ProvideDocumentRangeFormattingRequest>,
937	) -> Result<Response<ProvideDocumentRangeFormattingResponse>, Status> {
938		Provider::ProvideDocumentRangeFormatting::Fn(self, request.into_inner()).await
939	}
940
941	async fn register_on_type_formatting_provider(
942		&self,
943
944		request:Request<RegisterOnTypeFormattingProviderRequest>,
945	) -> Result<Response<Empty>, Status> {
946		Provider::RegisterOnTypeFormattingProvider::Fn(self, request.into_inner()).await
947	}
948
949	async fn provide_on_type_formatting(
950		&self,
951
952		request:Request<ProvideOnTypeFormattingRequest>,
953	) -> Result<Response<ProvideOnTypeFormattingResponse>, Status> {
954		Provider::ProvideOnTypeFormatting::Fn(self, request.into_inner()).await
955	}
956
957	async fn register_signature_help_provider(
958		&self,
959
960		request:Request<RegisterSignatureHelpProviderRequest>,
961	) -> Result<Response<Empty>, Status> {
962		Provider::RegisterSignatureHelpProvider::Fn(self, request.into_inner()).await
963	}
964
965	async fn provide_signature_help(
966		&self,
967
968		request:Request<ProvideSignatureHelpRequest>,
969	) -> Result<Response<ProvideSignatureHelpResponse>, Status> {
970		Provider::ProvideSignatureHelp::Fn(self, request.into_inner()).await
971	}
972
973	async fn register_code_lens_provider(
974		&self,
975
976		request:Request<RegisterProviderRequest>,
977	) -> Result<Response<Empty>, Status> {
978		Provider::RegisterCodeLensProvider::Fn(self, request.into_inner()).await
979	}
980
981	async fn provide_code_lenses(
982		&self,
983
984		request:Request<ProvideCodeLensesRequest>,
985	) -> Result<Response<ProvideCodeLensesResponse>, Status> {
986		Provider::ProvideCodeLenses::Fn(self, request.into_inner()).await
987	}
988
989	async fn register_folding_range_provider(
990		&self,
991
992		request:Request<RegisterProviderRequest>,
993	) -> Result<Response<Empty>, Status> {
994		Provider::RegisterFoldingRangeProvider::Fn(self, request.into_inner()).await
995	}
996
997	async fn provide_folding_ranges(
998		&self,
999
1000		request:Request<ProvideFoldingRangesRequest>,
1001	) -> Result<Response<ProvideFoldingRangesResponse>, Status> {
1002		Provider::ProvideFoldingRanges::Fn(self, request.into_inner()).await
1003	}
1004
1005	async fn register_selection_range_provider(
1006		&self,
1007
1008		request:Request<RegisterProviderRequest>,
1009	) -> Result<Response<Empty>, Status> {
1010		Provider::RegisterSelectionRangeProvider::Fn(self, request.into_inner()).await
1011	}
1012
1013	async fn provide_selection_ranges(
1014		&self,
1015
1016		request:Request<ProvideSelectionRangesRequest>,
1017	) -> Result<Response<ProvideSelectionRangesResponse>, Status> {
1018		Provider::ProvideSelectionRanges::Fn(self, request.into_inner()).await
1019	}
1020
1021	async fn register_semantic_tokens_provider(
1022		&self,
1023
1024		request:Request<RegisterSemanticTokensProviderRequest>,
1025	) -> Result<Response<Empty>, Status> {
1026		Provider::RegisterSemanticTokensProvider::Fn(self, request.into_inner()).await
1027	}
1028
1029	async fn provide_semantic_tokens_full(
1030		&self,
1031
1032		request:Request<ProvideSemanticTokensRequest>,
1033	) -> Result<Response<ProvideSemanticTokensResponse>, Status> {
1034		Provider::ProvideSemanticTokensFull::Fn(self, request.into_inner()).await
1035	}
1036
1037	async fn register_inlay_hints_provider(
1038		&self,
1039
1040		request:Request<RegisterProviderRequest>,
1041	) -> Result<Response<Empty>, Status> {
1042		Provider::RegisterInlayHintsProvider::Fn(self, request.into_inner()).await
1043	}
1044
1045	async fn provide_inlay_hints(
1046		&self,
1047
1048		request:Request<ProvideInlayHintsRequest>,
1049	) -> Result<Response<ProvideInlayHintsResponse>, Status> {
1050		Provider::ProvideInlayHints::Fn(self, request.into_inner()).await
1051	}
1052
1053	async fn register_type_hierarchy_provider(
1054		&self,
1055
1056		request:Request<RegisterProviderRequest>,
1057	) -> Result<Response<Empty>, Status> {
1058		Provider::RegisterTypeHierarchyProvider::Fn(self, request.into_inner()).await
1059	}
1060
1061	async fn provide_type_hierarchy_supertypes(
1062		&self,
1063
1064		request:Request<ProvideTypeHierarchyRequest>,
1065	) -> Result<Response<ProvideTypeHierarchyResponse>, Status> {
1066		Provider::ProvideTypeHierarchySupertypes::Fn(self, request.into_inner()).await
1067	}
1068
1069	async fn provide_type_hierarchy_subtypes(
1070		&self,
1071
1072		request:Request<ProvideTypeHierarchyRequest>,
1073	) -> Result<Response<ProvideTypeHierarchyResponse>, Status> {
1074		Provider::ProvideTypeHierarchySubtypes::Fn(self, request.into_inner()).await
1075	}
1076
1077	async fn register_call_hierarchy_provider(
1078		&self,
1079
1080		request:Request<RegisterProviderRequest>,
1081	) -> Result<Response<Empty>, Status> {
1082		Provider::RegisterCallHierarchyProvider::Fn(self, request.into_inner()).await
1083	}
1084
1085	async fn provide_call_hierarchy_incoming_calls(
1086		&self,
1087
1088		request:Request<ProvideCallHierarchyRequest>,
1089	) -> Result<Response<ProvideCallHierarchyResponse>, Status> {
1090		Provider::ProvideCallHierarchyIncomingCalls::Fn(self, request.into_inner()).await
1091	}
1092
1093	async fn provide_call_hierarchy_outgoing_calls(
1094		&self,
1095
1096		request:Request<ProvideCallHierarchyRequest>,
1097	) -> Result<Response<ProvideCallHierarchyResponse>, Status> {
1098		Provider::ProvideCallHierarchyOutgoingCalls::Fn(self, request.into_inner()).await
1099	}
1100
1101	async fn register_linked_editing_range_provider(
1102		&self,
1103
1104		request:Request<RegisterProviderRequest>,
1105	) -> Result<Response<Empty>, Status> {
1106		Provider::RegisterLinkedEditingRangeProvider::Fn(self, request.into_inner()).await
1107	}
1108
1109	async fn provide_linked_editing_ranges(
1110		&self,
1111
1112		request:Request<ProvideLinkedEditingRangesRequest>,
1113	) -> Result<Response<ProvideLinkedEditingRangesResponse>, Status> {
1114		Provider::ProvideLinkedEditingRanges::Fn(self, request.into_inner()).await
1115	}
1116
1117	async fn register_inline_completion_item_provider(
1118		&self,
1119
1120		request:Request<RegisterProviderRequest>,
1121	) -> Result<Response<Empty>, Status> {
1122		// Registration: store handle + selector in the LanguageFeatureProviderRegistry.
1123		// The generic NotificationDispatcher already handles
1124		// `register_inline_completion_item_provider` coming via
1125		// SendCocoonNotification; this typed path is the proto-generated entry point.
1126		// NOTE: prost generates snake_case fields from the proto definition.
1127		let Inner = request.into_inner();
1128		let Handle = Inner.handle;
1129		let Selector = Inner.language_selector.clone();
1130		let ExtId = Inner.extension_id.clone();
1131		self.RegisterProvider(Handle, ProviderType::InlineCompletion, &Selector, &ExtId);
1132		Ok(Response::new(Empty {}))
1133	}
1134
1135	async fn provide_inline_completion_items(
1136		&self,
1137
1138		request:Request<ProvideInlineCompletionRequest>,
1139	) -> Result<Response<ProvideInlineCompletionResponse>, Status> {
1140		Provider::ProvideInlineCompletionItems::Fn(self, request.into_inner()).await
1141	}
1142
1143	async fn show_quick_pick(
1144		&self,
1145
1146		request:Request<ShowQuickPickRequest>,
1147	) -> Result<Response<ShowQuickPickResponse>, Status> {
1148		Window::ShowQuickPick::Fn(self, request.into_inner()).await
1149	}
1150
1151	async fn show_input_box(
1152		&self,
1153
1154		request:Request<ShowInputBoxRequest>,
1155	) -> Result<Response<ShowInputBoxResponse>, Status> {
1156		Window::ShowInputBox::Fn(self, request.into_inner()).await
1157	}
1158
1159	async fn show_progress(
1160		&self,
1161
1162		request:Request<ShowProgressRequest>,
1163	) -> Result<Response<ShowProgressResponse>, Status> {
1164		Window::ShowProgress::Fn(self, request.into_inner()).await
1165	}
1166
1167	async fn report_progress(&self, request:Request<ReportProgressRequest>) -> Result<Response<Empty>, Status> {
1168		Window::ReportProgress::Fn(self, request.into_inner()).await
1169	}
1170
1171	async fn open_external(&self, request:Request<OpenExternalRequest>) -> Result<Response<Empty>, Status> {
1172		Window::OpenExternal::Fn(self, request.into_inner()).await
1173	}
1174
1175	async fn create_output_channel(
1176		&self,
1177
1178		request:Request<CreateOutputChannelRequest>,
1179	) -> Result<Response<CreateOutputChannelResponse>, Status> {
1180		Output::CreateOutputChannel::Fn(self, request.into_inner()).await
1181	}
1182
1183	async fn append_output(&self, request:Request<AppendOutputRequest>) -> Result<Response<Empty>, Status> {
1184		Output::AppendOutput::Fn(self, request.into_inner()).await
1185	}
1186
1187	async fn clear_output(&self, request:Request<ClearOutputRequest>) -> Result<Response<Empty>, Status> {
1188		Output::ClearOutput::Fn(self, request.into_inner()).await
1189	}
1190
1191	async fn show_output(&self, request:Request<ShowOutputRequest>) -> Result<Response<Empty>, Status> {
1192		Output::ShowOutput::Fn(self, request.into_inner()).await
1193	}
1194
1195	async fn dispose_output(&self, request:Request<DisposeOutputRequest>) -> Result<Response<Empty>, Status> {
1196		Output::DisposeOutput::Fn(self, request.into_inner()).await
1197	}
1198
1199	async fn register_task_provider(
1200		&self,
1201
1202		request:Request<RegisterTaskProviderRequest>,
1203	) -> Result<Response<Empty>, Status> {
1204		Task::RegisterTaskProvider::Fn(self, request.into_inner()).await
1205	}
1206
1207	async fn execute_task(&self, request:Request<ExecuteTaskRequest>) -> Result<Response<ExecuteTaskResponse>, Status> {
1208		Task::ExecuteTask::Fn(self, request.into_inner()).await
1209	}
1210
1211	async fn terminate_task(&self, request:Request<TerminateTaskRequest>) -> Result<Response<Empty>, Status> {
1212		Task::TerminateTask::Fn(self, request.into_inner()).await
1213	}
1214
1215	async fn get_authentication_session(
1216		&self,
1217
1218		request:Request<GetAuthenticationSessionRequest>,
1219	) -> Result<Response<GetAuthenticationSessionResponse>, Status> {
1220		Auth::GetAuthenticationSession::Fn(self, request.into_inner()).await
1221	}
1222
1223	async fn register_authentication_provider(
1224		&self,
1225
1226		request:Request<RegisterAuthenticationProviderRequest>,
1227	) -> Result<Response<Empty>, Status> {
1228		Auth::RegisterAuthenticationProvider::Fn(self, request.into_inner()).await
1229	}
1230
1231	async fn get_extension(
1232		&self,
1233
1234		request:Request<GetExtensionRequest>,
1235	) -> Result<Response<GetExtensionResponse>, Status> {
1236		Extension::GetExtension::Fn(self, request.into_inner()).await
1237	}
1238
1239	async fn get_all_extensions(&self, request:Request<Empty>) -> Result<Response<GetAllExtensionsResponse>, Status> {
1240		Extension::GetAllExtensions::Fn(self, request.into_inner()).await
1241	}
1242
1243	async fn get_configuration(
1244		&self,
1245
1246		request:Request<GetConfigurationRequest>,
1247	) -> Result<Response<GetConfigurationResponse>, Status> {
1248		Extension::GetConfiguration::Fn(self, request.into_inner()).await
1249	}
1250}