Clean up some Ruff references in the ty server (#17920)

## Summary

Anything user-facing, etc.
This commit is contained in:
Charlie Marsh 2025-05-07 10:55:16 -04:00 committed by GitHub
parent 3dedd70a92
commit ad658f4d68
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
8 changed files with 25 additions and 17 deletions

View file

@ -1,4 +1,4 @@
//! Types and utilities for working with text, modifying source files, and `Ruff <-> LSP` type conversion. //! Types and utilities for working with text, modifying source files, and `ty <-> LSP` type conversion.
mod location; mod location;
mod notebook; mod notebook;
@ -23,7 +23,7 @@ pub enum PositionEncoding {
/// Second choice because UTF32 uses a fixed 4 byte encoding for each character (makes conversion relatively easy) /// Second choice because UTF32 uses a fixed 4 byte encoding for each character (makes conversion relatively easy)
UTF32, UTF32,
/// Ruff's preferred encoding /// ty's preferred encoding
UTF8, UTF8,
} }

View file

@ -92,7 +92,7 @@ impl NotebookDocument {
}; };
ruff_notebook::Notebook::from_raw_notebook(raw_notebook, false) ruff_notebook::Notebook::from_raw_notebook(raw_notebook, false)
.unwrap_or_else(|err| panic!("Server notebook document could not be converted to Ruff's notebook document format: {err}")) .unwrap_or_else(|err| panic!("Server notebook document could not be converted to ty's notebook document format: {err}"))
} }
pub(crate) fn update( pub(crate) fn update(

View file

@ -148,7 +148,7 @@ impl Server {
writeln!(stderr, "{panic_info}\n{backtrace}").ok(); writeln!(stderr, "{panic_info}\n{backtrace}").ok();
try_show_message( try_show_message(
"The Ruff language server exited with a panic. See the logs for more details." "The ty language server exited with a panic. See the logs for more details."
.to_string(), .to_string(),
MessageType::ERROR, MessageType::ERROR,
) )

View file

@ -50,7 +50,7 @@ pub(super) fn request<'a>(req: server::Request) -> Task<'a> {
.unwrap_or_else(|err| { .unwrap_or_else(|err| {
tracing::error!("Encountered error when routing request with ID {id}: {err}"); tracing::error!("Encountered error when routing request with ID {id}: {err}");
show_err_msg!( show_err_msg!(
"Ruff failed to handle a request from the editor. Check the logs for more details." "ty failed to handle a request from the editor. Check the logs for more details."
); );
let result: Result<()> = Err(err); let result: Result<()> = Err(err);
Task::immediate(id, result) Task::immediate(id, result)
@ -59,9 +59,15 @@ pub(super) fn request<'a>(req: server::Request) -> Task<'a> {
pub(super) fn notification<'a>(notif: server::Notification) -> Task<'a> { pub(super) fn notification<'a>(notif: server::Notification) -> Task<'a> {
match notif.method.as_str() { match notif.method.as_str() {
notification::DidCloseTextDocumentHandler::METHOD => local_notification_task::<notification::DidCloseTextDocumentHandler>(notif), notification::DidCloseTextDocumentHandler::METHOD => {
notification::DidOpenTextDocumentHandler::METHOD => local_notification_task::<notification::DidOpenTextDocumentHandler>(notif), local_notification_task::<notification::DidCloseTextDocumentHandler>(notif)
notification::DidChangeTextDocumentHandler::METHOD => local_notification_task::<notification::DidChangeTextDocumentHandler>(notif), }
notification::DidOpenTextDocumentHandler::METHOD => {
local_notification_task::<notification::DidOpenTextDocumentHandler>(notif)
}
notification::DidChangeTextDocumentHandler::METHOD => {
local_notification_task::<notification::DidChangeTextDocumentHandler>(notif)
}
notification::DidOpenNotebookHandler::METHOD => { notification::DidOpenNotebookHandler::METHOD => {
local_notification_task::<notification::DidOpenNotebookHandler>(notif) local_notification_task::<notification::DidOpenNotebookHandler>(notif)
} }
@ -71,7 +77,7 @@ pub(super) fn notification<'a>(notif: server::Notification) -> Task<'a> {
lsp_types::notification::SetTrace::METHOD => { lsp_types::notification::SetTrace::METHOD => {
tracing::trace!("Ignoring `setTrace` notification"); tracing::trace!("Ignoring `setTrace` notification");
return Task::nothing(); return Task::nothing();
}, }
method => { method => {
tracing::warn!("Received notification {method} which does not have a handler."); tracing::warn!("Received notification {method} which does not have a handler.");
@ -80,7 +86,9 @@ pub(super) fn notification<'a>(notif: server::Notification) -> Task<'a> {
} }
.unwrap_or_else(|err| { .unwrap_or_else(|err| {
tracing::error!("Encountered error when routing notification: {err}"); tracing::error!("Encountered error when routing notification: {err}");
show_err_msg!("Ruff failed to handle a notification from the editor. Check the logs for more details."); show_err_msg!(
"ty failed to handle a notification from the editor. Check the logs for more details."
);
Task::nothing() Task::nothing()
}) })
} }
@ -139,7 +147,7 @@ fn local_notification_task<'a, N: traits::SyncNotificationHandler>(
let _span = tracing::trace_span!("notification", method = N::METHOD).entered(); let _span = tracing::trace_span!("notification", method = N::METHOD).entered();
if let Err(err) = N::run(session, notifier, requester, params) { if let Err(err) = N::run(session, notifier, requester, params) {
tracing::error!("An error occurred while running {id}: {err}"); tracing::error!("An error occurred while running {id}: {err}");
show_err_msg!("Ruff encountered a problem. Check the logs for more details."); show_err_msg!("ty encountered a problem. Check the logs for more details.");
} }
})) }))
} }
@ -159,7 +167,7 @@ fn background_notification_thread<'a, N: traits::BackgroundDocumentNotificationH
let _span = tracing::trace_span!("notification", method = N::METHOD).entered(); let _span = tracing::trace_span!("notification", method = N::METHOD).entered();
if let Err(err) = N::run_with_snapshot(snapshot, notifier, params) { if let Err(err) = N::run_with_snapshot(snapshot, notifier, params) {
tracing::error!("An error occurred while running {id}: {err}"); tracing::error!("An error occurred while running {id}: {err}");
show_err_msg!("Ruff encountered a problem. Check the logs for more details."); show_err_msg!("ty encountered a problem. Check the logs for more details.");
} }
}) })
})) }))
@ -204,7 +212,7 @@ fn respond<Req>(
{ {
if let Err(err) = &result { if let Err(err) = &result {
tracing::error!("An error occurred with request ID {id}: {err}"); tracing::error!("An error occurred with request ID {id}: {err}");
show_err_msg!("Ruff encountered a problem. Check the logs for more details."); show_err_msg!("ty encountered a problem. Check the logs for more details.");
} }
if let Err(err) = responder.respond(id, result) { if let Err(err) = responder.respond(id, result) {
tracing::error!("Failed to send response: {err}"); tracing::error!("Failed to send response: {err}");

View file

@ -1,4 +1,4 @@
//! A stateful LSP implementation that calls into the Ruff API. //! A stateful LSP implementation that calls into the ty API.
use crate::server::client::{Notifier, Requester}; use crate::server::client::{Notifier, Requester};
use crate::session::{DocumentSnapshot, Session}; use crate::session::{DocumentSnapshot, Session};

View file

@ -23,7 +23,7 @@ pub(crate) fn event_loop_thread(
) -> crate::Result<thread::JoinHandle<crate::Result<()>>> { ) -> crate::Result<thread::JoinHandle<crate::Result<()>>> {
// Override OS defaults to avoid stack overflows on platforms with low stack size defaults. // Override OS defaults to avoid stack overflows on platforms with low stack size defaults.
const MAIN_THREAD_STACK_SIZE: usize = 2 * 1024 * 1024; const MAIN_THREAD_STACK_SIZE: usize = 2 * 1024 * 1024;
const MAIN_THREAD_NAME: &str = "ruff:main"; const MAIN_THREAD_NAME: &str = "ty:main";
Ok( Ok(
thread::Builder::new(thread::ThreadPriority::LatencySensitive) thread::Builder::new(thread::ThreadPriority::LatencySensitive)
.name(MAIN_THREAD_NAME.into()) .name(MAIN_THREAD_NAME.into())

View file

@ -59,7 +59,7 @@ impl Pool {
for i in 0..threads { for i in 0..threads {
let handle = Builder::new(INITIAL_PRIORITY) let handle = Builder::new(INITIAL_PRIORITY)
.stack_size(STACK_SIZE) .stack_size(STACK_SIZE)
.name(format!("ruff:worker:{i}")) .name(format!("ty:worker:{i}"))
.spawn({ .spawn({
let extant_tasks = Arc::clone(&extant_tasks); let extant_tasks = Arc::clone(&extant_tasks);
let job_receiver: Receiver<Job> = job_receiver.clone(); let job_receiver: Receiver<Job> = job_receiver.clone();

View file

@ -75,7 +75,7 @@ impl AllSettings {
serde_json::from_value(options) serde_json::from_value(options)
.map_err(|err| { .map_err(|err| {
tracing::error!("Failed to deserialize initialization options: {err}. Falling back to default client settings..."); tracing::error!("Failed to deserialize initialization options: {err}. Falling back to default client settings...");
show_err_msg!("Ruff received invalid client settings - falling back to default client settings."); show_err_msg!("ty received invalid client settings - falling back to default client settings.");
}) })
.unwrap_or_default(), .unwrap_or_default(),
) )