vscode-as3mxml icon indicating copy to clipboard operation
vscode-as3mxml copied to clipboard

Update package names and imports on folder rename or move

Open olafkruger opened this issue 6 years ago • 4 comments

Hi, today, we have to update all imports of affected files manually after renaming or moving a folder. (Or do I miss something?) It would be very helpful if VSCode would do that automatically ;-)

There were already filed a couple of issues regarding this feature, maybe this helps [1].

Thanks, Olaf

[1] https://github.com/Microsoft/vscode/issues/53233

olafkruger avatar Aug 10 '18 08:08 olafkruger

This is definitely a feature that I'd like to add.

It looks like they're using some "proposed" APIs (in other words, the APIs are considered beta-quality) for detecting folder renames for TypeScript/JavaScript imports.

https://code.visualstudio.com/updates/v1_25#_local-rename-events

Listening for renames seems to work like this:

//listen
var subscription = vscode.workspace.onDidRenameFile((event) =>
{
	//event.oldUri
	//event.newUri
});

//stop listening
subscription.dispose();

Right now, there is no API available in the language server protocol. I would need to listen in the VSCode extension, and then I could register a custom command in the language server that VSCode can call.

I will wait until the API moves from "proposed" to stable, though.

joshtynjala avatar Aug 10 '18 17:08 joshtynjala

Yup, I come from FlashDevelop and was expecting all the references to change with class file rename. I hope it gets added soon because having to navigate .as file by .as file and changing all references is time consuming and a pain in the trace( ["a", "r", "s", "e"].join("") ).

Thank you!

angelhdzdev avatar Sep 06 '18 04:09 angelhdzdev

@angelhdz If you're only renaming a single class, you should be able to use Rename Symbol instead of renaming the file in the file explorer, and it will also change all references. You can find Rename Symbol when you right click in the editor.

joshtynjala avatar Sep 06 '18 14:09 joshtynjala

What about this feature? It's would be really helpful

varadig avatar Jan 20 '21 12:01 varadig