mirror of
https://github.com/astral-sh/ruff.git
synced 2025-09-30 05:45:24 +00:00
ruff server
now supports source.fixAll
source action (#10597)
## Summary
`ruff server` now has source action `source.fixAll` as an available code
action.
This also fixes https://github.com/astral-sh/ruff/issues/10593 in the
process of revising the code for quick fix code actions.
## Test Plan
f4c07425
-e68a-445f-a4ed-949c9197a6be
This commit is contained in:
parent
d467aa78c2
commit
257964a8bc
15 changed files with 564 additions and 191 deletions
|
@ -1,34 +1,36 @@
|
|||
//! Data model, state management, and configuration resolution.
|
||||
|
||||
mod types;
|
||||
mod settings;
|
||||
|
||||
use std::collections::BTreeMap;
|
||||
use std::path::{Path, PathBuf};
|
||||
use std::{ops::Deref, sync::Arc};
|
||||
|
||||
use anyhow::anyhow;
|
||||
use lsp_types::{ServerCapabilities, Url};
|
||||
use lsp_types::{ClientCapabilities, ServerCapabilities, Url};
|
||||
use ruff_workspace::resolver::{ConfigurationTransformer, Relativity};
|
||||
use rustc_hash::FxHashMap;
|
||||
|
||||
use crate::edit::{Document, DocumentVersion};
|
||||
use crate::PositionEncoding;
|
||||
|
||||
use self::settings::ResolvedClientCapabilities;
|
||||
|
||||
/// The global state for the LSP
|
||||
pub(crate) struct Session {
|
||||
/// Workspace folders in the current session, which contain the state of all open files.
|
||||
workspaces: Workspaces,
|
||||
/// The global position encoding, negotiated during LSP initialization.
|
||||
position_encoding: PositionEncoding,
|
||||
/// Extension-specific settings, set by the client, that apply to all workspace folders.
|
||||
#[allow(dead_code)]
|
||||
lsp_settings: types::ExtensionSettings,
|
||||
/// Tracks what LSP features the client supports and doesn't support.
|
||||
resolved_client_capabilities: Arc<ResolvedClientCapabilities>,
|
||||
}
|
||||
|
||||
/// An immutable snapshot of `Session` that references
|
||||
/// a specific document.
|
||||
pub(crate) struct DocumentSnapshot {
|
||||
configuration: Arc<RuffConfiguration>,
|
||||
resolved_client_capabilities: Arc<ResolvedClientCapabilities>,
|
||||
document_ref: DocumentRef,
|
||||
position_encoding: PositionEncoding,
|
||||
url: Url,
|
||||
|
@ -70,6 +72,7 @@ pub(crate) struct DocumentRef {
|
|||
|
||||
impl Session {
|
||||
pub(crate) fn new(
|
||||
client_capabilities: &ClientCapabilities,
|
||||
server_capabilities: &ServerCapabilities,
|
||||
workspaces: &[Url],
|
||||
) -> crate::Result<Self> {
|
||||
|
@ -79,7 +82,9 @@ impl Session {
|
|||
.as_ref()
|
||||
.and_then(|encoding| encoding.try_into().ok())
|
||||
.unwrap_or_default(),
|
||||
lsp_settings: types::ExtensionSettings,
|
||||
resolved_client_capabilities: Arc::new(ResolvedClientCapabilities::new(
|
||||
client_capabilities,
|
||||
)),
|
||||
workspaces: Workspaces::new(workspaces)?,
|
||||
})
|
||||
}
|
||||
|
@ -87,6 +92,7 @@ impl Session {
|
|||
pub(crate) fn take_snapshot(&self, url: &Url) -> Option<DocumentSnapshot> {
|
||||
Some(DocumentSnapshot {
|
||||
configuration: self.workspaces.configuration(url)?.clone(),
|
||||
resolved_client_capabilities: self.resolved_client_capabilities.clone(),
|
||||
document_ref: self.workspaces.snapshot(url)?,
|
||||
position_encoding: self.position_encoding,
|
||||
url: url.clone(),
|
||||
|
@ -196,6 +202,10 @@ impl DocumentSnapshot {
|
|||
&self.configuration
|
||||
}
|
||||
|
||||
pub(crate) fn resolved_client_capabilities(&self) -> &ResolvedClientCapabilities {
|
||||
&self.resolved_client_capabilities
|
||||
}
|
||||
|
||||
pub(crate) fn document(&self) -> &DocumentRef {
|
||||
&self.document_ref
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue