mirror of
https://github.com/astral-sh/ruff.git
synced 2025-08-04 18:58:26 +00:00
Clean up some Ruff references in the ty server (#17920)
## Summary Anything user-facing, etc.
This commit is contained in:
parent
3dedd70a92
commit
ad658f4d68
8 changed files with 25 additions and 17 deletions
|
@ -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 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)
|
||||
UTF32,
|
||||
|
||||
/// Ruff's preferred encoding
|
||||
/// ty's preferred encoding
|
||||
UTF8,
|
||||
}
|
||||
|
||||
|
|
|
@ -92,7 +92,7 @@ impl NotebookDocument {
|
|||
};
|
||||
|
||||
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(
|
||||
|
|
|
@ -148,7 +148,7 @@ impl Server {
|
|||
writeln!(stderr, "{panic_info}\n{backtrace}").ok();
|
||||
|
||||
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(),
|
||||
MessageType::ERROR,
|
||||
)
|
||||
|
|
|
@ -50,7 +50,7 @@ pub(super) fn request<'a>(req: server::Request) -> Task<'a> {
|
|||
.unwrap_or_else(|err| {
|
||||
tracing::error!("Encountered error when routing request with ID {id}: {err}");
|
||||
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);
|
||||
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> {
|
||||
match notif.method.as_str() {
|
||||
notification::DidCloseTextDocumentHandler::METHOD => local_notification_task::<notification::DidCloseTextDocumentHandler>(notif),
|
||||
notification::DidOpenTextDocumentHandler::METHOD => local_notification_task::<notification::DidOpenTextDocumentHandler>(notif),
|
||||
notification::DidChangeTextDocumentHandler::METHOD => local_notification_task::<notification::DidChangeTextDocumentHandler>(notif),
|
||||
notification::DidCloseTextDocumentHandler::METHOD => {
|
||||
local_notification_task::<notification::DidCloseTextDocumentHandler>(notif)
|
||||
}
|
||||
notification::DidOpenTextDocumentHandler::METHOD => {
|
||||
local_notification_task::<notification::DidOpenTextDocumentHandler>(notif)
|
||||
}
|
||||
notification::DidChangeTextDocumentHandler::METHOD => {
|
||||
local_notification_task::<notification::DidChangeTextDocumentHandler>(notif)
|
||||
}
|
||||
notification::DidOpenNotebookHandler::METHOD => {
|
||||
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 => {
|
||||
tracing::trace!("Ignoring `setTrace` notification");
|
||||
return Task::nothing();
|
||||
},
|
||||
}
|
||||
|
||||
method => {
|
||||
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| {
|
||||
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()
|
||||
})
|
||||
}
|
||||
|
@ -139,7 +147,7 @@ fn local_notification_task<'a, N: traits::SyncNotificationHandler>(
|
|||
let _span = tracing::trace_span!("notification", method = N::METHOD).entered();
|
||||
if let Err(err) = N::run(session, notifier, requester, params) {
|
||||
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();
|
||||
if let Err(err) = N::run_with_snapshot(snapshot, notifier, params) {
|
||||
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 {
|
||||
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) {
|
||||
tracing::error!("Failed to send response: {err}");
|
||||
|
|
|
@ -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::session::{DocumentSnapshot, Session};
|
||||
|
|
|
@ -23,7 +23,7 @@ pub(crate) fn event_loop_thread(
|
|||
) -> crate::Result<thread::JoinHandle<crate::Result<()>>> {
|
||||
// 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_NAME: &str = "ruff:main";
|
||||
const MAIN_THREAD_NAME: &str = "ty:main";
|
||||
Ok(
|
||||
thread::Builder::new(thread::ThreadPriority::LatencySensitive)
|
||||
.name(MAIN_THREAD_NAME.into())
|
||||
|
|
|
@ -59,7 +59,7 @@ impl Pool {
|
|||
for i in 0..threads {
|
||||
let handle = Builder::new(INITIAL_PRIORITY)
|
||||
.stack_size(STACK_SIZE)
|
||||
.name(format!("ruff:worker:{i}"))
|
||||
.name(format!("ty:worker:{i}"))
|
||||
.spawn({
|
||||
let extant_tasks = Arc::clone(&extant_tasks);
|
||||
let job_receiver: Receiver<Job> = job_receiver.clone();
|
||||
|
|
|
@ -75,7 +75,7 @@ impl AllSettings {
|
|||
serde_json::from_value(options)
|
||||
.map_err(|err| {
|
||||
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(),
|
||||
)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue