mirror of
https://github.com/astral-sh/ruff.git
synced 2025-08-30 23:27:38 +00:00
Switch to Rust 2024 edition (#18129)
This commit is contained in:
parent
e67b35743a
commit
9ae698fe30
1082 changed files with 4211 additions and 3300 deletions
|
@ -1,6 +1,6 @@
|
|||
use crate::PositionEncoding;
|
||||
use crate::document::{FileRangeExt, ToRangeExt};
|
||||
use crate::system::file_to_url;
|
||||
use crate::PositionEncoding;
|
||||
use lsp_types::Location;
|
||||
use ruff_db::files::FileRange;
|
||||
use ruff_db::source::{line_index, source_text};
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
use super::notebook;
|
||||
use super::PositionEncoding;
|
||||
use super::notebook;
|
||||
use crate::system::file_to_url;
|
||||
|
||||
use lsp_types as types;
|
||||
|
@ -21,7 +21,7 @@ pub(crate) struct NotebookRange {
|
|||
|
||||
pub(crate) trait RangeExt {
|
||||
fn to_text_range(&self, text: &str, index: &LineIndex, encoding: PositionEncoding)
|
||||
-> TextRange;
|
||||
-> TextRange;
|
||||
}
|
||||
|
||||
pub(crate) trait PositionExt {
|
||||
|
|
|
@ -82,9 +82,11 @@ impl TextDocument {
|
|||
new_version: DocumentVersion,
|
||||
encoding: PositionEncoding,
|
||||
) {
|
||||
if let [lsp_types::TextDocumentContentChangeEvent {
|
||||
range: None, text, ..
|
||||
}] = changes.as_slice()
|
||||
if let [
|
||||
lsp_types::TextDocumentContentChangeEvent {
|
||||
range: None, text, ..
|
||||
},
|
||||
] = changes.as_slice()
|
||||
{
|
||||
tracing::debug!("Fast path - replacing entire document");
|
||||
self.modify(|contents, version| {
|
||||
|
|
|
@ -9,9 +9,9 @@ use serde::Deserialize;
|
|||
use std::{path::PathBuf, str::FromStr, sync::Arc};
|
||||
use tracing::level_filters::LevelFilter;
|
||||
use tracing_subscriber::{
|
||||
Layer,
|
||||
fmt::{time::Uptime, writer::BoxMakeWriter},
|
||||
layer::SubscriberExt,
|
||||
Layer,
|
||||
};
|
||||
|
||||
pub(crate) fn init_logging(log_level: LogLevel, log_file: Option<&std::path::Path>) {
|
||||
|
|
|
@ -16,8 +16,8 @@ use lsp_types::{
|
|||
|
||||
use self::connection::{Connection, ConnectionInitializer};
|
||||
use self::schedule::event_loop_thread;
|
||||
use crate::session::{AllSettings, ClientSettings, Experimental, Session};
|
||||
use crate::PositionEncoding;
|
||||
use crate::session::{AllSettings, ClientSettings, Experimental, Session};
|
||||
|
||||
mod api;
|
||||
mod client;
|
||||
|
@ -240,7 +240,9 @@ impl Server {
|
|||
},
|
||||
response_handler,
|
||||
) {
|
||||
tracing::error!("An error occurred when trying to register the configuration file watcher: {err}");
|
||||
tracing::error!(
|
||||
"An error occurred when trying to register the configuration file watcher: {err}"
|
||||
);
|
||||
}
|
||||
} else {
|
||||
tracing::warn!("The client does not support file system watching.");
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
use crate::server::schedule::Task;
|
||||
use crate::session::Session;
|
||||
use crate::system::{url_to_any_system_path, AnySystemPath};
|
||||
use crate::system::{AnySystemPath, url_to_any_system_path};
|
||||
use lsp_server as server;
|
||||
use lsp_types::notification::Notification;
|
||||
|
||||
|
@ -14,7 +14,7 @@ use requests as request;
|
|||
|
||||
use self::traits::{NotificationHandler, RequestHandler};
|
||||
|
||||
use super::{client::Responder, schedule::BackgroundSchedule, Result};
|
||||
use super::{Result, client::Responder, schedule::BackgroundSchedule};
|
||||
|
||||
pub(super) fn request<'a>(req: server::Request) -> Task<'a> {
|
||||
let id = req.id.clone();
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
use lsp_server::ErrorCode;
|
||||
use lsp_types::{notification::PublishDiagnostics, PublishDiagnosticsParams, Url};
|
||||
use lsp_types::{PublishDiagnosticsParams, Url, notification::PublishDiagnostics};
|
||||
|
||||
use crate::server::client::Notifier;
|
||||
use crate::server::Result;
|
||||
use crate::server::client::Notifier;
|
||||
|
||||
use super::LSPResult;
|
||||
|
||||
|
|
|
@ -1,15 +1,15 @@
|
|||
use lsp_server::ErrorCode;
|
||||
use lsp_types::notification::DidChangeTextDocument;
|
||||
use lsp_types::DidChangeTextDocumentParams;
|
||||
use lsp_types::notification::DidChangeTextDocument;
|
||||
|
||||
use ty_project::watch::ChangeEvent;
|
||||
|
||||
use crate::server::api::traits::{NotificationHandler, SyncNotificationHandler};
|
||||
use crate::server::api::LSPResult;
|
||||
use crate::server::client::{Notifier, Requester};
|
||||
use crate::server::Result;
|
||||
use crate::server::api::LSPResult;
|
||||
use crate::server::api::traits::{NotificationHandler, SyncNotificationHandler};
|
||||
use crate::server::client::{Notifier, Requester};
|
||||
use crate::session::Session;
|
||||
use crate::system::{url_to_any_system_path, AnySystemPath};
|
||||
use crate::system::{AnySystemPath, url_to_any_system_path};
|
||||
|
||||
pub(crate) struct DidChangeTextDocumentHandler;
|
||||
|
||||
|
|
|
@ -1,15 +1,15 @@
|
|||
use crate::server::api::traits::{NotificationHandler, SyncNotificationHandler};
|
||||
use crate::server::Result;
|
||||
use crate::server::api::LSPResult;
|
||||
use crate::server::api::traits::{NotificationHandler, SyncNotificationHandler};
|
||||
use crate::server::client::{Notifier, Requester};
|
||||
use crate::server::schedule::Task;
|
||||
use crate::server::Result;
|
||||
use crate::session::Session;
|
||||
use crate::system::{url_to_any_system_path, AnySystemPath};
|
||||
use crate::system::{AnySystemPath, url_to_any_system_path};
|
||||
use lsp_types as types;
|
||||
use lsp_types::{notification as notif, FileChangeType};
|
||||
use lsp_types::{FileChangeType, notification as notif};
|
||||
use rustc_hash::FxHashMap;
|
||||
use ty_project::watch::{ChangeEvent, ChangedKind, CreatedKind, DeletedKind};
|
||||
use ty_project::Db;
|
||||
use ty_project::watch::{ChangeEvent, ChangedKind, CreatedKind, DeletedKind};
|
||||
|
||||
pub(crate) struct DidChangeWatchedFiles;
|
||||
|
||||
|
|
|
@ -1,15 +1,15 @@
|
|||
use lsp_server::ErrorCode;
|
||||
use lsp_types::notification::DidCloseTextDocument;
|
||||
use lsp_types::DidCloseTextDocumentParams;
|
||||
use lsp_types::notification::DidCloseTextDocument;
|
||||
use ty_project::watch::ChangeEvent;
|
||||
|
||||
use crate::server::Result;
|
||||
use crate::server::api::LSPResult;
|
||||
use crate::server::api::diagnostics::clear_diagnostics;
|
||||
use crate::server::api::traits::{NotificationHandler, SyncNotificationHandler};
|
||||
use crate::server::api::LSPResult;
|
||||
use crate::server::client::{Notifier, Requester};
|
||||
use crate::server::Result;
|
||||
use crate::session::Session;
|
||||
use crate::system::{url_to_any_system_path, AnySystemPath};
|
||||
use crate::system::{AnySystemPath, url_to_any_system_path};
|
||||
|
||||
pub(crate) struct DidCloseTextDocumentHandler;
|
||||
|
||||
|
|
|
@ -1,14 +1,14 @@
|
|||
use lsp_types::notification::DidCloseNotebookDocument;
|
||||
use lsp_types::DidCloseNotebookDocumentParams;
|
||||
use lsp_types::notification::DidCloseNotebookDocument;
|
||||
|
||||
use ty_project::watch::ChangeEvent;
|
||||
|
||||
use crate::server::api::traits::{NotificationHandler, SyncNotificationHandler};
|
||||
use crate::server::api::LSPResult;
|
||||
use crate::server::client::{Notifier, Requester};
|
||||
use crate::server::Result;
|
||||
use crate::server::api::LSPResult;
|
||||
use crate::server::api::traits::{NotificationHandler, SyncNotificationHandler};
|
||||
use crate::server::client::{Notifier, Requester};
|
||||
use crate::session::Session;
|
||||
use crate::system::{url_to_any_system_path, AnySystemPath};
|
||||
use crate::system::{AnySystemPath, url_to_any_system_path};
|
||||
|
||||
pub(crate) struct DidCloseNotebookHandler;
|
||||
|
||||
|
|
|
@ -4,12 +4,12 @@ use lsp_types::{DidOpenTextDocumentParams, TextDocumentItem};
|
|||
use ruff_db::Db;
|
||||
use ty_project::watch::ChangeEvent;
|
||||
|
||||
use crate::TextDocument;
|
||||
use crate::server::Result;
|
||||
use crate::server::api::traits::{NotificationHandler, SyncNotificationHandler};
|
||||
use crate::server::client::{Notifier, Requester};
|
||||
use crate::server::Result;
|
||||
use crate::session::Session;
|
||||
use crate::system::{url_to_any_system_path, AnySystemPath};
|
||||
use crate::TextDocument;
|
||||
use crate::system::{AnySystemPath, url_to_any_system_path};
|
||||
|
||||
pub(crate) struct DidOpenTextDocumentHandler;
|
||||
|
||||
|
|
|
@ -1,17 +1,17 @@
|
|||
use lsp_server::ErrorCode;
|
||||
use lsp_types::notification::DidOpenNotebookDocument;
|
||||
use lsp_types::DidOpenNotebookDocumentParams;
|
||||
use lsp_types::notification::DidOpenNotebookDocument;
|
||||
|
||||
use ruff_db::Db;
|
||||
use ty_project::watch::ChangeEvent;
|
||||
|
||||
use crate::document::NotebookDocument;
|
||||
use crate::server::api::traits::{NotificationHandler, SyncNotificationHandler};
|
||||
use crate::server::api::LSPResult;
|
||||
use crate::server::client::{Notifier, Requester};
|
||||
use crate::server::Result;
|
||||
use crate::server::api::LSPResult;
|
||||
use crate::server::api::traits::{NotificationHandler, SyncNotificationHandler};
|
||||
use crate::server::client::{Notifier, Requester};
|
||||
use crate::session::Session;
|
||||
use crate::system::{url_to_any_system_path, AnySystemPath};
|
||||
use crate::system::{AnySystemPath, url_to_any_system_path};
|
||||
|
||||
pub(crate) struct DidOpenNotebookHandler;
|
||||
|
||||
|
|
|
@ -6,10 +6,10 @@ use ruff_db::source::{line_index, source_text};
|
|||
use ty_ide::completion;
|
||||
use ty_project::ProjectDatabase;
|
||||
|
||||
use crate::DocumentSnapshot;
|
||||
use crate::document::PositionExt;
|
||||
use crate::server::api::traits::{BackgroundDocumentRequestHandler, RequestHandler};
|
||||
use crate::server::client::Notifier;
|
||||
use crate::DocumentSnapshot;
|
||||
|
||||
pub(crate) struct CompletionRequestHandler;
|
||||
|
||||
|
|
|
@ -9,7 +9,7 @@ use lsp_types::{
|
|||
|
||||
use crate::document::ToRangeExt;
|
||||
use crate::server::api::traits::{BackgroundDocumentRequestHandler, RequestHandler};
|
||||
use crate::server::{client::Notifier, Result};
|
||||
use crate::server::{Result, client::Notifier};
|
||||
use crate::session::DocumentSnapshot;
|
||||
use ruff_db::diagnostic::Severity;
|
||||
use ruff_db::source::{line_index, source_text};
|
||||
|
|
|
@ -6,10 +6,10 @@ use ruff_db::source::{line_index, source_text};
|
|||
use ty_ide::goto_type_definition;
|
||||
use ty_project::ProjectDatabase;
|
||||
|
||||
use crate::DocumentSnapshot;
|
||||
use crate::document::{PositionExt, ToLink};
|
||||
use crate::server::api::traits::{BackgroundDocumentRequestHandler, RequestHandler};
|
||||
use crate::server::client::Notifier;
|
||||
use crate::DocumentSnapshot;
|
||||
|
||||
pub(crate) struct GotoTypeDefinitionRequestHandler;
|
||||
|
||||
|
|
|
@ -1,14 +1,14 @@
|
|||
use std::borrow::Cow;
|
||||
|
||||
use crate::DocumentSnapshot;
|
||||
use crate::document::{PositionExt, ToRangeExt};
|
||||
use crate::server::api::traits::{BackgroundDocumentRequestHandler, RequestHandler};
|
||||
use crate::server::client::Notifier;
|
||||
use crate::DocumentSnapshot;
|
||||
use lsp_types::request::HoverRequest;
|
||||
use lsp_types::{HoverContents, HoverParams, MarkupContent, Url};
|
||||
use ruff_db::source::{line_index, source_text};
|
||||
use ruff_text_size::Ranged;
|
||||
use ty_ide::{hover, MarkupKind};
|
||||
use ty_ide::{MarkupKind, hover};
|
||||
use ty_project::ProjectDatabase;
|
||||
|
||||
pub(crate) struct HoverRequestHandler;
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
use std::borrow::Cow;
|
||||
|
||||
use crate::DocumentSnapshot;
|
||||
use crate::document::{RangeExt, TextSizeExt};
|
||||
use crate::server::api::traits::{BackgroundDocumentRequestHandler, RequestHandler};
|
||||
use crate::server::client::Notifier;
|
||||
use crate::DocumentSnapshot;
|
||||
use lsp_types::request::InlayHintRequest;
|
||||
use lsp_types::{InlayHintParams, Url};
|
||||
use ruff_db::source::{line_index, source_text};
|
||||
|
|
|
@ -4,7 +4,7 @@ use lsp_server::{Notification, RequestId};
|
|||
use rustc_hash::FxHashMap;
|
||||
use serde_json::Value;
|
||||
|
||||
use super::{schedule::Task, ClientSender};
|
||||
use super::{ClientSender, schedule::Task};
|
||||
|
||||
type ResponseBuilder<'s> = Box<dyn FnOnce(lsp_server::Response) -> Task<'s>>;
|
||||
|
||||
|
|
|
@ -124,7 +124,9 @@ impl Connection {
|
|||
lsp::Message::Notification(lsp::Notification { method, .. })
|
||||
if method == lsp_types::notification::Exit::METHOD =>
|
||||
{
|
||||
anyhow::bail!("Server received an exit notification before a shutdown request was sent. Exiting...");
|
||||
anyhow::bail!(
|
||||
"Server received an exit notification before a shutdown request was sent. Exiting..."
|
||||
);
|
||||
}
|
||||
_ => Ok(false),
|
||||
}
|
||||
|
|
|
@ -12,7 +12,7 @@ use self::{
|
|||
thread::ThreadPriority,
|
||||
};
|
||||
|
||||
use super::{client::Client, ClientSender};
|
||||
use super::{ClientSender, client::Client};
|
||||
|
||||
/// The event loop thread is actually a secondary thread that we spawn from the
|
||||
/// _actual_ main thread. This secondary thread has a larger stack size
|
||||
|
|
|
@ -16,8 +16,8 @@
|
|||
use std::{
|
||||
num::NonZeroUsize,
|
||||
sync::{
|
||||
atomic::{AtomicUsize, Ordering},
|
||||
Arc,
|
||||
atomic::{AtomicUsize, Ordering},
|
||||
},
|
||||
};
|
||||
|
||||
|
|
|
@ -8,13 +8,13 @@ use std::sync::Arc;
|
|||
use anyhow::anyhow;
|
||||
use lsp_types::{ClientCapabilities, TextDocumentContentChangeEvent, Url};
|
||||
|
||||
use ruff_db::files::{system_path_to_file, File};
|
||||
use ruff_db::system::SystemPath;
|
||||
use ruff_db::Db;
|
||||
use ruff_db::files::{File, system_path_to_file};
|
||||
use ruff_db::system::SystemPath;
|
||||
use ty_project::{ProjectDatabase, ProjectMetadata};
|
||||
|
||||
use crate::document::{DocumentKey, DocumentVersion, NotebookDocument};
|
||||
use crate::system::{url_to_any_system_path, AnySystemPath, LSPSystem};
|
||||
use crate::system::{AnySystemPath, LSPSystem, url_to_any_system_path};
|
||||
use crate::{PositionEncoding, TextDocument};
|
||||
|
||||
pub(crate) use self::capabilities::ResolvedClientCapabilities;
|
||||
|
|
|
@ -5,8 +5,8 @@ use lsp_types::Url;
|
|||
use rustc_hash::FxHashMap;
|
||||
|
||||
use crate::{
|
||||
document::{DocumentKey, DocumentVersion, NotebookDocument},
|
||||
PositionEncoding, TextDocument,
|
||||
document::{DocumentKey, DocumentVersion, NotebookDocument},
|
||||
};
|
||||
|
||||
use super::ClientSettings;
|
||||
|
|
|
@ -13,8 +13,8 @@ use ruff_db::system::{
|
|||
use ruff_notebook::{Notebook, NotebookError};
|
||||
use ty_python_semantic::Db;
|
||||
|
||||
use crate::session::index::Index;
|
||||
use crate::DocumentQuery;
|
||||
use crate::session::index::Index;
|
||||
|
||||
/// Converts the given [`Url`] to an [`AnySystemPath`].
|
||||
///
|
||||
|
@ -221,7 +221,7 @@ impl System for LSPSystem {
|
|||
&self,
|
||||
pattern: &str,
|
||||
) -> std::result::Result<
|
||||
Box<dyn Iterator<Item = std::result::Result<SystemPathBuf, GlobError>>>,
|
||||
Box<dyn Iterator<Item = std::result::Result<SystemPathBuf, GlobError>> + '_>,
|
||||
PatternError,
|
||||
> {
|
||||
self.os_system.glob(pattern)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue