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