Computes the strings preferred quotes and normalizes its content.
(&self, string: StringLikePart)
| 235 | |
| 236 | /// Computes the strings preferred quotes and normalizes its content. |
| 237 | pub(crate) fn normalize(&self, string: StringLikePart) -> NormalizedString<'src> { |
| 238 | let raw_content = &self.context.source()[string.content_range()]; |
| 239 | let quote_selection = self.choose_quotes(string); |
| 240 | |
| 241 | let normalized = if let Some(first_quote_or_escape_offset) = |
| 242 | quote_selection.first_quote_or_normalized_char_offset |
| 243 | { |
| 244 | normalize_string( |
| 245 | raw_content, |
| 246 | first_quote_or_escape_offset, |
| 247 | quote_selection.flags, |
| 248 | false, |
| 249 | ) |
| 250 | } else { |
| 251 | Cow::Borrowed(raw_content) |
| 252 | }; |
| 253 | |
| 254 | NormalizedString { |
| 255 | flags: quote_selection.flags, |
| 256 | content_range: string.content_range(), |
| 257 | text: normalized, |
| 258 | } |
| 259 | } |
| 260 | } |
| 261 | |
| 262 | #[derive(Debug)] |
no test coverage detected