mirror of
https://github.com/astral-sh/ruff.git
synced 2025-08-04 10:48:32 +00:00
Add text_len()
methods to more *Prefix
enums in ruff_python_ast
(#16254)
Some checks are pending
CI / Determine changes (push) Waiting to run
CI / cargo fmt (push) Waiting to run
CI / cargo clippy (push) Blocked by required conditions
CI / cargo test (linux) (push) Blocked by required conditions
CI / cargo test (linux, release) (push) Blocked by required conditions
CI / cargo test (windows) (push) Blocked by required conditions
CI / cargo test (wasm) (push) Blocked by required conditions
CI / cargo build (release) (push) Waiting to run
CI / cargo build (msrv) (push) Blocked by required conditions
CI / cargo fuzz build (push) Blocked by required conditions
CI / fuzz parser (push) Blocked by required conditions
CI / test scripts (push) Blocked by required conditions
CI / ecosystem (push) Blocked by required conditions
CI / cargo shear (push) Blocked by required conditions
CI / python package (push) Waiting to run
CI / pre-commit (push) Waiting to run
CI / mkdocs (push) Waiting to run
CI / formatter instabilities and black similarity (push) Blocked by required conditions
CI / test ruff-lsp (push) Blocked by required conditions
CI / benchmarks (push) Blocked by required conditions
Some checks are pending
CI / Determine changes (push) Waiting to run
CI / cargo fmt (push) Waiting to run
CI / cargo clippy (push) Blocked by required conditions
CI / cargo test (linux) (push) Blocked by required conditions
CI / cargo test (linux, release) (push) Blocked by required conditions
CI / cargo test (windows) (push) Blocked by required conditions
CI / cargo test (wasm) (push) Blocked by required conditions
CI / cargo build (release) (push) Waiting to run
CI / cargo build (msrv) (push) Blocked by required conditions
CI / cargo fuzz build (push) Blocked by required conditions
CI / fuzz parser (push) Blocked by required conditions
CI / test scripts (push) Blocked by required conditions
CI / ecosystem (push) Blocked by required conditions
CI / cargo shear (push) Blocked by required conditions
CI / python package (push) Waiting to run
CI / pre-commit (push) Waiting to run
CI / mkdocs (push) Waiting to run
CI / formatter instabilities and black similarity (push) Blocked by required conditions
CI / test ruff-lsp (push) Blocked by required conditions
CI / benchmarks (push) Blocked by required conditions
This commit is contained in:
parent
55ea09401a
commit
f50849aeef
2 changed files with 23 additions and 1 deletions
|
@ -1029,7 +1029,7 @@ pub trait StringFlags: Copy {
|
|||
/// i.e., the length of the prefixes plus the length
|
||||
/// of the quotes used to open the string.
|
||||
fn opener_len(self) -> TextSize {
|
||||
self.prefix().as_str().text_len() + self.quote_len()
|
||||
self.prefix().text_len() + self.quote_len()
|
||||
}
|
||||
|
||||
/// The total length of the string's closer.
|
||||
|
|
|
@ -71,6 +71,13 @@ impl FStringPrefix {
|
|||
}
|
||||
}
|
||||
|
||||
pub const fn text_len(self) -> TextSize {
|
||||
match self {
|
||||
Self::Regular => TextSize::new(1),
|
||||
Self::Raw { .. } => TextSize::new(2),
|
||||
}
|
||||
}
|
||||
|
||||
/// Return true if this prefix indicates a "raw f-string",
|
||||
/// e.g. `rf"{bar}"` or `Rf"{bar}"`
|
||||
pub const fn is_raw(self) -> bool {
|
||||
|
@ -105,6 +112,13 @@ impl ByteStringPrefix {
|
|||
}
|
||||
}
|
||||
|
||||
pub const fn text_len(self) -> TextSize {
|
||||
match self {
|
||||
Self::Regular => TextSize::new(1),
|
||||
Self::Raw { .. } => TextSize::new(2),
|
||||
}
|
||||
}
|
||||
|
||||
/// Return true if this prefix indicates a "raw bytestring",
|
||||
/// e.g. `rb"foo"` or `Rb"foo"`
|
||||
pub const fn is_raw(self) -> bool {
|
||||
|
@ -150,6 +164,14 @@ impl AnyStringPrefix {
|
|||
}
|
||||
}
|
||||
|
||||
pub const fn text_len(self) -> TextSize {
|
||||
match self {
|
||||
Self::Regular(regular_prefix) => regular_prefix.text_len(),
|
||||
Self::Bytes(bytestring_prefix) => bytestring_prefix.text_len(),
|
||||
Self::Format(fstring_prefix) => fstring_prefix.text_len(),
|
||||
}
|
||||
}
|
||||
|
||||
pub const fn is_raw(self) -> bool {
|
||||
match self {
|
||||
Self::Regular(regular_prefix) => regular_prefix.is_raw(),
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue