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 (GetHover, GetHoverResponse, true),
565 (GetCodeActions, GetCodeActionsResponse, true),
566 (GetSignatureHelp, GetSignatureHelpResponse, true),
567 (GetCodeLens, GetCodeLensResponse, true),
568 (GetDocumentDiagnostics, GetDocumentDiagnosticsResponse, true),
569 (GetDefinition, GetDefinitionResponse, true),
570 (GetDeclaration, GetDeclarationResponse, true),
571 (GetTypeDefinition, GetTypeDefinitionResponse, true),
572 (GetImplementation, GetImplementationResponse, true),
573 (InlayHints, InlayHintsResponse, false),
574 (SemanticTokens, SemanticTokensResponse, true)
575);
576
577entity_messages!(
578 {project_id, ShareProject},
579 AddProjectCollaborator,
580 AddWorktree,
581 AllocateWorktreeId,
582 ApplyCodeAction,
583 ApplyCompletionAdditionalEdits,
584 BlameBuffer,
585 BufferReloaded,
586 BufferSaved,
587 CloseBuffer,
588 Commit,
589 RunGitHook,
590 GetColorPresentation,
591 CopyProjectEntry,
592 CreateBufferForPeer,
593 CreateFileForPeer,
594 CreateImageForPeer,
595 CreateProjectEntry,
596 GetDocumentColor,
597 GetFoldingRanges,
598 DeleteProjectEntry,
599 ExpandProjectEntry,
600 ExpandAllForProjectEntry,
601 FindSearchCandidates,
602 ApplyCodeActionKind,
603 FormatBuffers,
604 GetCodeActions,
605 GetCodeLens,
606 GetCompletions,
607 GetDefinition,
608 GetDeclaration,
609 GetImplementation,
610 GetDocumentHighlights,
611 GetDocumentSymbols,
612 GetHover,
613 GetProjectSymbols,
614 GetReferences,
615 GetSignatureHelp,
616 OpenUnstagedDiff,
617 OpenUncommittedDiff,
618 GetTypeDefinition,
619 InlayHints,
620 SemanticTokens,
621 JoinProject,
622 LeaveProject,
623 LinkedEditingRange,
624 LoadCommitDiff,
625 LspQuery,
626 LspQueryResponse,
627 RestartLanguageServers,
628 StopLanguageServers,
629 OnTypeFormatting,
630 OpenNewBuffer,
631 OpenBufferById,
632 OpenBufferByPath,
633 OpenImageByPath,
634 OpenBufferForSymbol,
635 OpenCommitMessageBuffer,
636 PerformRename,
637 PrepareRename,
638 RefreshInlayHints,
639 RefreshSemanticTokens,
640 RefreshCodeLens,
641 ReloadBuffers,
642 RemoveProjectCollaborator,
643 RenameProjectEntry,
644 ResolveCompletionDocumentation,
645 ResolveInlayHint,
646 SaveBuffer,
647 Stage,
648 StartLanguageServer,
649 SynchronizeBuffers,
650 TaskContextForLocation,
651 UnshareProject,
652 Unstage,
653 Stash,
654 StashPop,
655 StashApply,
656 StashDrop,
657 UpdateBuffer,
658 UpdateBufferFile,
659 UpdateDiagnosticSummary,
660 UpdateDiffBases,
661 UpdateLanguageServer,
662 UpdateProject,
663 UpdateProjectCollaborator,
664 UpdateWorktree,
665 UpdateRepository,
666 RemoveRepository,
667 UpdateWorktreeSettings,
668 UpdateUserSettings,
669 LspExtExpandMacro,
670 LspExtOpenDocs,
671 LspExtRunnables,
672 AdvertiseContexts,
673 OpenContext,
674 CreateContext,
675 UpdateContext,
676 SynchronizeContexts,
677 LspExtSwitchSourceHeader,
678 LspExtGoToParentModule,
679 LspExtCancelFlycheck,
680 LspExtRunFlycheck,
681 LspExtClearFlycheck,
682 LanguageServerLog,
683 Toast,
684 HideToast,
685 OpenServerSettings,
686 GetPermalinkToLine,
687 LanguageServerPromptRequest,
688 GitGetBranches,
689 UpdateGitBranch,
690 ListToolchains,
691 ActivateToolchain,
692 ActiveToolchain,
693 ResolveToolchain,
694 GetPathMetadata,
695 GetProcesses,
696 CancelLanguageServerWork,
697 RegisterBufferWithLanguageServers,
698 GitShow,
699 GitFileHistory,
700 GitReset,
701 GitDeleteBranch,
702 GitCheckoutFiles,
703 SetIndexText,
704 ToggleLspLogs,
705 GetDirectoryEnvironment,
706
707 Push,
708 Fetch,
709 GetRemotes,
710 Pull,
711 AskPassRequest,
712 GitChangeBranch,
713 GitRenameBranch,
714 GitCreateBranch,
715 GitCreateRemote,
716 GitRemoveRemote,
717 CheckForPushedCommits,
718 GitDiff,
719 GitInit,
720 BreakpointsForFile,
721 ToggleBreakpoint,
722 RunDebugLocators,
723 GetDebugAdapterBinary,
724 LogToDebugConsole,
725 GetDocumentDiagnostics,
726 PullWorkspaceDiagnostics,
727 GetDefaultBranch,
728 GetTreeDiff,
729 GetBlobContent,
730 GitClone,
731 GetAgentServerCommand,
732 GetContextServerCommand,
733 ExternalAgentsUpdated,
734 ExternalExtensionAgentsUpdated,
735 ExternalAgentLoadingStatusUpdated,
736 NewExternalAgentVersionAvailable,
737 GitGetWorktrees,
738 GitCreateWorktree,
739 TrustWorktrees,
740 RestrictWorktrees,
741 FindSearchCandidatesChunk,
742 FindSearchCandidatesCancelled,
743 DownloadFileByPath
744);
745
746entity_messages!(
747 {channel_id, Channel},
748 ChannelMessageSent,
749 ChannelMessageUpdate,
750 RemoveChannelMessage,
751 UpdateChannelMessage,
752 UpdateChannelBuffer,
753 UpdateChannelBufferCollaborators,
754);
755
756impl From<Timestamp> for SystemTime {
757 fn from(val: Timestamp) -> Self {
758 UNIX_EPOCH
759 .checked_add(Duration::new(val.seconds, val.nanos))
760 .unwrap()
761 }
762}
763
764impl From<SystemTime> for Timestamp {
765 fn from(time: SystemTime) -> Self {
766 let duration = time.duration_since(UNIX_EPOCH).unwrap_or_default();
767 Self {
768 seconds: duration.as_secs(),
769 nanos: duration.subsec_nanos(),
770 }
771 }
772}
773
774impl From<u128> for Nonce {
775 fn from(nonce: u128) -> Self {
776 let upper_half = (nonce >> 64) as u64;
777 let lower_half = nonce as u64;
778 Self {
779 upper_half,
780 lower_half,
781 }
782 }
783}
784
785impl From<Nonce> for u128 {
786 fn from(nonce: Nonce) -> Self {
787 let upper_half = (nonce.upper_half as u128) << 64;
788 let lower_half = nonce.lower_half as u128;
789 upper_half | lower_half
790 }
791}
792
793#[cfg(any(test, feature = "test-support"))]
794pub const MAX_WORKTREE_UPDATE_MAX_CHUNK_SIZE: usize = 2;
795#[cfg(not(any(test, feature = "test-support")))]
796pub const MAX_WORKTREE_UPDATE_MAX_CHUNK_SIZE: usize = 256;
797
798pub fn split_worktree_update(mut message: UpdateWorktree) -> impl Iterator<Item = UpdateWorktree> {
799 let mut done = false;
800
801 iter::from_fn(move || {
802 if done {
803 return None;
804 }
805
806 let updated_entries_chunk_size = cmp::min(
807 message.updated_entries.len(),
808 MAX_WORKTREE_UPDATE_MAX_CHUNK_SIZE,
809 );
810 let updated_entries: Vec<_> = message
811 .updated_entries
812 .drain(..updated_entries_chunk_size)
813 .collect();
814
815 let removed_entries_chunk_size = cmp::min(
816 message.removed_entries.len(),
817 MAX_WORKTREE_UPDATE_MAX_CHUNK_SIZE,
818 );
819 let removed_entries = message
820 .removed_entries
821 .drain(..removed_entries_chunk_size)
822 .collect();
823
824 let mut updated_repositories = Vec::new();
825 let mut limit = MAX_WORKTREE_UPDATE_MAX_CHUNK_SIZE;
826 while let Some(repo) = message.updated_repositories.first_mut() {
827 let updated_statuses_limit = cmp::min(repo.updated_statuses.len(), limit);
828 let removed_statuses_limit = cmp::min(repo.removed_statuses.len(), limit);
829
830 updated_repositories.push(RepositoryEntry {
831 repository_id: repo.repository_id,
832 branch_summary: repo.branch_summary.clone(),
833 updated_statuses: repo
834 .updated_statuses
835 .drain(..updated_statuses_limit)
836 .collect(),
837 removed_statuses: repo
838 .removed_statuses
839 .drain(..removed_statuses_limit)
840 .collect(),
841 current_merge_conflicts: repo.current_merge_conflicts.clone(),
842 });
843 if repo.removed_statuses.is_empty() && repo.updated_statuses.is_empty() {
844 message.updated_repositories.remove(0);
845 }
846 limit = limit.saturating_sub(removed_statuses_limit + updated_statuses_limit);
847 if limit == 0 {
848 break;
849 }
850 }
851
852 done = message.updated_entries.is_empty()
853 && message.removed_entries.is_empty()
854 && message.updated_repositories.is_empty();
855
856 let removed_repositories = if done {
857 mem::take(&mut message.removed_repositories)
858 } else {
859 Default::default()
860 };
861
862 Some(UpdateWorktree {
863 project_id: message.project_id,
864 worktree_id: message.worktree_id,
865 root_name: message.root_name.clone(),
866 abs_path: message.abs_path.clone(),
867 updated_entries,
868 removed_entries,
869 scan_id: message.scan_id,
870 is_last_update: done && message.is_last_update,
871 updated_repositories,
872 removed_repositories,
873 })
874 })
875}
876
877pub fn split_repository_update(
878 mut update: UpdateRepository,
879) -> impl Iterator<Item = UpdateRepository> {
880 let mut updated_statuses_iter = mem::take(&mut update.updated_statuses).into_iter().fuse();
881 let mut removed_statuses_iter = mem::take(&mut update.removed_statuses).into_iter().fuse();
882 std::iter::from_fn({
883 let update = update.clone();
884 move || {
885 let updated_statuses = updated_statuses_iter
886 .by_ref()
887 .take(MAX_WORKTREE_UPDATE_MAX_CHUNK_SIZE)
888 .collect::<Vec<_>>();
889 let removed_statuses = removed_statuses_iter
890 .by_ref()
891 .take(MAX_WORKTREE_UPDATE_MAX_CHUNK_SIZE)
892 .collect::<Vec<_>>();
893 if updated_statuses.is_empty() && removed_statuses.is_empty() {
894 return None;
895 }
896 Some(UpdateRepository {
897 updated_statuses,
898 removed_statuses,
899 is_last_update: false,
900 ..update.clone()
901 })
902 }
903 })
904 .chain([UpdateRepository {
905 updated_statuses: Vec::new(),
906 removed_statuses: Vec::new(),
907 is_last_update: true,
908 ..update
909 }])
910}
911
912impl LspQuery {
913 pub fn query_name_and_write_permissions(&self) -> (&str, bool) {
914 match self.request {
915 Some(lsp_query::Request::GetHover(_)) => ("GetHover", false),
916 Some(lsp_query::Request::GetCodeActions(_)) => ("GetCodeActions", true),
917 Some(lsp_query::Request::GetSignatureHelp(_)) => ("GetSignatureHelp", false),
918 Some(lsp_query::Request::GetCodeLens(_)) => ("GetCodeLens", true),
919 Some(lsp_query::Request::GetDocumentDiagnostics(_)) => {
920 ("GetDocumentDiagnostics", false)
921 }
922 Some(lsp_query::Request::GetDefinition(_)) => ("GetDefinition", false),
923 Some(lsp_query::Request::GetDeclaration(_)) => ("GetDeclaration", false),
924 Some(lsp_query::Request::GetTypeDefinition(_)) => ("GetTypeDefinition", false),
925 Some(lsp_query::Request::GetImplementation(_)) => ("GetImplementation", false),
926 Some(lsp_query::Request::GetReferences(_)) => ("GetReferences", false),
927 Some(lsp_query::Request::GetDocumentColor(_)) => ("GetDocumentColor", false),
928 Some(lsp_query::Request::GetFoldingRanges(_)) => ("GetFoldingRanges", false),
929 Some(lsp_query::Request::InlayHints(_)) => ("InlayHints", false),
930 Some(lsp_query::Request::SemanticTokens(_)) => ("SemanticTokens", false),
931 None => ("<unknown>", true),
932 }
933 }
934}
935
936#[cfg(test)]
937mod tests {
938 use super::*;
939
940 #[test]
941 fn test_converting_peer_id_from_and_to_u64() {
942 let peer_id = PeerId {
943 owner_id: 10,
944 id: 3,
945 };
946 assert_eq!(PeerId::from_u64(peer_id.as_u64()), peer_id);
947 let peer_id = PeerId {
948 owner_id: u32::MAX,
949 id: 3,
950 };
951 assert_eq!(PeerId::from_u64(peer_id.as_u64()), peer_id);
952 let peer_id = PeerId {
953 owner_id: 10,
954 id: u32::MAX,
955 };
956 assert_eq!(PeerId::from_u64(peer_id.as_u64()), peer_id);
957 let peer_id = PeerId {
958 owner_id: u32::MAX,
959 id: u32::MAX,
960 };
961 assert_eq!(PeerId::from_u64(peer_id.as_u64()), peer_id);
962 }
963}