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