Skip to content

Prompt for name when using extract refactoring assists #17579

Open
@joshka

Description

@joshka

In typescript, extracting a variable / function / etc. allows you to enter a name for the just created extraction. It would be nice to do the same in RA for functions, modules, variables, etc.

image image

Playing with the extract_variable:

if let Some(cap) = ctx.config.snippet_cap {
    if let Some(ast::Pat::IdentPat(ident_pat)) = let_stmt.pat() {
        if let Some(name) = ident_pat.name() {
-            edit.add_tabstop_before(cap, name);
+            edit.add_placeholder_snippet_group(
+                cap,
+                vec![name.syntax().clone(), name_expr.syntax().clone()],
            )
        }
    }
}

SourceChangeBuilder::add_placeholder_snippet_token doesn't seem quite right for this. Instead of a single edit location which applies to both places when the edit is confirmed, this method makes two edit locations that are edited simultaneously.

image

I'm not quite sure what the right terminology to use to find the functionality here, so seeking some guidance on what to do to make this work.

Edit: this UX is provided by the rename symbol function, but I'm not sure how that would fit in to the extract refactoring.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions