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 (GetCrashFiles, Background),
103 (GetCrashFilesResponse, 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 (OpenUnstagedDiff, Foreground),
123 (OpenUnstagedDiffResponse, Foreground),
124 (OpenUncommittedDiff, Foreground),
125 (OpenUncommittedDiffResponse, Foreground),
126 (GetUsers, Foreground),
127 (GitGetBranches, Background),
128 (GitBranchesResponse, Background),
129 (Hello, Foreground),
130 (HideToast, Background),
131 (IncomingCall, Foreground),
132 (InlayHints, Background),
133 (InlayHintsResponse, Background),
134 (InstallExtension, Background),
135 (InviteChannelMember, Foreground),
136 (JoinChannel, Foreground),
137 (JoinChannelBuffer, Foreground),
138 (JoinChannelBufferResponse, Foreground),
139 (JoinChannelChat, Foreground),
140 (JoinChannelChatResponse, Foreground),
141 (JoinProject, Foreground),
142 (JoinProjectResponse, Foreground),
143 (JoinRoom, Foreground),
144 (JoinRoomResponse, Foreground),
145 (LanguageServerLog, Foreground),
146 (LanguageServerPromptRequest, Foreground),
147 (LanguageServerPromptResponse, Foreground),
148 (LeaveChannelBuffer, Background),
149 (LeaveChannelChat, Foreground),
150 (LeaveProject, Foreground),
151 (LeaveRoom, Foreground),
152 (LinkedEditingRange, Background),
153 (LinkedEditingRangeResponse, Background),
154 (ListRemoteDirectory, Background),
155 (ListRemoteDirectoryResponse, Background),
156 (ListToolchains, Foreground),
157 (ListToolchainsResponse, Foreground),
158 (LoadCommitDiff, Foreground),
159 (LoadCommitDiffResponse, Foreground),
160 (LspExtExpandMacro, Background),
161 (LspExtExpandMacroResponse, Background),
162 (LspExtOpenDocs, Background),
163 (LspExtOpenDocsResponse, Background),
164 (LspExtRunnables, Background),
165 (LspExtRunnablesResponse, Background),
166 (LspExtSwitchSourceHeader, Background),
167 (LspExtSwitchSourceHeaderResponse, Background),
168 (LspExtGoToParentModule, Background),
169 (LspExtGoToParentModuleResponse, Background),
170 (LspExtCancelFlycheck, Background),
171 (LspExtRunFlycheck, Background),
172 (LspExtClearFlycheck, Background),
173 (MarkNotificationRead, Foreground),
174 (MoveChannel, Foreground),
175 (ReorderChannel, Foreground),
176 (MultiLspQuery, Background),
177 (MultiLspQueryResponse, Background),
178 (OnTypeFormatting, Background),
179 (OnTypeFormattingResponse, Background),
180 (OpenBufferById, Background),
181 (OpenBufferByPath, Background),
182 (OpenBufferForSymbol, Background),
183 (OpenBufferForSymbolResponse, Background),
184 (OpenBufferResponse, Background),
185 (OpenCommitMessageBuffer, Background),
186 (OpenContext, Foreground),
187 (OpenContextResponse, Foreground),
188 (OpenNewBuffer, Foreground),
189 (OpenServerSettings, Foreground),
190 (PerformRename, Background),
191 (PerformRenameResponse, Background),
192 (Ping, Foreground),
193 (PrepareRename, Background),
194 (PrepareRenameResponse, Background),
195 (ProjectEntryResponse, Foreground),
196 (RefreshInlayHints, Foreground),
197 (RegisterBufferWithLanguageServers, Background),
198 (RejoinChannelBuffers, Foreground),
199 (RejoinChannelBuffersResponse, Foreground),
200 (RejoinRemoteProjects, Foreground),
201 (RejoinRemoteProjectsResponse, Foreground),
202 (RejoinRoom, Foreground),
203 (RejoinRoomResponse, Foreground),
204 (ReloadBuffers, Foreground),
205 (ReloadBuffersResponse, Foreground),
206 (RemoveChannelMember, Foreground),
207 (RemoveChannelMessage, Foreground),
208 (RemoveContact, Foreground),
209 (RemoveProjectCollaborator, Foreground),
210 (RemoveWorktree, Foreground),
211 (RenameChannel, Foreground),
212 (RenameChannelResponse, Foreground),
213 (RenameProjectEntry, Foreground),
214 (RequestContact, Foreground),
215 (ResolveCompletionDocumentation, Background),
216 (ResolveCompletionDocumentationResponse, Background),
217 (ResolveInlayHint, Background),
218 (ResolveInlayHintResponse, Background),
219 (GetDocumentColor, Background),
220 (GetDocumentColorResponse, Background),
221 (GetColorPresentation, Background),
222 (GetColorPresentationResponse, Background),
223 (RefreshCodeLens, Background),
224 (GetCodeLens, Background),
225 (GetCodeLensResponse, Background),
226 (RespondToChannelInvite, Foreground),
227 (RespondToContactRequest, Foreground),
228 (RestartLanguageServers, Foreground),
229 (StopLanguageServers, Background),
230 (RoomUpdated, Foreground),
231 (SaveBuffer, Foreground),
232 (SendChannelMessage, Background),
233 (SendChannelMessageResponse, Background),
234 (SetChannelMemberRole, Foreground),
235 (SetChannelVisibility, Foreground),
236 (SetRoomParticipantRole, Foreground),
237 (ShareProject, Foreground),
238 (ShareProjectResponse, Foreground),
239 (ShowContacts, Foreground),
240 (ShutdownRemoteServer, Foreground),
241 (Stage, Background),
242 (StartLanguageServer, Foreground),
243 (SubscribeToChannels, Foreground),
244 (SyncExtensions, Background),
245 (SyncExtensionsResponse, Background),
246 (BreakpointsForFile, Background),
247 (ToggleBreakpoint, Foreground),
248 (SynchronizeBuffers, Foreground),
249 (SynchronizeBuffersResponse, Foreground),
250 (SynchronizeContexts, Foreground),
251 (SynchronizeContextsResponse, Foreground),
252 (TaskContext, Background),
253 (TaskContextForLocation, Background),
254 (Test, Foreground),
255 (Toast, Background),
256 (Unfollow, Foreground),
257 (UnshareProject, Foreground),
258 (Unstage, Background),
259 (Stash, Background),
260 (StashPop, Background),
261 (UpdateBuffer, Foreground),
262 (UpdateBufferFile, Foreground),
263 (UpdateChannelBuffer, Foreground),
264 (UpdateChannelBufferCollaborators, Foreground),
265 (UpdateChannelMessage, Foreground),
266 (UpdateChannels, Foreground),
267 (UpdateContacts, Foreground),
268 (UpdateContext, Foreground),
269 (UpdateDiagnosticSummary, Foreground),
270 (UpdateDiffBases, Foreground),
271 (UpdateFollowers, Foreground),
272 (UpdateGitBranch, Background),
273 (UpdateInviteInfo, Foreground),
274 (UpdateLanguageServer, Foreground),
275 (UpdateNotification, Foreground),
276 (UpdateParticipantLocation, Foreground),
277 (UpdateProject, Foreground),
278 (UpdateProjectCollaborator, Foreground),
279 (UpdateUserChannels, Foreground),
280 (UpdateUserPlan, Foreground),
281 (UpdateWorktree, Foreground),
282 (UpdateWorktreeSettings, Foreground),
283 (UpdateRepository, Foreground),
284 (RemoveRepository, Foreground),
285 (UsersResponse, Foreground),
286 (GitReset, Background),
287 (GitCheckoutFiles, Background),
288 (GitShow, Background),
289 (GitCommitDetails, Background),
290 (SetIndexText, Background),
291 (Push, Background),
292 (Fetch, Background),
293 (GetRemotes, Background),
294 (GetRemotesResponse, Background),
295 (Pull, Background),
296 (RemoteMessageResponse, Background),
297 (AskPassRequest, Background),
298 (AskPassResponse, Background),
299 (GitCreateBranch, Background),
300 (GitChangeBranch, Background),
301 (CheckForPushedCommits, Background),
302 (CheckForPushedCommitsResponse, Background),
303 (GitDiff, Background),
304 (GitDiffResponse, Background),
305 (GitInit, Background),
306 (GetDebugAdapterBinary, Background),
307 (DebugAdapterBinary, Background),
308 (RunDebugLocators, Background),
309 (DebugRequest, Background),
310 (LogToDebugConsole, Background),
311 (GetDocumentDiagnostics, Background),
312 (GetDocumentDiagnosticsResponse, Background),
313 (PullWorkspaceDiagnostics, Background),
314 (GetDefaultBranch, Background),
315 (GetDefaultBranchResponse, Background),
316 (GitClone, Background),
317 (GitCloneResponse, Background)
318);
319
320request_messages!(
321 (AcceptTermsOfService, AcceptTermsOfServiceResponse),
322 (ApplyCodeAction, ApplyCodeActionResponse),
323 (
324 ApplyCompletionAdditionalEdits,
325 ApplyCompletionAdditionalEditsResponse
326 ),
327 (Call, Ack),
328 (CancelCall, Ack),
329 (Commit, Ack),
330 (CopyProjectEntry, ProjectEntryResponse),
331 (CreateChannel, CreateChannelResponse),
332 (CreateProjectEntry, ProjectEntryResponse),
333 (CreateRoom, CreateRoomResponse),
334 (DeclineCall, Ack),
335 (DeleteChannel, Ack),
336 (DeleteProjectEntry, ProjectEntryResponse),
337 (ExpandProjectEntry, ExpandProjectEntryResponse),
338 (ExpandAllForProjectEntry, ExpandAllForProjectEntryResponse),
339 (Follow, FollowResponse),
340 (ApplyCodeActionKind, ApplyCodeActionKindResponse),
341 (FormatBuffers, FormatBuffersResponse),
342 (FuzzySearchUsers, UsersResponse),
343 (GetChannelMembers, GetChannelMembersResponse),
344 (GetChannelMessages, GetChannelMessagesResponse),
345 (GetChannelMessagesById, GetChannelMessagesResponse),
346 (GetCodeActions, GetCodeActionsResponse),
347 (GetCompletions, GetCompletionsResponse),
348 (GetDefinition, GetDefinitionResponse),
349 (GetDeclaration, GetDeclarationResponse),
350 (GetImplementation, GetImplementationResponse),
351 (GetDocumentHighlights, GetDocumentHighlightsResponse),
352 (GetDocumentSymbols, GetDocumentSymbolsResponse),
353 (GetHover, GetHoverResponse),
354 (GetNotifications, GetNotificationsResponse),
355 (GetPrivateUserInfo, GetPrivateUserInfoResponse),
356 (GetProjectSymbols, GetProjectSymbolsResponse),
357 (GetReferences, GetReferencesResponse),
358 (GetSignatureHelp, GetSignatureHelpResponse),
359 (OpenUnstagedDiff, OpenUnstagedDiffResponse),
360 (OpenUncommittedDiff, OpenUncommittedDiffResponse),
361 (GetSupermavenApiKey, GetSupermavenApiKeyResponse),
362 (GetTypeDefinition, GetTypeDefinitionResponse),
363 (LinkedEditingRange, LinkedEditingRangeResponse),
364 (ListRemoteDirectory, ListRemoteDirectoryResponse),
365 (GetUsers, UsersResponse),
366 (IncomingCall, Ack),
367 (InlayHints, InlayHintsResponse),
368 (GetCodeLens, GetCodeLensResponse),
369 (InviteChannelMember, Ack),
370 (JoinChannel, JoinRoomResponse),
371 (JoinChannelBuffer, JoinChannelBufferResponse),
372 (JoinChannelChat, JoinChannelChatResponse),
373 (JoinProject, JoinProjectResponse),
374 (JoinRoom, JoinRoomResponse),
375 (LeaveChannelBuffer, Ack),
376 (LeaveRoom, Ack),
377 (LoadCommitDiff, LoadCommitDiffResponse),
378 (MarkNotificationRead, Ack),
379 (MoveChannel, Ack),
380 (OnTypeFormatting, OnTypeFormattingResponse),
381 (OpenBufferById, OpenBufferResponse),
382 (OpenBufferByPath, OpenBufferResponse),
383 (OpenBufferForSymbol, OpenBufferForSymbolResponse),
384 (OpenCommitMessageBuffer, OpenBufferResponse),
385 (OpenNewBuffer, OpenBufferResponse),
386 (PerformRename, PerformRenameResponse),
387 (Ping, Ack),
388 (PrepareRename, PrepareRenameResponse),
389 (RefreshInlayHints, Ack),
390 (RefreshCodeLens, Ack),
391 (RejoinChannelBuffers, RejoinChannelBuffersResponse),
392 (RejoinRoom, RejoinRoomResponse),
393 (ReloadBuffers, ReloadBuffersResponse),
394 (RemoveChannelMember, Ack),
395 (RemoveChannelMessage, Ack),
396 (UpdateChannelMessage, Ack),
397 (RemoveContact, Ack),
398 (RenameChannel, RenameChannelResponse),
399 (RenameProjectEntry, ProjectEntryResponse),
400 (ReorderChannel, Ack),
401 (RequestContact, Ack),
402 (
403 ResolveCompletionDocumentation,
404 ResolveCompletionDocumentationResponse
405 ),
406 (ResolveInlayHint, ResolveInlayHintResponse),
407 (GetDocumentColor, GetDocumentColorResponse),
408 (GetColorPresentation, GetColorPresentationResponse),
409 (RespondToChannelInvite, Ack),
410 (RespondToContactRequest, Ack),
411 (SaveBuffer, BufferSaved),
412 (Stage, Ack),
413 (FindSearchCandidates, FindSearchCandidatesResponse),
414 (SendChannelMessage, SendChannelMessageResponse),
415 (SetChannelMemberRole, Ack),
416 (SetChannelVisibility, Ack),
417 (ShareProject, ShareProjectResponse),
418 (SynchronizeBuffers, SynchronizeBuffersResponse),
419 (TaskContextForLocation, TaskContext),
420 (Test, Test),
421 (Unstage, Ack),
422 (Stash, Ack),
423 (StashPop, Ack),
424 (UpdateBuffer, Ack),
425 (UpdateParticipantLocation, Ack),
426 (UpdateProject, Ack),
427 (UpdateWorktree, Ack),
428 (UpdateRepository, Ack),
429 (RemoveRepository, Ack),
430 (LspExtExpandMacro, LspExtExpandMacroResponse),
431 (LspExtOpenDocs, LspExtOpenDocsResponse),
432 (LspExtRunnables, LspExtRunnablesResponse),
433 (SetRoomParticipantRole, Ack),
434 (BlameBuffer, BlameBufferResponse),
435 (RejoinRemoteProjects, RejoinRemoteProjectsResponse),
436 (MultiLspQuery, MultiLspQueryResponse),
437 (RestartLanguageServers, Ack),
438 (StopLanguageServers, Ack),
439 (OpenContext, OpenContextResponse),
440 (CreateContext, CreateContextResponse),
441 (SynchronizeContexts, SynchronizeContextsResponse),
442 (LspExtSwitchSourceHeader, LspExtSwitchSourceHeaderResponse),
443 (LspExtGoToParentModule, LspExtGoToParentModuleResponse),
444 (LspExtCancelFlycheck, Ack),
445 (LspExtRunFlycheck, Ack),
446 (LspExtClearFlycheck, Ack),
447 (AddWorktree, AddWorktreeResponse),
448 (ShutdownRemoteServer, Ack),
449 (RemoveWorktree, Ack),
450 (OpenServerSettings, OpenBufferResponse),
451 (GetPermalinkToLine, GetPermalinkToLineResponse),
452 (FlushBufferedMessages, Ack),
453 (LanguageServerPromptRequest, LanguageServerPromptResponse),
454 (GitGetBranches, GitBranchesResponse),
455 (UpdateGitBranch, Ack),
456 (ListToolchains, ListToolchainsResponse),
457 (ActivateToolchain, Ack),
458 (ActiveToolchain, ActiveToolchainResponse),
459 (GetPathMetadata, GetPathMetadataResponse),
460 (GetCrashFiles, GetCrashFilesResponse),
461 (CancelLanguageServerWork, Ack),
462 (SyncExtensions, SyncExtensionsResponse),
463 (InstallExtension, Ack),
464 (RegisterBufferWithLanguageServers, Ack),
465 (GitShow, GitCommitDetails),
466 (GitReset, Ack),
467 (GitCheckoutFiles, Ack),
468 (SetIndexText, Ack),
469 (Push, RemoteMessageResponse),
470 (Fetch, RemoteMessageResponse),
471 (GetRemotes, GetRemotesResponse),
472 (Pull, RemoteMessageResponse),
473 (AskPassRequest, AskPassResponse),
474 (GitCreateBranch, Ack),
475 (GitChangeBranch, Ack),
476 (CheckForPushedCommits, CheckForPushedCommitsResponse),
477 (GitDiff, GitDiffResponse),
478 (GitInit, Ack),
479 (ToggleBreakpoint, Ack),
480 (GetDebugAdapterBinary, DebugAdapterBinary),
481 (RunDebugLocators, DebugRequest),
482 (GetDocumentDiagnostics, GetDocumentDiagnosticsResponse),
483 (PullWorkspaceDiagnostics, Ack),
484 (GetDefaultBranch, GetDefaultBranchResponse),
485 (GitClone, GitCloneResponse)
486);
487
488entity_messages!(
489 {project_id, ShareProject},
490 AddProjectCollaborator,
491 AddWorktree,
492 ApplyCodeAction,
493 ApplyCompletionAdditionalEdits,
494 BlameBuffer,
495 BufferReloaded,
496 BufferSaved,
497 CloseBuffer,
498 Commit,
499 GetColorPresentation,
500 CopyProjectEntry,
501 CreateBufferForPeer,
502 CreateProjectEntry,
503 GetDocumentColor,
504 DeleteProjectEntry,
505 ExpandProjectEntry,
506 ExpandAllForProjectEntry,
507 FindSearchCandidates,
508 ApplyCodeActionKind,
509 FormatBuffers,
510 GetCodeActions,
511 GetCodeLens,
512 GetCompletions,
513 GetDefinition,
514 GetDeclaration,
515 GetImplementation,
516 GetDocumentHighlights,
517 GetDocumentSymbols,
518 GetHover,
519 GetProjectSymbols,
520 GetReferences,
521 GetSignatureHelp,
522 OpenUnstagedDiff,
523 OpenUncommittedDiff,
524 GetTypeDefinition,
525 InlayHints,
526 JoinProject,
527 LeaveProject,
528 LinkedEditingRange,
529 LoadCommitDiff,
530 MultiLspQuery,
531 RestartLanguageServers,
532 StopLanguageServers,
533 OnTypeFormatting,
534 OpenNewBuffer,
535 OpenBufferById,
536 OpenBufferByPath,
537 OpenBufferForSymbol,
538 OpenCommitMessageBuffer,
539 PerformRename,
540 PrepareRename,
541 RefreshInlayHints,
542 RefreshCodeLens,
543 ReloadBuffers,
544 RemoveProjectCollaborator,
545 RenameProjectEntry,
546 ResolveCompletionDocumentation,
547 ResolveInlayHint,
548 SaveBuffer,
549 Stage,
550 StartLanguageServer,
551 SynchronizeBuffers,
552 TaskContextForLocation,
553 UnshareProject,
554 Unstage,
555 Stash,
556 StashPop,
557 UpdateBuffer,
558 UpdateBufferFile,
559 UpdateDiagnosticSummary,
560 UpdateDiffBases,
561 UpdateLanguageServer,
562 UpdateProject,
563 UpdateProjectCollaborator,
564 UpdateWorktree,
565 UpdateRepository,
566 RemoveRepository,
567 UpdateWorktreeSettings,
568 LspExtExpandMacro,
569 LspExtOpenDocs,
570 LspExtRunnables,
571 AdvertiseContexts,
572 OpenContext,
573 CreateContext,
574 UpdateContext,
575 SynchronizeContexts,
576 LspExtSwitchSourceHeader,
577 LspExtGoToParentModule,
578 LspExtCancelFlycheck,
579 LspExtRunFlycheck,
580 LspExtClearFlycheck,
581 LanguageServerLog,
582 Toast,
583 HideToast,
584 OpenServerSettings,
585 GetPermalinkToLine,
586 LanguageServerPromptRequest,
587 GitGetBranches,
588 UpdateGitBranch,
589 ListToolchains,
590 ActivateToolchain,
591 ActiveToolchain,
592 GetPathMetadata,
593 CancelLanguageServerWork,
594 RegisterBufferWithLanguageServers,
595 GitShow,
596 GitReset,
597 GitCheckoutFiles,
598 SetIndexText,
599
600 Push,
601 Fetch,
602 GetRemotes,
603 Pull,
604 AskPassRequest,
605 GitChangeBranch,
606 GitCreateBranch,
607 CheckForPushedCommits,
608 GitDiff,
609 GitInit,
610 BreakpointsForFile,
611 ToggleBreakpoint,
612 RunDebugLocators,
613 GetDebugAdapterBinary,
614 LogToDebugConsole,
615 GetDocumentDiagnostics,
616 PullWorkspaceDiagnostics,
617 GetDefaultBranch,
618 GitClone
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
787impl MultiLspQuery {
788 pub fn request_str(&self) -> &str {
789 match self.request {
790 Some(multi_lsp_query::Request::GetHover(_)) => "GetHover",
791 Some(multi_lsp_query::Request::GetCodeActions(_)) => "GetCodeActions",
792 Some(multi_lsp_query::Request::GetSignatureHelp(_)) => "GetSignatureHelp",
793 Some(multi_lsp_query::Request::GetCodeLens(_)) => "GetCodeLens",
794 Some(multi_lsp_query::Request::GetDocumentDiagnostics(_)) => "GetDocumentDiagnostics",
795 Some(multi_lsp_query::Request::GetDocumentColor(_)) => "GetDocumentColor",
796 Some(multi_lsp_query::Request::GetDefinition(_)) => "GetDefinition",
797 Some(multi_lsp_query::Request::GetDeclaration(_)) => "GetDeclaration",
798 Some(multi_lsp_query::Request::GetTypeDefinition(_)) => "GetTypeDefinition",
799 Some(multi_lsp_query::Request::GetImplementation(_)) => "GetImplementation",
800 Some(multi_lsp_query::Request::GetReferences(_)) => "GetReferences",
801 None => "<unknown>",
802 }
803 }
804}
805
806#[cfg(test)]
807mod tests {
808 use super::*;
809
810 #[test]
811 fn test_converting_peer_id_from_and_to_u64() {
812 let peer_id = PeerId {
813 owner_id: 10,
814 id: 3,
815 };
816 assert_eq!(PeerId::from_u64(peer_id.as_u64()), peer_id);
817 let peer_id = PeerId {
818 owner_id: u32::MAX,
819 id: 3,
820 };
821 assert_eq!(PeerId::from_u64(peer_id.as_u64()), peer_id);
822 let peer_id = PeerId {
823 owner_id: 10,
824 id: u32::MAX,
825 };
826 assert_eq!(PeerId::from_u64(peer_id.as_u64()), peer_id);
827 let peer_id = PeerId {
828 owner_id: u32::MAX,
829 id: u32::MAX,
830 };
831 assert_eq!(PeerId::from_u64(peer_id.as_u64()), peer_id);
832 }
833
834 #[test]
835 #[cfg(target_os = "windows")]
836 fn test_proto() {
837 use std::path::PathBuf;
838
839 fn generate_proto_path(path: PathBuf) -> PathBuf {
840 let proto = path.to_proto();
841 PathBuf::from_proto(proto)
842 }
843
844 let path = PathBuf::from("C:\\foo\\bar");
845 assert_eq!(path, generate_proto_path(path.clone()));
846
847 let path = PathBuf::from("C:/foo/bar/");
848 assert_eq!(path, generate_proto_path(path.clone()));
849
850 let path = PathBuf::from("C:/foo\\bar\\");
851 assert_eq!(path, generate_proto_path(path.clone()));
852 }
853}