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