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