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