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