1#![allow(non_snake_case)]
2
3pub mod error;
4mod macros;
5mod typed_envelope;
6
7pub use error::*;
8pub use prost::{DecodeError, Message};
9use std::{
10 cmp,
11 fmt::Debug,
12 iter, mem,
13 time::{Duration, SystemTime, UNIX_EPOCH},
14};
15pub use typed_envelope::*;
16
17include!(concat!(env!("OUT_DIR"), "/zed.messages.rs"));
18
19pub const REMOTE_SERVER_PEER_ID: PeerId = PeerId { owner_id: 0, id: 0 };
20pub const REMOTE_SERVER_PROJECT_ID: u64 = 0;
21
22messages!(
23 (Ack, Foreground),
24 (AckBufferOperation, Background),
25 (AckChannelMessage, Background),
26 (ActivateToolchain, Foreground),
27 (ActiveToolchain, Foreground),
28 (ActiveToolchainResponse, Foreground),
29 (ResolveToolchain, Background),
30 (ResolveToolchainResponse, Background),
31 (AddNotification, Foreground),
32 (AddProjectCollaborator, Foreground),
33 (AddWorktree, Foreground),
34 (AddWorktreeResponse, Foreground),
35 (AdvertiseContexts, Foreground),
36 (AllocateWorktreeId, Foreground),
37 (AllocateWorktreeIdResponse, Foreground),
38 (ApplyCodeAction, Background),
39 (ApplyCodeActionResponse, Background),
40 (ApplyCompletionAdditionalEdits, Background),
41 (ApplyCompletionAdditionalEditsResponse, Background),
42 (BlameBuffer, Foreground),
43 (BlameBufferResponse, Foreground),
44 (BufferReloaded, Foreground),
45 (BufferSaved, Foreground),
46 (Call, Foreground),
47 (CallCanceled, Foreground),
48 (CancelCall, Foreground),
49 (CancelLanguageServerWork, Foreground),
50 (ChannelMessageSent, Foreground),
51 (ChannelMessageUpdate, Foreground),
52 (CloseBuffer, Foreground),
53 (Commit, Background),
54 (RunGitHook, Background),
55 (CopyProjectEntry, Foreground),
56 (CreateBufferForPeer, Foreground),
57 (CreateImageForPeer, Foreground),
58 (CreateFileForPeer, Foreground),
59 (CreateChannel, Foreground),
60 (CreateChannelResponse, Foreground),
61 (CreateContext, Foreground),
62 (CreateContextResponse, Foreground),
63 (CreateProjectEntry, Foreground),
64 (CreateRoom, Foreground),
65 (CreateRoomResponse, Foreground),
66 (DeclineCall, Foreground),
67 (DeleteChannel, Foreground),
68 (DeleteNotification, Foreground),
69 (DeleteProjectEntry, Foreground),
70 (DownloadFileByPath, Background),
71 (DownloadFileResponse, Background),
72 (EndStream, Foreground),
73 (Error, Foreground),
74 (ExpandProjectEntry, Foreground),
75 (ExpandProjectEntryResponse, Foreground),
76 (FindSearchCandidates, Background),
77 (FlushBufferedMessages, Foreground),
78 (ExpandAllForProjectEntry, Foreground),
79 (ExpandAllForProjectEntryResponse, Foreground),
80 (Follow, Foreground),
81 (FollowResponse, Foreground),
82 (ApplyCodeActionKind, Foreground),
83 (ApplyCodeActionKindResponse, Foreground),
84 (FormatBuffers, Foreground),
85 (FormatBuffersResponse, Foreground),
86 (FuzzySearchUsers, Foreground),
87 (GetChannelMembers, Foreground),
88 (GetChannelMembersResponse, Foreground),
89 (GetChannelMessages, Background),
90 (GetChannelMessagesById, Background),
91 (GetChannelMessagesResponse, Background),
92 (GetCodeActions, Background),
93 (GetCodeActionsResponse, Background),
94 (GetCompletions, Background),
95 (GetCompletionsResponse, Background),
96 (GetDeclaration, Background),
97 (GetDeclarationResponse, Background),
98 (GetDefinition, Background),
99 (GetDefinitionResponse, Background),
100 (GetDocumentHighlights, Background),
101 (GetDocumentHighlightsResponse, Background),
102 (GetDocumentSymbols, Background),
103 (GetDocumentSymbolsResponse, Background),
104 (GetHover, Background),
105 (GetHoverResponse, Background),
106 (GetNotifications, Foreground),
107 (GetNotificationsResponse, Foreground),
108 (GetCrashFiles, Background),
109 (GetCrashFilesResponse, Background),
110 (GetPathMetadata, Background),
111 (GetPathMetadataResponse, Background),
112 (GetPermalinkToLine, Foreground),
113 (GetProcesses, Background),
114 (GetProcessesResponse, Background),
115 (GetPermalinkToLineResponse, Foreground),
116 (GetProjectSymbols, Background),
117 (GetProjectSymbolsResponse, Background),
118 (GetReferences, Background),
119 (GetReferencesResponse, Background),
120 (GetSignatureHelp, Background),
121 (GetSignatureHelpResponse, Background),
122 (GetTypeDefinition, Background),
123 (GetTypeDefinitionResponse, Background),
124 (GetImplementation, Background),
125 (GetImplementationResponse, Background),
126 (OpenUnstagedDiff, Foreground),
127 (OpenUnstagedDiffResponse, Foreground),
128 (OpenUncommittedDiff, Foreground),
129 (OpenUncommittedDiffResponse, Foreground),
130 (GetUsers, Foreground),
131 (GitGetBranches, Background),
132 (GitBranchesResponse, Background),
133 (Hello, Foreground),
134 (HideToast, Background),
135 (IncomingCall, Foreground),
136 (InlayHints, Background),
137 (InlayHintsResponse, Background),
138 (SemanticTokens, Background),
139 (SemanticTokensResponse, Background),
140 (InstallExtension, Background),
141 (InviteChannelMember, Foreground),
142 (JoinChannel, Foreground),
143 (JoinChannelBuffer, Foreground),
144 (JoinChannelBufferResponse, Foreground),
145 (JoinChannelChat, Foreground),
146 (JoinChannelChatResponse, Foreground),
147 (JoinProject, Foreground),
148 (JoinProjectResponse, Foreground),
149 (JoinRoom, Foreground),
150 (JoinRoomResponse, Foreground),
151 (LanguageServerLog, Foreground),
152 (LanguageServerPromptRequest, Foreground),
153 (LanguageServerPromptResponse, Foreground),
154 (LeaveChannelBuffer, Background),
155 (LeaveChannelChat, Foreground),
156 (LeaveProject, Foreground),
157 (LeaveRoom, Foreground),
158 (LinkedEditingRange, Background),
159 (LinkedEditingRangeResponse, Background),
160 (ListRemoteDirectory, Background),
161 (ListRemoteDirectoryResponse, Background),
162 (ListToolchains, Foreground),
163 (ListToolchainsResponse, Foreground),
164 (LoadCommitDiff, Foreground),
165 (LoadCommitDiffResponse, Foreground),
166 (LspExtExpandMacro, Background),
167 (LspExtExpandMacroResponse, Background),
168 (LspExtOpenDocs, Background),
169 (LspExtOpenDocsResponse, Background),
170 (LspExtRunnables, Background),
171 (LspExtRunnablesResponse, Background),
172 (LspExtSwitchSourceHeader, Background),
173 (LspExtSwitchSourceHeaderResponse, Background),
174 (LspExtGoToParentModule, Background),
175 (LspExtGoToParentModuleResponse, Background),
176 (LspExtCancelFlycheck, Background),
177 (LspExtRunFlycheck, Background),
178 (LspExtClearFlycheck, Background),
179 (MarkNotificationRead, Foreground),
180 (MoveChannel, Foreground),
181 (ReorderChannel, Foreground),
182 (LspQuery, Background),
183 (LspQueryResponse, Background),
184 (OnTypeFormatting, Background),
185 (OnTypeFormattingResponse, Background),
186 (OpenBufferById, Background),
187 (OpenBufferByPath, Background),
188 (OpenImageByPath, Background),
189 (OpenBufferForSymbol, Background),
190 (OpenBufferForSymbolResponse, Background),
191 (OpenBufferResponse, Background),
192 (OpenImageResponse, Background),
193 (OpenCommitMessageBuffer, Background),
194 (OpenContext, Foreground),
195 (OpenContextResponse, Foreground),
196 (OpenNewBuffer, Foreground),
197 (OpenServerSettings, Foreground),
198 (PerformRename, Background),
199 (PerformRenameResponse, Background),
200 (Ping, Foreground),
201 (PrepareRename, Background),
202 (PrepareRenameResponse, Background),
203 (ProjectEntryResponse, Foreground),
204 (RefreshInlayHints, Background),
205 (RefreshSemanticTokens, Background),
206 (RegisterBufferWithLanguageServers, Background),
207 (RejoinChannelBuffers, Foreground),
208 (RejoinChannelBuffersResponse, Foreground),
209 (RejoinRemoteProjects, Foreground),
210 (RejoinRemoteProjectsResponse, Foreground),
211 (RejoinRoom, Foreground),
212 (RejoinRoomResponse, Foreground),
213 (ReloadBuffers, Foreground),
214 (ReloadBuffersResponse, Foreground),
215 (RemoveChannelMember, Foreground),
216 (RemoveChannelMessage, Foreground),
217 (RemoveContact, Foreground),
218 (RemoveProjectCollaborator, Foreground),
219 (RemoveWorktree, Foreground),
220 (RenameChannel, Foreground),
221 (RenameChannelResponse, Foreground),
222 (RenameProjectEntry, Foreground),
223 (RequestContact, Foreground),
224 (ResolveCompletionDocumentation, Background),
225 (ResolveCompletionDocumentationResponse, Background),
226 (ResolveInlayHint, Background),
227 (ResolveInlayHintResponse, Background),
228 (GetDocumentColor, Background),
229 (GetDocumentColorResponse, Background),
230 (GetColorPresentation, Background),
231 (GetColorPresentationResponse, Background),
232 (RefreshCodeLens, Background),
233 (GetCodeLens, Background),
234 (GetCodeLensResponse, Background),
235 (RespondToChannelInvite, Foreground),
236 (RespondToContactRequest, Foreground),
237 (RestartLanguageServers, Foreground),
238 (StopLanguageServers, Background),
239 (RoomUpdated, Foreground),
240 (SaveBuffer, Foreground),
241 (SendChannelMessage, Background),
242 (SendChannelMessageResponse, Background),
243 (SetChannelMemberRole, Foreground),
244 (SetChannelVisibility, Foreground),
245 (SetRoomParticipantRole, Foreground),
246 (ShareProject, Foreground),
247 (ShareProjectResponse, Foreground),
248 (ShowContacts, Foreground),
249 (ShutdownRemoteServer, Foreground),
250 (Stage, Background),
251 (StartLanguageServer, Foreground),
252 (SubscribeToChannels, Foreground),
253 (SyncExtensions, Background),
254 (SyncExtensionsResponse, Background),
255 (BreakpointsForFile, Background),
256 (ToggleBreakpoint, Foreground),
257 (SynchronizeBuffers, Foreground),
258 (SynchronizeBuffersResponse, Foreground),
259 (SynchronizeContexts, Foreground),
260 (SynchronizeContextsResponse, Foreground),
261 (TaskContext, Background),
262 (TaskContextForLocation, Background),
263 (Test, Foreground),
264 (Toast, Background),
265 (Unfollow, Foreground),
266 (UnshareProject, Foreground),
267 (Unstage, Background),
268 (Stash, Background),
269 (StashPop, Background),
270 (StashApply, Background),
271 (StashDrop, Background),
272 (UpdateBuffer, Foreground),
273 (UpdateBufferFile, Foreground),
274 (UpdateChannelBuffer, Foreground),
275 (UpdateChannelBufferCollaborators, Foreground),
276 (UpdateChannelMessage, Foreground),
277 (UpdateChannels, Foreground),
278 (UpdateContacts, Foreground),
279 (UpdateContext, Foreground),
280 (UpdateDiagnosticSummary, Foreground),
281 (UpdateDiffBases, Foreground),
282 (UpdateFollowers, Foreground),
283 (UpdateGitBranch, Background),
284 (UpdateLanguageServer, Foreground),
285 (UpdateNotification, Foreground),
286 (UpdateParticipantLocation, Foreground),
287 (UpdateProject, Foreground),
288 (UpdateProjectCollaborator, Foreground),
289 (UpdateUserChannels, Foreground),
290 (UpdateWorktree, Foreground),
291 (UpdateWorktreeSettings, Foreground),
292 (UpdateUserSettings, Background),
293 (UpdateRepository, Foreground),
294 (RemoveRepository, Foreground),
295 (UsersResponse, Foreground),
296 (GitReset, Background),
297 (GitDeleteBranch, Background),
298 (GitCheckoutFiles, Background),
299 (GitShow, Background),
300 (GitCommitDetails, Background),
301 (GitFileHistory, Background),
302 (GitFileHistoryResponse, Background),
303 (SetIndexText, Background),
304 (Push, Background),
305 (Fetch, Background),
306 (GetRemotes, Background),
307 (GetRemotesResponse, Background),
308 (Pull, Background),
309 (RemoteMessageResponse, Background),
310 (AskPassRequest, Background),
311 (AskPassResponse, Background),
312 (GitCreateRemote, Background),
313 (GitRemoveRemote, Background),
314 (GitCreateBranch, Background),
315 (GitChangeBranch, Background),
316 (GitRenameBranch, Background),
317 (TrustWorktrees, Background),
318 (RestrictWorktrees, Background),
319 (CheckForPushedCommits, Background),
320 (CheckForPushedCommitsResponse, Background),
321 (GitDiff, Background),
322 (GitDiffResponse, Background),
323 (GitInit, Background),
324 (GetDebugAdapterBinary, Background),
325 (DebugAdapterBinary, Background),
326 (RunDebugLocators, Background),
327 (DebugRequest, Background),
328 (LogToDebugConsole, Background),
329 (GetDocumentDiagnostics, Background),
330 (GetDocumentDiagnosticsResponse, Background),
331 (PullWorkspaceDiagnostics, Background),
332 (GetDefaultBranch, Background),
333 (GetDefaultBranchResponse, Background),
334 (GetTreeDiff, Background),
335 (GetTreeDiffResponse, Background),
336 (GetBlobContent, Background),
337 (GetBlobContentResponse, Background),
338 (GitClone, Background),
339 (GitCloneResponse, Background),
340 (ToggleLspLogs, Background),
341 (GetDirectoryEnvironment, Background),
342 (DirectoryEnvironment, Background),
343 (GetAgentServerCommand, Background),
344 (AgentServerCommand, Background),
345 (GetContextServerCommand, Background),
346 (ContextServerCommand, Background),
347 (ExternalAgentsUpdated, Background),
348 (ExternalExtensionAgentsUpdated, Background),
349 (ExternalAgentLoadingStatusUpdated, Background),
350 (NewExternalAgentVersionAvailable, Background),
351 (RemoteStarted, Background),
352 (GitGetWorktrees, Background),
353 (GitWorktreesResponse, Background),
354 (GitCreateWorktree, Background),
355 (ShareAgentThread, Foreground),
356 (GetSharedAgentThread, Foreground),
357 (GetSharedAgentThreadResponse, Foreground),
358 (FindSearchCandidatesChunk, Background),
359 (FindSearchCandidatesCancelled, Background),
360);
361
362request_messages!(
363 (AllocateWorktreeId, AllocateWorktreeIdResponse),
364 (ApplyCodeAction, ApplyCodeActionResponse),
365 (
366 ApplyCompletionAdditionalEdits,
367 ApplyCompletionAdditionalEditsResponse
368 ),
369 (Call, Ack),
370 (CancelCall, Ack),
371 (Commit, Ack),
372 (RunGitHook, Ack),
373 (CopyProjectEntry, ProjectEntryResponse),
374 (CreateChannel, CreateChannelResponse),
375 (CreateProjectEntry, ProjectEntryResponse),
376 (CreateRoom, CreateRoomResponse),
377 (DeclineCall, Ack),
378 (DeleteChannel, Ack),
379 (DeleteProjectEntry, ProjectEntryResponse),
380 (DownloadFileByPath, DownloadFileResponse),
381 (ExpandProjectEntry, ExpandProjectEntryResponse),
382 (ExpandAllForProjectEntry, ExpandAllForProjectEntryResponse),
383 (Follow, FollowResponse),
384 (ApplyCodeActionKind, ApplyCodeActionKindResponse),
385 (FormatBuffers, FormatBuffersResponse),
386 (FuzzySearchUsers, UsersResponse),
387 (GetChannelMembers, GetChannelMembersResponse),
388 (GetChannelMessages, GetChannelMessagesResponse),
389 (GetChannelMessagesById, GetChannelMessagesResponse),
390 (GetCodeActions, GetCodeActionsResponse),
391 (GetCompletions, GetCompletionsResponse),
392 (GetDefinition, GetDefinitionResponse),
393 (GetDeclaration, GetDeclarationResponse),
394 (GetImplementation, GetImplementationResponse),
395 (GetDocumentHighlights, GetDocumentHighlightsResponse),
396 (GetDocumentSymbols, GetDocumentSymbolsResponse),
397 (GetHover, GetHoverResponse),
398 (GetNotifications, GetNotificationsResponse),
399 (GetProjectSymbols, GetProjectSymbolsResponse),
400 (GetReferences, GetReferencesResponse),
401 (GetSignatureHelp, GetSignatureHelpResponse),
402 (OpenUnstagedDiff, OpenUnstagedDiffResponse),
403 (OpenUncommittedDiff, OpenUncommittedDiffResponse),
404 (GetTypeDefinition, GetTypeDefinitionResponse),
405 (LinkedEditingRange, LinkedEditingRangeResponse),
406 (ListRemoteDirectory, ListRemoteDirectoryResponse),
407 (GetUsers, UsersResponse),
408 (IncomingCall, Ack),
409 (InlayHints, InlayHintsResponse),
410 (SemanticTokens, SemanticTokensResponse),
411 (GetCodeLens, GetCodeLensResponse),
412 (InviteChannelMember, Ack),
413 (JoinChannel, JoinRoomResponse),
414 (JoinChannelBuffer, JoinChannelBufferResponse),
415 (JoinChannelChat, JoinChannelChatResponse),
416 (JoinProject, JoinProjectResponse),
417 (JoinRoom, JoinRoomResponse),
418 (LeaveChannelBuffer, Ack),
419 (LeaveRoom, Ack),
420 (LoadCommitDiff, LoadCommitDiffResponse),
421 (MarkNotificationRead, Ack),
422 (MoveChannel, Ack),
423 (OnTypeFormatting, OnTypeFormattingResponse),
424 (OpenBufferById, OpenBufferResponse),
425 (OpenBufferByPath, OpenBufferResponse),
426 (OpenImageByPath, OpenImageResponse),
427 (OpenBufferForSymbol, OpenBufferForSymbolResponse),
428 (OpenCommitMessageBuffer, OpenBufferResponse),
429 (OpenNewBuffer, OpenBufferResponse),
430 (PerformRename, PerformRenameResponse),
431 (Ping, Ack),
432 (PrepareRename, PrepareRenameResponse),
433 (RefreshInlayHints, Ack),
434 (RefreshSemanticTokens, Ack),
435 (RefreshCodeLens, Ack),
436 (RejoinChannelBuffers, RejoinChannelBuffersResponse),
437 (RejoinRoom, RejoinRoomResponse),
438 (ReloadBuffers, ReloadBuffersResponse),
439 (RemoveChannelMember, Ack),
440 (RemoveChannelMessage, Ack),
441 (UpdateChannelMessage, Ack),
442 (RemoveContact, Ack),
443 (RenameChannel, RenameChannelResponse),
444 (RenameProjectEntry, ProjectEntryResponse),
445 (ReorderChannel, Ack),
446 (RequestContact, Ack),
447 (
448 ResolveCompletionDocumentation,
449 ResolveCompletionDocumentationResponse
450 ),
451 (ResolveInlayHint, ResolveInlayHintResponse),
452 (GetDocumentColor, GetDocumentColorResponse),
453 (GetColorPresentation, GetColorPresentationResponse),
454 (RespondToChannelInvite, Ack),
455 (RespondToContactRequest, Ack),
456 (SaveBuffer, BufferSaved),
457 (Stage, Ack),
458 (FindSearchCandidates, Ack),
459 (SendChannelMessage, SendChannelMessageResponse),
460 (SetChannelMemberRole, Ack),
461 (SetChannelVisibility, Ack),
462 (ShareAgentThread, Ack),
463 (GetSharedAgentThread, GetSharedAgentThreadResponse),
464 (ShareProject, ShareProjectResponse),
465 (SynchronizeBuffers, SynchronizeBuffersResponse),
466 (TaskContextForLocation, TaskContext),
467 (Test, Test),
468 (Unstage, Ack),
469 (Stash, Ack),
470 (StashPop, Ack),
471 (StashApply, Ack),
472 (StashDrop, Ack),
473 (UpdateBuffer, Ack),
474 (UpdateParticipantLocation, Ack),
475 (UpdateProject, Ack),
476 (UpdateWorktree, Ack),
477 (UpdateRepository, Ack),
478 (RemoveRepository, Ack),
479 (LspExtExpandMacro, LspExtExpandMacroResponse),
480 (LspExtOpenDocs, LspExtOpenDocsResponse),
481 (LspExtRunnables, LspExtRunnablesResponse),
482 (SetRoomParticipantRole, Ack),
483 (BlameBuffer, BlameBufferResponse),
484 (RejoinRemoteProjects, RejoinRemoteProjectsResponse),
485 (LspQuery, Ack),
486 (LspQueryResponse, Ack),
487 (RestartLanguageServers, Ack),
488 (StopLanguageServers, Ack),
489 (OpenContext, OpenContextResponse),
490 (CreateContext, CreateContextResponse),
491 (SynchronizeContexts, SynchronizeContextsResponse),
492 (LspExtSwitchSourceHeader, LspExtSwitchSourceHeaderResponse),
493 (LspExtGoToParentModule, LspExtGoToParentModuleResponse),
494 (LspExtCancelFlycheck, Ack),
495 (LspExtRunFlycheck, Ack),
496 (LspExtClearFlycheck, Ack),
497 (AddWorktree, AddWorktreeResponse),
498 (ShutdownRemoteServer, Ack),
499 (RemoveWorktree, Ack),
500 (OpenServerSettings, OpenBufferResponse),
501 (GetPermalinkToLine, GetPermalinkToLineResponse),
502 (FlushBufferedMessages, Ack),
503 (LanguageServerPromptRequest, LanguageServerPromptResponse),
504 (GitGetBranches, GitBranchesResponse),
505 (UpdateGitBranch, Ack),
506 (ListToolchains, ListToolchainsResponse),
507 (ActivateToolchain, Ack),
508 (ActiveToolchain, ActiveToolchainResponse),
509 (ResolveToolchain, ResolveToolchainResponse),
510 (GetPathMetadata, GetPathMetadataResponse),
511 (GetCrashFiles, GetCrashFilesResponse),
512 (CancelLanguageServerWork, Ack),
513 (SyncExtensions, SyncExtensionsResponse),
514 (InstallExtension, Ack),
515 (RegisterBufferWithLanguageServers, Ack),
516 (GitShow, GitCommitDetails),
517 (GitFileHistory, GitFileHistoryResponse),
518 (GitReset, Ack),
519 (GitDeleteBranch, Ack),
520 (GitCheckoutFiles, Ack),
521 (SetIndexText, Ack),
522 (Push, RemoteMessageResponse),
523 (Fetch, RemoteMessageResponse),
524 (GetRemotes, GetRemotesResponse),
525 (Pull, RemoteMessageResponse),
526 (AskPassRequest, AskPassResponse),
527 (GitCreateRemote, Ack),
528 (GitRemoveRemote, Ack),
529 (GitCreateBranch, Ack),
530 (GitChangeBranch, Ack),
531 (GitRenameBranch, Ack),
532 (CheckForPushedCommits, CheckForPushedCommitsResponse),
533 (GitDiff, GitDiffResponse),
534 (GitInit, Ack),
535 (ToggleBreakpoint, Ack),
536 (GetDebugAdapterBinary, DebugAdapterBinary),
537 (RunDebugLocators, DebugRequest),
538 (GetDocumentDiagnostics, GetDocumentDiagnosticsResponse),
539 (PullWorkspaceDiagnostics, Ack),
540 (GetDefaultBranch, GetDefaultBranchResponse),
541 (GetBlobContent, GetBlobContentResponse),
542 (GetTreeDiff, GetTreeDiffResponse),
543 (GitClone, GitCloneResponse),
544 (ToggleLspLogs, Ack),
545 (GetDirectoryEnvironment, DirectoryEnvironment),
546 (GetProcesses, GetProcessesResponse),
547 (GetAgentServerCommand, AgentServerCommand),
548 (GetContextServerCommand, ContextServerCommand),
549 (RemoteStarted, Ack),
550 (GitGetWorktrees, GitWorktreesResponse),
551 (GitCreateWorktree, Ack),
552 (TrustWorktrees, Ack),
553 (RestrictWorktrees, Ack),
554 (FindSearchCandidatesChunk, Ack),
555);
556
557lsp_messages!(
558 (GetReferences, GetReferencesResponse, true),
559 (GetDocumentColor, GetDocumentColorResponse, true),
560 (GetHover, GetHoverResponse, true),
561 (GetCodeActions, GetCodeActionsResponse, true),
562 (GetSignatureHelp, GetSignatureHelpResponse, true),
563 (GetCodeLens, GetCodeLensResponse, true),
564 (GetDocumentDiagnostics, GetDocumentDiagnosticsResponse, true),
565 (GetDefinition, GetDefinitionResponse, true),
566 (GetDeclaration, GetDeclarationResponse, true),
567 (GetTypeDefinition, GetTypeDefinitionResponse, true),
568 (GetImplementation, GetImplementationResponse, true),
569 (InlayHints, InlayHintsResponse, false),
570 (SemanticTokens, SemanticTokensResponse, true)
571);
572
573entity_messages!(
574 {project_id, ShareProject},
575 AddProjectCollaborator,
576 AddWorktree,
577 AllocateWorktreeId,
578 ApplyCodeAction,
579 ApplyCompletionAdditionalEdits,
580 BlameBuffer,
581 BufferReloaded,
582 BufferSaved,
583 CloseBuffer,
584 Commit,
585 RunGitHook,
586 GetColorPresentation,
587 CopyProjectEntry,
588 CreateBufferForPeer,
589 CreateFileForPeer,
590 CreateImageForPeer,
591 CreateProjectEntry,
592 GetDocumentColor,
593 DeleteProjectEntry,
594 ExpandProjectEntry,
595 ExpandAllForProjectEntry,
596 FindSearchCandidates,
597 ApplyCodeActionKind,
598 FormatBuffers,
599 GetCodeActions,
600 GetCodeLens,
601 GetCompletions,
602 GetDefinition,
603 GetDeclaration,
604 GetImplementation,
605 GetDocumentHighlights,
606 GetDocumentSymbols,
607 GetHover,
608 GetProjectSymbols,
609 GetReferences,
610 GetSignatureHelp,
611 OpenUnstagedDiff,
612 OpenUncommittedDiff,
613 GetTypeDefinition,
614 InlayHints,
615 SemanticTokens,
616 JoinProject,
617 LeaveProject,
618 LinkedEditingRange,
619 LoadCommitDiff,
620 LspQuery,
621 LspQueryResponse,
622 RestartLanguageServers,
623 StopLanguageServers,
624 OnTypeFormatting,
625 OpenNewBuffer,
626 OpenBufferById,
627 OpenBufferByPath,
628 OpenImageByPath,
629 OpenBufferForSymbol,
630 OpenCommitMessageBuffer,
631 PerformRename,
632 PrepareRename,
633 RefreshInlayHints,
634 RefreshSemanticTokens,
635 RefreshCodeLens,
636 ReloadBuffers,
637 RemoveProjectCollaborator,
638 RenameProjectEntry,
639 ResolveCompletionDocumentation,
640 ResolveInlayHint,
641 SaveBuffer,
642 Stage,
643 StartLanguageServer,
644 SynchronizeBuffers,
645 TaskContextForLocation,
646 UnshareProject,
647 Unstage,
648 Stash,
649 StashPop,
650 StashApply,
651 StashDrop,
652 UpdateBuffer,
653 UpdateBufferFile,
654 UpdateDiagnosticSummary,
655 UpdateDiffBases,
656 UpdateLanguageServer,
657 UpdateProject,
658 UpdateProjectCollaborator,
659 UpdateWorktree,
660 UpdateRepository,
661 RemoveRepository,
662 UpdateWorktreeSettings,
663 UpdateUserSettings,
664 LspExtExpandMacro,
665 LspExtOpenDocs,
666 LspExtRunnables,
667 AdvertiseContexts,
668 OpenContext,
669 CreateContext,
670 UpdateContext,
671 SynchronizeContexts,
672 LspExtSwitchSourceHeader,
673 LspExtGoToParentModule,
674 LspExtCancelFlycheck,
675 LspExtRunFlycheck,
676 LspExtClearFlycheck,
677 LanguageServerLog,
678 Toast,
679 HideToast,
680 OpenServerSettings,
681 GetPermalinkToLine,
682 LanguageServerPromptRequest,
683 GitGetBranches,
684 UpdateGitBranch,
685 ListToolchains,
686 ActivateToolchain,
687 ActiveToolchain,
688 ResolveToolchain,
689 GetPathMetadata,
690 GetProcesses,
691 CancelLanguageServerWork,
692 RegisterBufferWithLanguageServers,
693 GitShow,
694 GitFileHistory,
695 GitReset,
696 GitDeleteBranch,
697 GitCheckoutFiles,
698 SetIndexText,
699 ToggleLspLogs,
700 GetDirectoryEnvironment,
701
702 Push,
703 Fetch,
704 GetRemotes,
705 Pull,
706 AskPassRequest,
707 GitChangeBranch,
708 GitRenameBranch,
709 GitCreateBranch,
710 GitCreateRemote,
711 GitRemoveRemote,
712 CheckForPushedCommits,
713 GitDiff,
714 GitInit,
715 BreakpointsForFile,
716 ToggleBreakpoint,
717 RunDebugLocators,
718 GetDebugAdapterBinary,
719 LogToDebugConsole,
720 GetDocumentDiagnostics,
721 PullWorkspaceDiagnostics,
722 GetDefaultBranch,
723 GetTreeDiff,
724 GetBlobContent,
725 GitClone,
726 GetAgentServerCommand,
727 GetContextServerCommand,
728 ExternalAgentsUpdated,
729 ExternalExtensionAgentsUpdated,
730 ExternalAgentLoadingStatusUpdated,
731 NewExternalAgentVersionAvailable,
732 GitGetWorktrees,
733 GitCreateWorktree,
734 TrustWorktrees,
735 RestrictWorktrees,
736 FindSearchCandidatesChunk,
737 FindSearchCandidatesCancelled,
738 DownloadFileByPath
739);
740
741entity_messages!(
742 {channel_id, Channel},
743 ChannelMessageSent,
744 ChannelMessageUpdate,
745 RemoveChannelMessage,
746 UpdateChannelMessage,
747 UpdateChannelBuffer,
748 UpdateChannelBufferCollaborators,
749);
750
751impl From<Timestamp> for SystemTime {
752 fn from(val: Timestamp) -> Self {
753 UNIX_EPOCH
754 .checked_add(Duration::new(val.seconds, val.nanos))
755 .unwrap()
756 }
757}
758
759impl From<SystemTime> for Timestamp {
760 fn from(time: SystemTime) -> Self {
761 let duration = time.duration_since(UNIX_EPOCH).unwrap_or_default();
762 Self {
763 seconds: duration.as_secs(),
764 nanos: duration.subsec_nanos(),
765 }
766 }
767}
768
769impl From<u128> for Nonce {
770 fn from(nonce: u128) -> Self {
771 let upper_half = (nonce >> 64) as u64;
772 let lower_half = nonce as u64;
773 Self {
774 upper_half,
775 lower_half,
776 }
777 }
778}
779
780impl From<Nonce> for u128 {
781 fn from(nonce: Nonce) -> Self {
782 let upper_half = (nonce.upper_half as u128) << 64;
783 let lower_half = nonce.lower_half as u128;
784 upper_half | lower_half
785 }
786}
787
788#[cfg(any(test, feature = "test-support"))]
789pub const MAX_WORKTREE_UPDATE_MAX_CHUNK_SIZE: usize = 2;
790#[cfg(not(any(test, feature = "test-support")))]
791pub const MAX_WORKTREE_UPDATE_MAX_CHUNK_SIZE: usize = 256;
792
793pub fn split_worktree_update(mut message: UpdateWorktree) -> impl Iterator<Item = UpdateWorktree> {
794 let mut done = false;
795
796 iter::from_fn(move || {
797 if done {
798 return None;
799 }
800
801 let updated_entries_chunk_size = cmp::min(
802 message.updated_entries.len(),
803 MAX_WORKTREE_UPDATE_MAX_CHUNK_SIZE,
804 );
805 let updated_entries: Vec<_> = message
806 .updated_entries
807 .drain(..updated_entries_chunk_size)
808 .collect();
809
810 let removed_entries_chunk_size = cmp::min(
811 message.removed_entries.len(),
812 MAX_WORKTREE_UPDATE_MAX_CHUNK_SIZE,
813 );
814 let removed_entries = message
815 .removed_entries
816 .drain(..removed_entries_chunk_size)
817 .collect();
818
819 let mut updated_repositories = Vec::new();
820 let mut limit = MAX_WORKTREE_UPDATE_MAX_CHUNK_SIZE;
821 while let Some(repo) = message.updated_repositories.first_mut() {
822 let updated_statuses_limit = cmp::min(repo.updated_statuses.len(), limit);
823 let removed_statuses_limit = cmp::min(repo.removed_statuses.len(), limit);
824
825 updated_repositories.push(RepositoryEntry {
826 repository_id: repo.repository_id,
827 branch_summary: repo.branch_summary.clone(),
828 updated_statuses: repo
829 .updated_statuses
830 .drain(..updated_statuses_limit)
831 .collect(),
832 removed_statuses: repo
833 .removed_statuses
834 .drain(..removed_statuses_limit)
835 .collect(),
836 current_merge_conflicts: repo.current_merge_conflicts.clone(),
837 });
838 if repo.removed_statuses.is_empty() && repo.updated_statuses.is_empty() {
839 message.updated_repositories.remove(0);
840 }
841 limit = limit.saturating_sub(removed_statuses_limit + updated_statuses_limit);
842 if limit == 0 {
843 break;
844 }
845 }
846
847 done = message.updated_entries.is_empty()
848 && message.removed_entries.is_empty()
849 && message.updated_repositories.is_empty();
850
851 let removed_repositories = if done {
852 mem::take(&mut message.removed_repositories)
853 } else {
854 Default::default()
855 };
856
857 Some(UpdateWorktree {
858 project_id: message.project_id,
859 worktree_id: message.worktree_id,
860 root_name: message.root_name.clone(),
861 abs_path: message.abs_path.clone(),
862 updated_entries,
863 removed_entries,
864 scan_id: message.scan_id,
865 is_last_update: done && message.is_last_update,
866 updated_repositories,
867 removed_repositories,
868 })
869 })
870}
871
872pub fn split_repository_update(
873 mut update: UpdateRepository,
874) -> impl Iterator<Item = UpdateRepository> {
875 let mut updated_statuses_iter = mem::take(&mut update.updated_statuses).into_iter().fuse();
876 let mut removed_statuses_iter = mem::take(&mut update.removed_statuses).into_iter().fuse();
877 std::iter::from_fn({
878 let update = update.clone();
879 move || {
880 let updated_statuses = updated_statuses_iter
881 .by_ref()
882 .take(MAX_WORKTREE_UPDATE_MAX_CHUNK_SIZE)
883 .collect::<Vec<_>>();
884 let removed_statuses = removed_statuses_iter
885 .by_ref()
886 .take(MAX_WORKTREE_UPDATE_MAX_CHUNK_SIZE)
887 .collect::<Vec<_>>();
888 if updated_statuses.is_empty() && removed_statuses.is_empty() {
889 return None;
890 }
891 Some(UpdateRepository {
892 updated_statuses,
893 removed_statuses,
894 is_last_update: false,
895 ..update.clone()
896 })
897 }
898 })
899 .chain([UpdateRepository {
900 updated_statuses: Vec::new(),
901 removed_statuses: Vec::new(),
902 is_last_update: true,
903 ..update
904 }])
905}
906
907impl LspQuery {
908 pub fn query_name_and_write_permissions(&self) -> (&str, bool) {
909 match self.request {
910 Some(lsp_query::Request::GetHover(_)) => ("GetHover", false),
911 Some(lsp_query::Request::GetCodeActions(_)) => ("GetCodeActions", true),
912 Some(lsp_query::Request::GetSignatureHelp(_)) => ("GetSignatureHelp", false),
913 Some(lsp_query::Request::GetCodeLens(_)) => ("GetCodeLens", true),
914 Some(lsp_query::Request::GetDocumentDiagnostics(_)) => {
915 ("GetDocumentDiagnostics", false)
916 }
917 Some(lsp_query::Request::GetDefinition(_)) => ("GetDefinition", false),
918 Some(lsp_query::Request::GetDeclaration(_)) => ("GetDeclaration", false),
919 Some(lsp_query::Request::GetTypeDefinition(_)) => ("GetTypeDefinition", false),
920 Some(lsp_query::Request::GetImplementation(_)) => ("GetImplementation", false),
921 Some(lsp_query::Request::GetReferences(_)) => ("GetReferences", false),
922 Some(lsp_query::Request::GetDocumentColor(_)) => ("GetDocumentColor", false),
923 Some(lsp_query::Request::InlayHints(_)) => ("InlayHints", false),
924 Some(lsp_query::Request::SemanticTokens(_)) => ("SemanticTokens", false),
925 None => ("<unknown>", true),
926 }
927 }
928}
929
930#[cfg(test)]
931mod tests {
932 use super::*;
933
934 #[test]
935 fn test_converting_peer_id_from_and_to_u64() {
936 let peer_id = PeerId {
937 owner_id: 10,
938 id: 3,
939 };
940 assert_eq!(PeerId::from_u64(peer_id.as_u64()), peer_id);
941 let peer_id = PeerId {
942 owner_id: u32::MAX,
943 id: 3,
944 };
945 assert_eq!(PeerId::from_u64(peer_id.as_u64()), peer_id);
946 let peer_id = PeerId {
947 owner_id: 10,
948 id: u32::MAX,
949 };
950 assert_eq!(PeerId::from_u64(peer_id.as_u64()), peer_id);
951 let peer_id = PeerId {
952 owner_id: u32::MAX,
953 id: u32::MAX,
954 };
955 assert_eq!(PeerId::from_u64(peer_id.as_u64()), peer_id);
956 }
957}