(values: Vec<JoinedStrPart>)
| 61 | } |
| 62 | |
| 63 | fn normalize_joined_str_parts(values: Vec<JoinedStrPart>) -> Vec<JoinedStrPart> { |
| 64 | let mut output = Vec::with_capacity(values.len()); |
| 65 | let mut pending: Option<(String, StringLiteralPrefix, TextRange)> = None; |
| 66 | |
| 67 | for part in values { |
| 68 | match part { |
| 69 | JoinedStrPart::Constant(constant) => { |
| 70 | let ConstantLiteral::Str { value, prefix } = constant.value else { |
| 71 | push_joined_str_literal(&mut output, &mut pending); |
| 72 | output.push(JoinedStrPart::Constant(constant)); |
| 73 | continue; |
| 74 | }; |
| 75 | let value: String = value.into(); |
| 76 | if let Some((pending_value, _, _)) = pending.as_mut() { |
| 77 | pending_value.push_str(&value); |
| 78 | } else { |
| 79 | pending = Some((value, prefix, constant.range)); |
| 80 | } |
| 81 | } |
| 82 | JoinedStrPart::FormattedValue(value) => { |
| 83 | push_joined_str_literal(&mut output, &mut pending); |
| 84 | output.push(JoinedStrPart::FormattedValue(value)); |
| 85 | } |
| 86 | } |
| 87 | } |
| 88 | |
| 89 | push_joined_str_literal(&mut output, &mut pending); |
| 90 | output |
| 91 | } |
| 92 | |
| 93 | fn push_template_str_literal( |
| 94 | output: &mut Vec<TemplateStrPart>, |
no test coverage detected