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

Function generate_function_name

src/code_actions/extract_function.rs:398–407  ·  view source on GitHub ↗

Generate a contextual name for the extracted function/method. The naming follows these heuristics (first match wins): 1. **Guard strategies** (`VoidGuards`, `UniformGuards`, `NullGuardWithValue`): `{enclosing}Guard` — the user extracted validation / precondition logic. 2. **`SentinelNull`**: `try{Enclosing}` — a "try" pattern where `null` signals failure. 3. **`TrailingReturn` with `new ClassNam

(
    content: &str,
    enclosing_ctx: &EnclosingContext,
    naming: &NamingContext,
)

Source from the content-addressed store, hash-verified

396/// existing names in the appropriate scope (class members for methods,
397/// file-level `function` declarations for standalone functions).
398fn generate_function_name(
399 content: &str,
400 enclosing_ctx: &EnclosingContext,
401 naming: &NamingContext,
402) -> String {
403 let base = derive_base_name(naming);
404
405 // Deduplicate against the right scope.
406 deduplicate_name(&base, content, enclosing_ctx)
407}
408
409/// Pick a base name from the naming context (before deduplication).
410fn derive_base_name(ctx: &NamingContext) -> String {

Calls 2

derive_base_nameFunction · 0.85
deduplicate_nameFunction · 0.70