MCPcopy Create free account
hub / github.com/PHPantom-dev/phpantom_lsp / split_concat_parts

Function split_concat_parts

src/code_actions/extract_constant.rs:178–200  ·  view source on GitHub ↗

Split a string on the PHP `.` concatenation operator, respecting string literal boundaries.

(text: &str)

Source from the content-addressed store, hash-verified

176/// Split a string on the PHP `.` concatenation operator, respecting
177/// string literal boundaries.
178fn split_concat_parts(text: &str) -> Vec<&str> {
179 let mut parts = Vec::new();
180 let bytes = text.as_bytes();
181 let mut start = 0;
182 let mut i = 0;
183 let mut in_single = false;
184 let mut in_double = false;
185
186 while i < bytes.len() {
187 match bytes[i] {
188 b'\'' if !in_double => in_single = !in_single,
189 b'"' if !in_single => in_double = !in_double,
190 b'.' if !in_single && !in_double => {
191 parts.push(&text[start..i]);
192 start = i + 1;
193 }
194 _ => {}
195 }
196 i += 1;
197 }
198 parts.push(&text[start..]);
199 parts
200}
201
202// ─── Name generation ────────────────────────────────────────────────────────
203

Callers 1

is_concat_expressionFunction · 0.85

Calls 1

pushMethod · 0.80

Tested by

no test coverage detected