vscode-intelephense
vscode-intelephense copied to clipboard
Support move file/folder refactoring
Move a file or folder and have namespaces corrected if the original path and namespace was aligned.
This would me much appreciated. It’s the only thing that Storm offers (that I use) and vscode doesn’t.
I now find myself opening storm to do some class/namespace refactors, after which I continue work as usual in code.
I wouldn’t mind if this would be a premium feature (like rename class).
Would be really neat addition to premium features. Any plans about this one?
@bmewburn The website states that Intelephense does support this as a premium feature:
Rename. Easily rename symbols with automatic file/folder renaming too.
However, I don't have this option available, and this issue seems to imply that the website is incorrect. Could you please clarify this? Thanks!
@levacic renaming a class or namespace should also rename the file/folder if the old name matched the filename/folder. This ticket is to support the other way around, renaming a file/folder renames the namespace and/or class.
@bmewburn That sounds great, however - I don't really see a way how to trigger this behavior, and I've tried a bunch of stuff. Most of the other premium features do work correctly for me (e.g. find all implementations, go to type definition/declaration, PHPDoc generation etc.). I've also tried to find if this is documented anywhere, but had no luck with that either.
Thanks!
Edit: I've just realized that the other features weren't working for me either, and the license key got unset for some reason - I've set it back and got access to the "Rename symbol" option which wasn't there before. My mistake!
It does work correctly when renaming a class name for example, however when I try to rename a namespace, it doesn't get moved to a new location. Is Intelephense aware of autoloading configuration and stuff like that? I'm working with Laravel, where the majority of the code will usually be under the App
namespace, in the app
folder in the project root - which isn't an exact match - e.g. the class App\Foo\Bar
will be in the app/Foo/Bar.php
file.
@levacic if it's not behaving as expected please open a new ticket with a code example that reproduces the problem and I will take a look.
@bmewburn maybe for this we can use the https://code.visualstudio.com/api/references/vscode-api#workspace events like onWillRenameFiles
this way u can get the old & new path of the folder & contents then make a project search & rename for the namespaces.
i worked on this today and its added to https://github.com/ctf0/vscode-php-refactor, give it a try and reply back for any issues.
Any update on this? I'd love to have PHP move refactoring in VSCode. Like someone mentioned above, I also have to switch to PHPStorm to do move refactoring.
Little bump on this feature that is quite important. Big projects are a pain to refactor. Refactoring a namespace symbol already works, so handling all children files of a directory should be rather trivial. cc @bmewburn
Another bump as this is the ONLY thing keeping me in phpstorm at the moment.
Related: https://github.com/bmewburn/vscode-intelephense/issues/2480