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