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