1 //! The main loop of `rust-analyzer` responsible for dispatching LSP
2 //! requests/replies and notifications back to the client.
6 pub(crate) mod pending_requests;
14 time::{Duration, Instant},
17 use crossbeam_channel::{select, unbounded, RecvError, Sender};
18 use lsp_server::{Connection, ErrorCode, Message, Notification, Request, RequestId, Response};
19 use lsp_types::{ClientCapabilities, NumberOrString};
20 use ra_cargo_watch::{url_from_path_with_drive_lowercasing, CheckOptions, CheckTask};
21 use ra_ide::{Canceled, FeatureFlags, FileId, LibraryData, SourceRootId};
23 use ra_vfs::{VfsFile, VfsTask, Watch};
24 use relative_path::RelativePathBuf;
25 use rustc_hash::FxHashSet;
26 use serde::{de::DeserializeOwned, Serialize};
27 use threadpool::ThreadPool;
30 diagnostics::DiagnosticTask,
32 pending_requests::{PendingRequest, PendingRequests},
33 subscriptions::Subscriptions,
36 world::{Options, WorldSnapshot, WorldState},
47 pub fn new(code: i32, message: String) -> LspError {
48 LspError { code, message }
52 impl fmt::Display for LspError {
53 fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
54 write!(f, "Language Server request failed with {}. ({})", self.code, self.message)
58 impl Error for LspError {}
61 ws_roots: Vec<PathBuf>,
62 client_caps: ClientCapabilities,
64 connection: Connection,
66 log::info!("server_config: {:#?}", config);
68 // Windows scheduler implements priority boosts: if thread waits for an
69 // event (like a condvar), and event fires, priority of the thread is
70 // temporary bumped. This optimization backfires in our case: each time the
71 // `main_loop` schedules a task to run on a threadpool, the worker threads
72 // gets a higher priority, and (on a machine with fewer cores) displaces the
73 // main loop! We work-around this by marking the main loop as a
74 // higher-priority thread.
76 // https://docs.microsoft.com/en-us/windows/win32/procthread/scheduling-priorities
77 // https://docs.microsoft.com/en-us/windows/win32/procthread/priority-boosts
78 // https://github.com/rust-analyzer/rust-analyzer/issues/2835
81 use winapi::um::processthreadsapi::*;
82 let thread = GetCurrentThread();
83 let thread_priority_above_normal = 1;
84 SetThreadPriority(thread, thread_priority_above_normal);
87 let mut loop_state = LoopState::default();
88 let mut world_state = {
90 let mut ff = FeatureFlags::default();
91 for (flag, value) in config.feature_flags {
92 if ff.set(flag.as_str(), value).is_err() {
93 log::error!("unknown feature flag: {:?}", flag);
95 req::MessageType::Error,
96 format!("unknown feature flag: {:?}", flag),
103 log::info!("feature_flags: {:#?}", feature_flags);
105 // FIXME: support dynamic workspace loading.
107 let mut loaded_workspaces = Vec::new();
108 for ws_root in &ws_roots {
109 let workspace = ra_project_model::ProjectWorkspace::discover_with_sysroot(
112 &config.cargo_features,
115 Ok(workspace) => loaded_workspaces.push(workspace),
117 log::error!("loading workspace failed: {:?}", e);
119 if let Some(ra_project_model::CargoTomlNotFoundError { .. }) =
122 if !feature_flags.get("notifications.cargo-toml-not-found") {
128 req::MessageType::Error,
129 format!("rust-analyzer failed to load workspace: {:?}", e),
141 .map(|glob| crate::vfs_glob::Glob::new(glob))
142 .collect::<std::result::Result<Vec<_>, _>>()?;
144 if config.use_client_watching {
145 let registration_options = req::DidChangeWatchedFilesRegistrationOptions {
148 .flat_map(|ws| ws.to_roots())
149 .filter(|root| root.is_member())
150 .map(|root| format!("{}/**/*.rs", root.path().display()))
151 .map(|glob_pattern| req::FileSystemWatcher { glob_pattern, kind: None })
154 let registration = req::Registration {
155 id: "file-watcher".to_string(),
156 method: "workspace/didChangeWatchedFiles".to_string(),
157 register_options: Some(serde_json::to_value(registration_options).unwrap()),
159 let params = req::RegistrationParams { registrations: vec![registration] };
161 request_new::<req::RegisterCapability>(loop_state.next_request_id(), params);
162 connection.sender.send(request.into()).unwrap();
166 let text_document_caps = client_caps.text_document.as_ref();
168 publish_decorations: config.publish_decorations,
169 supports_location_link: text_document_caps
170 .and_then(|it| it.definition)
171 .and_then(|it| it.link_support)
173 line_folding_only: text_document_caps
174 .and_then(|it| it.folding_range.as_ref())
175 .and_then(|it| it.line_folding_only)
177 max_inlay_hint_length: config.max_inlay_hint_length,
178 cargo_watch: CheckOptions {
179 enable: config.cargo_watch_enable,
180 args: config.cargo_watch_args,
181 command: config.cargo_watch_command,
182 all_targets: config.cargo_watch_all_targets,
184 rustfmt_args: config.rustfmt_args,
193 Watch(!config.use_client_watching),
199 let pool = ThreadPool::default();
200 let (task_sender, task_receiver) = unbounded::<Task>();
201 let (libdata_sender, libdata_receiver) = unbounded::<LibraryData>();
203 log::info!("server initialized, serving requests");
205 let task_sender = task_sender;
206 let libdata_sender = libdata_sender;
208 log::trace!("selecting");
209 let event = select! {
210 recv(&connection.receiver) -> msg => match msg {
211 Ok(msg) => Event::Msg(msg),
212 Err(RecvError) => return Err("client exited without shutdown".into()),
214 recv(task_receiver) -> task => Event::Task(task.unwrap()),
215 recv(world_state.task_receiver) -> task => match task {
216 Ok(task) => Event::Vfs(task),
217 Err(RecvError) => return Err("vfs died".into()),
219 recv(libdata_receiver) -> data => Event::Lib(data.unwrap()),
220 recv(world_state.check_watcher.task_recv) -> task => match task {
221 Ok(task) => Event::CheckWatcher(task),
222 Err(RecvError) => return Err("check watcher died".into()),
225 if let Event::Msg(Message::Request(req)) = &event {
226 if connection.handle_shutdown(&req)? {
241 world_state.analysis_host.request_cancellation();
242 log::info!("waiting for tasks to finish...");
243 task_receiver.into_iter().for_each(|task| {
244 on_task(task, &connection.sender, &mut loop_state.pending_requests, &mut world_state)
246 libdata_receiver.into_iter().for_each(drop);
247 log::info!("...tasks have finished");
248 log::info!("joining threadpool...");
250 log::info!("...threadpool has finished");
252 let vfs = Arc::try_unwrap(world_state.vfs).expect("all snapshots should be dead");
261 Notify(Notification),
262 Diagnostic(DiagnosticTask),
270 CheckWatcher(CheckTask),
273 impl fmt::Debug for Event {
274 fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
275 let debug_verbose_not = |not: &Notification, f: &mut fmt::Formatter| {
276 f.debug_struct("Notification").field("method", ¬.method).finish()
280 Event::Msg(Message::Notification(not)) => {
281 if notification_is::<req::DidOpenTextDocument>(not)
282 || notification_is::<req::DidChangeTextDocument>(not)
284 return debug_verbose_not(not, f);
287 Event::Task(Task::Notify(not)) => {
288 if notification_is::<req::PublishDecorations>(not)
289 || notification_is::<req::PublishDiagnostics>(not)
291 return debug_verbose_not(not, f);
294 Event::Task(Task::Respond(resp)) => {
296 .debug_struct("Response")
297 .field("id", &resp.id)
298 .field("error", &resp.error)
304 Event::Msg(it) => fmt::Debug::fmt(it, f),
305 Event::Task(it) => fmt::Debug::fmt(it, f),
306 Event::Vfs(it) => fmt::Debug::fmt(it, f),
307 Event::Lib(it) => fmt::Debug::fmt(it, f),
308 Event::CheckWatcher(it) => fmt::Debug::fmt(it, f),
313 #[derive(Debug, Default)]
315 next_request_id: u64,
316 pending_responses: FxHashSet<RequestId>,
317 pending_requests: PendingRequests,
318 subscriptions: Subscriptions,
319 // We try not to index more than MAX_IN_FLIGHT_LIBS libraries at the same
320 // time to always have a thread ready to react to input.
321 in_flight_libraries: usize,
322 pending_libraries: Vec<(SourceRootId, Vec<(FileId, RelativePathBuf, Arc<String>)>)>,
323 workspace_loaded: bool,
327 fn next_request_id(&mut self) -> RequestId {
328 self.next_request_id += 1;
329 let res: RequestId = self.next_request_id.into();
330 let inserted = self.pending_responses.insert(res.clone());
338 task_sender: &Sender<Task>,
339 libdata_sender: &Sender<LibraryData>,
340 connection: &Connection,
341 world_state: &mut WorldState,
342 loop_state: &mut LoopState,
345 let loop_start = Instant::now();
347 // NOTE: don't count blocking select! call as a loop-turn time
348 let _p = profile("main_loop_inner/loop-turn");
349 log::info!("loop turn = {:?}", event);
350 let queue_count = pool.queued_count();
352 log::info!("queued count = {}", queue_count);
356 Event::Task(task) => {
357 on_task(task, &connection.sender, &mut loop_state.pending_requests, world_state);
358 world_state.maybe_collect_garbage();
360 Event::Vfs(task) => {
361 world_state.vfs.write().handle_task(task);
364 world_state.add_lib(lib);
365 world_state.maybe_collect_garbage();
366 loop_state.in_flight_libraries -= 1;
368 Event::CheckWatcher(task) => on_check_task(task, world_state, task_sender)?,
369 Event::Msg(msg) => match msg {
370 Message::Request(req) => on_request(
372 &mut loop_state.pending_requests,
379 Message::Notification(not) => {
383 &mut loop_state.pending_requests,
384 &mut loop_state.subscriptions,
388 Message::Response(resp) => {
389 let removed = loop_state.pending_responses.remove(&resp.id);
391 log::error!("unexpected response: {:?}", resp)
397 let mut state_changed = false;
398 if let Some(changes) = world_state.process_changes() {
399 state_changed = true;
400 loop_state.pending_libraries.extend(changes);
403 let max_in_flight_libs = pool.max_count().saturating_sub(2).max(1);
404 while loop_state.in_flight_libraries < max_in_flight_libs
405 && !loop_state.pending_libraries.is_empty()
407 let (root, files) = loop_state.pending_libraries.pop().unwrap();
408 loop_state.in_flight_libraries += 1;
409 let sender = libdata_sender.clone();
410 pool.execute(move || {
411 log::info!("indexing {:?} ... ", root);
412 let data = LibraryData::prepare(root, files);
413 sender.send(data).unwrap();
417 if !loop_state.workspace_loaded
418 && world_state.roots_to_scan == 0
419 && loop_state.pending_libraries.is_empty()
420 && loop_state.in_flight_libraries == 0
422 loop_state.workspace_loaded = true;
423 let n_packages: usize = world_state.workspaces.iter().map(|it| it.n_packages()).sum();
424 if world_state.feature_flags().get("notifications.workspace-loaded") {
425 let msg = format!("workspace loaded, {} rust packages", n_packages);
426 show_message(req::MessageType::Info, msg, &connection.sender);
428 world_state.check_watcher.update();
432 update_file_notifications_on_threadpool(
434 world_state.snapshot(),
435 world_state.options.publish_decorations,
437 loop_state.subscriptions.subscriptions(),
441 let loop_duration = loop_start.elapsed();
442 if loop_duration > Duration::from_millis(100) {
443 log::error!("overly long loop turn: {:?}", loop_duration);
444 if env::var("RA_PROFILE").is_ok() {
446 req::MessageType::Error,
447 format!("overly long loop turn: {:?}", loop_duration),
458 msg_sender: &Sender<Message>,
459 pending_requests: &mut PendingRequests,
460 state: &mut WorldState,
463 Task::Respond(response) => {
464 if let Some(completed) = pending_requests.finish(&response.id) {
465 log::info!("handled req#{} in {:?}", completed.id, completed.duration);
466 state.complete_request(completed);
467 msg_sender.send(response.into()).unwrap();
471 msg_sender.send(n.into()).unwrap();
473 Task::Diagnostic(task) => on_diagnostic_task(task, msg_sender, state),
478 world: &mut WorldState,
479 pending_requests: &mut PendingRequests,
481 task_sender: &Sender<Task>,
482 msg_sender: &Sender<Message>,
483 request_received: Instant,
486 let mut pool_dispatcher = PoolDispatcher {
496 .on_sync::<req::CollectGarbage>(|s, ()| Ok(s.collect_garbage()))?
497 .on_sync::<req::JoinLines>(|s, p| handlers::handle_join_lines(s.snapshot(), p))?
498 .on_sync::<req::OnEnter>(|s, p| handlers::handle_on_enter(s.snapshot(), p))?
499 .on_sync::<req::SelectionRangeRequest>(|s, p| {
500 handlers::handle_selection_range(s.snapshot(), p)
502 .on_sync::<req::FindMatchingBrace>(|s, p| {
503 handlers::handle_find_matching_brace(s.snapshot(), p)
505 .on::<req::AnalyzerStatus>(handlers::handle_analyzer_status)?
506 .on::<req::SyntaxTree>(handlers::handle_syntax_tree)?
507 .on::<req::ExpandMacro>(handlers::handle_expand_macro)?
508 .on::<req::OnTypeFormatting>(handlers::handle_on_type_formatting)?
509 .on::<req::DocumentSymbolRequest>(handlers::handle_document_symbol)?
510 .on::<req::WorkspaceSymbol>(handlers::handle_workspace_symbol)?
511 .on::<req::GotoDefinition>(handlers::handle_goto_definition)?
512 .on::<req::GotoImplementation>(handlers::handle_goto_implementation)?
513 .on::<req::GotoTypeDefinition>(handlers::handle_goto_type_definition)?
514 .on::<req::ParentModule>(handlers::handle_parent_module)?
515 .on::<req::Runnables>(handlers::handle_runnables)?
516 .on::<req::DecorationsRequest>(handlers::handle_decorations)?
517 .on::<req::Completion>(handlers::handle_completion)?
518 .on::<req::CodeActionRequest>(handlers::handle_code_action)?
519 .on::<req::CodeLensRequest>(handlers::handle_code_lens)?
520 .on::<req::CodeLensResolve>(handlers::handle_code_lens_resolve)?
521 .on::<req::FoldingRangeRequest>(handlers::handle_folding_range)?
522 .on::<req::SignatureHelpRequest>(handlers::handle_signature_help)?
523 .on::<req::HoverRequest>(handlers::handle_hover)?
524 .on::<req::PrepareRenameRequest>(handlers::handle_prepare_rename)?
525 .on::<req::Rename>(handlers::handle_rename)?
526 .on::<req::References>(handlers::handle_references)?
527 .on::<req::Formatting>(handlers::handle_formatting)?
528 .on::<req::DocumentHighlightRequest>(handlers::handle_document_highlight)?
529 .on::<req::InlayHints>(handlers::handle_inlay_hints)?
530 .on::<req::CallHierarchyPrepare>(handlers::handle_call_hierarchy_prepare)?
531 .on::<req::CallHierarchyIncomingCalls>(handlers::handle_call_hierarchy_incoming)?
532 .on::<req::CallHierarchyOutgoingCalls>(handlers::handle_call_hierarchy_outgoing)?
533 .on::<req::SemanticTokensRequest>(handlers::handle_semantic_tokens)?
534 .on::<req::SemanticTokensRangeRequest>(handlers::handle_semantic_tokens_range)?
535 .on::<req::Ssr>(handlers::handle_ssr)?
541 msg_sender: &Sender<Message>,
542 state: &mut WorldState,
543 pending_requests: &mut PendingRequests,
544 subs: &mut Subscriptions,
547 let not = match notification_cast::<req::Cancel>(not) {
549 let id: RequestId = match params.id {
550 NumberOrString::Number(id) => id.into(),
551 NumberOrString::String(id) => id.into(),
553 if pending_requests.cancel(&id) {
554 let response = Response::new_err(
556 ErrorCode::RequestCanceled as i32,
557 "canceled by client".to_string(),
559 msg_sender.send(response.into()).unwrap()
565 let not = match notification_cast::<req::DidOpenTextDocument>(not) {
567 let uri = params.text_document.uri;
568 let path = uri.to_file_path().map_err(|()| format!("invalid uri: {}", uri))?;
569 if let Some(file_id) =
570 state.vfs.write().add_file_overlay(&path, params.text_document.text)
572 subs.add_sub(FileId(file_id.0));
578 let not = match notification_cast::<req::DidChangeTextDocument>(not) {
580 let uri = params.text_document.uri;
581 let path = uri.to_file_path().map_err(|()| format!("invalid uri: {}", uri))?;
583 params.content_changes.pop().ok_or_else(|| "empty changes".to_string())?.text;
584 state.vfs.write().change_file_overlay(path.as_path(), text);
589 let not = match notification_cast::<req::DidSaveTextDocument>(not) {
591 state.check_watcher.update();
596 let not = match notification_cast::<req::DidCloseTextDocument>(not) {
598 let uri = params.text_document.uri;
599 let path = uri.to_file_path().map_err(|()| format!("invalid uri: {}", uri))?;
600 if let Some(file_id) = state.vfs.write().remove_file_overlay(path.as_path()) {
601 subs.remove_sub(FileId(file_id.0));
604 req::PublishDiagnosticsParams { uri, diagnostics: Vec::new(), version: None };
605 let not = notification_new::<req::PublishDiagnostics>(params);
606 msg_sender.send(not.into()).unwrap();
611 let not = match notification_cast::<req::DidChangeConfiguration>(not) {
617 let not = match notification_cast::<req::DidChangeWatchedFiles>(not) {
619 let mut vfs = state.vfs.write();
620 for change in params.changes {
621 let uri = change.uri;
622 let path = uri.to_file_path().map_err(|()| format!("invalid uri: {}", uri))?;
623 vfs.notify_changed(path)
629 log::error!("unhandled notification: {:?}", not);
635 world_state: &mut WorldState,
636 task_sender: &Sender<Task>,
639 CheckTask::ClearDiagnostics => {
640 task_sender.send(Task::Diagnostic(DiagnosticTask::ClearCheck))?;
643 CheckTask::AddDiagnostic { url, diagnostic, fixes } => {
644 let path = url.to_file_path().map_err(|()| format!("invalid uri: {}", url))?;
645 let file_id = match world_state.vfs.read().path2file(&path) {
646 Some(file) => FileId(file.0),
648 log::error!("File with cargo diagnostic not found in VFS: {}", path.display());
654 .send(Task::Diagnostic(DiagnosticTask::AddCheck(file_id, diagnostic, fixes)))?;
657 CheckTask::Status(progress) => {
658 let params = req::ProgressParams {
659 token: req::ProgressToken::String("rustAnalyzer/cargoWatcher".to_string()),
660 value: req::ProgressParamsValue::WorkDone(progress),
662 let not = notification_new::<req::Progress>(params);
663 task_sender.send(Task::Notify(not)).unwrap();
670 fn on_diagnostic_task(task: DiagnosticTask, msg_sender: &Sender<Message>, state: &mut WorldState) {
671 let subscriptions = state.diagnostics.handle_task(task);
673 for file_id in subscriptions {
674 let path = state.vfs.read().file2path(VfsFile(file_id.0));
675 let uri = match url_from_path_with_drive_lowercasing(&path) {
678 log::error!("Couldn't convert path to url ({}): {:?}", err, path.to_string_lossy());
683 let diagnostics = state.diagnostics.diagnostics_for(file_id).cloned().collect();
684 let params = req::PublishDiagnosticsParams { uri, diagnostics, version: None };
685 let not = notification_new::<req::PublishDiagnostics>(params);
686 msg_sender.send(not.into()).unwrap();
690 struct PoolDispatcher<'a> {
691 req: Option<Request>,
692 pool: &'a ThreadPool,
693 world: &'a mut WorldState,
694 pending_requests: &'a mut PendingRequests,
695 msg_sender: &'a Sender<Message>,
696 task_sender: &'a Sender<Task>,
697 request_received: Instant,
700 impl<'a> PoolDispatcher<'a> {
701 /// Dispatches the request onto the current thread
704 f: fn(&mut WorldState, R::Params) -> Result<R::Result>,
705 ) -> Result<&mut Self>
707 R: req::Request + 'static,
708 R::Params: DeserializeOwned + panic::UnwindSafe + 'static,
709 R::Result: Serialize + 'static,
711 let (id, params) = match self.parse::<R>() {
717 let world = panic::AssertUnwindSafe(&mut *self.world);
718 let task = panic::catch_unwind(move || {
719 let result = f(world.0, params);
720 result_to_task::<R>(id, result)
722 .map_err(|_| format!("sync task {:?} panicked", R::METHOD))?;
723 on_task(task, self.msg_sender, self.pending_requests, self.world);
727 /// Dispatches the request onto thread pool
728 fn on<R>(&mut self, f: fn(WorldSnapshot, R::Params) -> Result<R::Result>) -> Result<&mut Self>
730 R: req::Request + 'static,
731 R::Params: DeserializeOwned + Send + 'static,
732 R::Result: Serialize + 'static,
734 let (id, params) = match self.parse::<R>() {
742 let world = self.world.snapshot();
743 let sender = self.task_sender.clone();
745 let result = f(world, params);
746 let task = result_to_task::<R>(id, result);
747 sender.send(task).unwrap();
754 fn parse<R>(&mut self) -> Option<(RequestId, R::Params)>
756 R: req::Request + 'static,
757 R::Params: DeserializeOwned + 'static,
759 let req = self.req.take()?;
760 let (id, params) = match req.extract::<R::Params>(R::METHOD) {
763 self.req = Some(req);
767 self.pending_requests.start(PendingRequest {
769 method: R::METHOD.to_string(),
770 received: self.request_received,
775 fn finish(&mut self) {
776 match self.req.take() {
779 log::error!("unknown request: {:?}", req);
780 let resp = Response::new_err(
782 ErrorCode::MethodNotFound as i32,
783 "unknown request".to_string(),
785 self.msg_sender.send(resp.into()).unwrap();
791 fn result_to_task<R>(id: RequestId, result: Result<R::Result>) -> Task
793 R: req::Request + 'static,
794 R::Params: DeserializeOwned + 'static,
795 R::Result: Serialize + 'static,
797 let response = match result {
798 Ok(resp) => Response::new_ok(id, &resp),
799 Err(e) => match e.downcast::<LspError>() {
800 Ok(lsp_error) => Response::new_err(id, lsp_error.code, lsp_error.message),
805 ErrorCode::ContentModified as i32,
806 "content modified".to_string(),
809 Response::new_err(id, ErrorCode::InternalError as i32, e.to_string())
814 Task::Respond(response)
817 fn update_file_notifications_on_threadpool(
819 world: WorldSnapshot,
820 publish_decorations: bool,
821 task_sender: Sender<Task>,
822 subscriptions: Vec<FileId>,
824 log::trace!("updating notifications for {:?}", subscriptions);
825 let publish_diagnostics = world.feature_flags().get("lsp.diagnostics");
826 pool.execute(move || {
827 for file_id in subscriptions {
828 if publish_diagnostics {
829 match handlers::publish_diagnostics(&world, file_id) {
831 if !is_canceled(&e) {
832 log::error!("failed to compute diagnostics: {:?}", e);
836 task_sender.send(Task::Diagnostic(task)).unwrap();
840 if publish_decorations {
841 match handlers::publish_decorations(&world, file_id) {
843 if !is_canceled(&e) {
844 log::error!("failed to compute decorations: {:?}", e);
848 let not = notification_new::<req::PublishDecorations>(params);
849 task_sender.send(Task::Notify(not)).unwrap();
857 pub fn show_message(typ: req::MessageType, message: impl Into<String>, sender: &Sender<Message>) {
858 let message = message.into();
859 let params = req::ShowMessageParams { typ, message };
860 let not = notification_new::<req::ShowMessage>(params);
861 sender.send(not.into()).unwrap();
864 fn is_canceled(e: &Box<dyn std::error::Error + Send + Sync>) -> bool {
865 e.downcast_ref::<Canceled>().is_some()
868 fn notification_is<N: lsp_types::notification::Notification>(notification: &Notification) -> bool {
869 notification.method == N::METHOD
872 fn notification_cast<N>(notification: Notification) -> std::result::Result<N::Params, Notification>
874 N: lsp_types::notification::Notification,
875 N::Params: DeserializeOwned,
877 notification.extract(N::METHOD)
880 fn notification_new<N>(params: N::Params) -> Notification
882 N: lsp_types::notification::Notification,
883 N::Params: Serialize,
885 Notification::new(N::METHOD.to_string(), params)
888 fn request_new<R>(id: RequestId, params: R::Params) -> Request
890 R: lsp_types::request::Request,
891 R::Params: Serialize,
893 Request::new(id, R::METHOD.to_string(), params)