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