Extract the string value from a literal string expression by reading the source text between the expression's span and stripping quotes.
(
expr: &expression::Expression<'_>,
content: &str,
)
| 594 | /// Extract the string value from a literal string expression by reading |
| 595 | /// the source text between the expression's span and stripping quotes. |
| 596 | fn extract_string_literal_value( |
| 597 | expr: &expression::Expression<'_>, |
| 598 | content: &str, |
| 599 | ) -> Option<String> { |
| 600 | let span = expr.span(); |
| 601 | let start = span.start.offset as usize; |
| 602 | let end = span.end.offset as usize; |
| 603 | let raw = content.get(start..end)?; |
| 604 | // Strip surrounding quotes (single or double). |
| 605 | let trimmed = raw.trim(); |
| 606 | if (trimmed.starts_with('\'') && trimmed.ends_with('\'')) |
| 607 | || (trimmed.starts_with('"') && trimmed.ends_with('"')) |
| 608 | { |
| 609 | Some(trimmed[1..trimmed.len() - 1].to_string()) |
| 610 | } else { |
| 611 | Some(trimmed.to_string()) |
| 612 | } |
| 613 | } |
| 614 | |
| 615 | // ─── Thread-local parse cache ─────────────────────────────────────────────── |
| 616 | // |
no test coverage detected