From 6ba6cfd37c9ff8b84dcf83ed8169fd9e2afa9641 Mon Sep 17 00:00:00 2001 From: Dhruv Manilawala Date: Tue, 11 Mar 2025 13:53:07 +0530 Subject: [PATCH] Server: Remove log notification for `printDebugInformation` command (#16617) ## Summary For context, the initial implementation started out by sending a log notification to the client to include this information in the client channel. This is a bit ineffective because it doesn't allow the client to display this information in a more obvious way. In addition to that, it isn't obvious from a users perspective as to where the information is being printed unless they actually open the output channel. The change was to actually return this formatted string that contains the information and let the client handle how it should display this information. For example, in the Ruff VS Code extension we open a split window and show this information which is similar to what rust-analyzer does. The notification request was kept as a precaution in case there are users who are actually utilizing this way. If they exists, it should a minority as it requires the user to actually dive into the code to understand how to hook into this notification. With 0.10, we're removing the old way as it only clobbers the output channel with a long message. fixes: #16225 ## Test Plan Tested it out locally that the information is not being logged to the output channel of VS Code. --- .../src/server/api/requests/execute_command.rs | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) diff --git a/crates/ruff_server/src/server/api/requests/execute_command.rs b/crates/ruff_server/src/server/api/requests/execute_command.rs index be4801e099..2888e1c85e 100644 --- a/crates/ruff_server/src/server/api/requests/execute_command.rs +++ b/crates/ruff_server/src/server/api/requests/execute_command.rs @@ -38,7 +38,7 @@ impl super::RequestHandler for ExecuteCommand { impl super::SyncRequestHandler for ExecuteCommand { fn run( session: &mut Session, - notifier: client::Notifier, + _notifier: client::Notifier, requester: &mut client::Requester, params: types::ExecuteCommandParams, ) -> server::Result> { @@ -46,19 +46,16 @@ impl super::SyncRequestHandler for ExecuteCommand { .with_failure_code(ErrorCode::InvalidParams)?; if command == SupportedCommand::Debug { + // TODO: Currently we only use the first argument i.e., the first document that's + // provided but we could expand this to consider all *open* documents. let argument: DebugCommandArgument = params.arguments.into_iter().next().map_or_else( || Ok(DebugCommandArgument::default()), |value| serde_json::from_value(value).with_failure_code(ErrorCode::InvalidParams), )?; - let output = debug_information(session, argument.text_document) - .with_failure_code(ErrorCode::InternalError)?; - notifier - .notify::(types::LogMessageParams { - message: output.clone(), - typ: types::MessageType::INFO, - }) - .with_failure_code(ErrorCode::InternalError)?; - return Ok(Some(serde_json::Value::String(output))); + return Ok(Some(serde_json::Value::String( + debug_information(session, argument.text_document) + .with_failure_code(ErrorCode::InternalError)?, + ))); } // check if we can apply a workspace edit