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

Function deduplicate_constant_name

src/code_actions/extract_constant.rs:349–360  ·  view source on GitHub ↗

Ensure the generated name doesn't collide with existing constants. If it does, append a numeric suffix.

(name: &str, existing: &[String])

Source from the content-addressed store, hash-verified

347/// Ensure the generated name doesn't collide with existing constants.
348/// If it does, append a numeric suffix.
349fn deduplicate_constant_name(name: &str, existing: &[String]) -> String {
350 if !existing.iter().any(|e| e == name) {
351 return name.to_string();
352 }
353 for i in 1u32.. {
354 let candidate = format!("{}_{}", name, i);
355 if !existing.iter().any(|e| e == &candidate) {
356 return candidate;
357 }
358 }
359 unreachable!()
360}
361
362// ─── AST helpers ────────────────────────────────────────────────────────────
363

Callers 4

deduplicate_no_collisionFunction · 0.85

Calls 1

iterMethod · 0.80

Tested by 3

deduplicate_no_collisionFunction · 0.68