Combine symbols refactor with ai

Can I do something like:

Rename all members of this golang struct to capital letters (to make them exportable), but don’t just change the text, actually do an IDE rename so that all referencing symbols are changed to uppercase as well? I tried to do it but didn’t see a way to tell the ai to “rename the symbol at the ide level”

Does the F2 shortcut maybe work here?

Otherwise, you can try using the /edit slash command in Chat.

I wasn’t clear. I want to combine refactoring with AI. For example, give the files below, I want to issue a prompt that says:

Refactor all attributed in the selected struct (e.g. Mailbox) to capitalized words

// mailbox.go
type Mailbox struct {
	client      models.Client
	name        string
	uidValidity uint32
	uidNext     uint32
	attributes  utils.Set[string]

func New(){
     box.client=.... // will become capital automatically via f2 type rename issued by ai   // will become capital automatically via f2 type rename issued by ai

// main.go
func useMailbox(){
   // all box attributes will become available

That way it’s like pressing F2 on each symbol so it does all the renaming of referencing code for you. In reality, I have a struct with 30+ attributes, all referenced in interfaces and throughout the package.

I had to either:

  1. Press F2 many times and wait for the refactor to complete in order to rename it.
  2. Rename all to capital letters using a multi-cursor and then fix all the reference errors manually (this is what I ended up doing).

I don’t thinkg /edit works here because this is a cross file change, also we should utilize the LSP since it knows for sure where all the symbols are.

@Jakob is it clear now? Is there a feature for this?

No, I think for that situation, using the F2 shortcut many times is the best way. I think currently that would still be faster and less prone to errors than letting AI look through and edit every file.

@Jakob , I don’t think we should let AI look through and edit every file.

I think there should be an integration between the LSP and the AI.

Here’s how I imagine it:

  1. Use makes a request via the interface, e.g. “rename all symbols in this struct to capital”
  2. AI transforms that request into a list of plain text commands e.g:
    a. Transform client in Mailbox to Client
    b. Transform name in Mailbox to Name
    c. …,etc.
  3. A new layer called the LSP integration layer (doesn’t directy edit files, but rather issues commands to the LSP), transforms each of the commands into a proper LSP request (e.g. using vscode-languageserver) and executes them.

If you’re open source I can make a PR

That’s a good idea. Probably something for the Interpreter Mode.

Is there documentation for Interpreter Mode?

1 Like

@shmuel Unfortunately, not yet. But I will add it to soon.