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”
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:=mailbox.Mailbox{}
box.client=.... // will become capital automatically via f2 type rename issued by ai
box.name=.... // will become capital automatically via f2 type rename issued by ai
etc....
}
// main.go
func useMailbox(){
box:=mailbox.Mailbox{}
// 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:
Press F2 many times and wait for the refactor to complete in order to rename it.
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.
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:
Use makes a request via the interface, e.g. “rename all symbols in this struct to capital”
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.
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.