mirror of
https://github.com/astral-sh/ruff.git
synced 2025-09-28 12:55:05 +00:00
Add as_slice
method for all string nodes (#9111)
This PR adds a `as_slice` method to all the string nodes which returns all the parts of the nodes as a slice. This will be useful in the next PR to split the string formatting to use this method to extract the _single node_ or _implicitly concanated nodes_.
This commit is contained in:
parent
cb99815c3e
commit
18452cf477
13 changed files with 121 additions and 65 deletions
|
@ -477,7 +477,7 @@ pub fn walk_expr<'a, V: Visitor<'a> + ?Sized>(visitor: &mut V, expr: &'a Expr) {
|
|||
visitor.visit_arguments(arguments);
|
||||
}
|
||||
Expr::FString(ast::ExprFString { value, .. }) => {
|
||||
for part in value.parts() {
|
||||
for part in value {
|
||||
match part {
|
||||
FStringPart::Literal(string_literal) => {
|
||||
visitor.visit_string_literal(string_literal);
|
||||
|
@ -487,12 +487,12 @@ pub fn walk_expr<'a, V: Visitor<'a> + ?Sized>(visitor: &mut V, expr: &'a Expr) {
|
|||
}
|
||||
}
|
||||
Expr::StringLiteral(ast::ExprStringLiteral { value, .. }) => {
|
||||
for string_literal in value.parts() {
|
||||
for string_literal in value {
|
||||
visitor.visit_string_literal(string_literal);
|
||||
}
|
||||
}
|
||||
Expr::BytesLiteral(ast::ExprBytesLiteral { value, .. }) => {
|
||||
for bytes_literal in value.parts() {
|
||||
for bytes_literal in value {
|
||||
visitor.visit_bytes_literal(bytes_literal);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue