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