Refactor when moving files
See original GitHub issueAutomatically adjust imports and package declarations when moving a class in the file explorer. (As implemented in eclipse/eclipse.jdt.ls#683 ?)
Environment
- Operating System:
Windows 10
- JDK version:
1.8.0_144
- Visual Studio Code version:
1.27.2
- Java extension version:
0.30.0
Steps To Reproduce
- Move a Java source file to another folder in the explorer
Current Result
- The imports in other source files are not updated
Expected Result
- The imports should be updated accordingly
Issue Analytics
- State:
- Created 5 years ago
- Reactions:21
- Comments:9 (1 by maintainers)
Top Results From Across the Web
'refactor' move files in VSCode - es6
If I move a file in the editor, it should find all the import statements and update them to the new location. Is...
Read more >Move to Folder refactoring | JetBrains Rider Documentation
This refactoring helps you move one or several types or files to another project or folder anywhere in your solution.
Read more >Refactor when moving files #26314 - microsoft/vscode
So if i move a file from a folder to another, i want it's path reference to be updated automatically in the project....
Read more >Move type to matching file refactoring - Visual Studio ...
This refactoring applies to: ... What: Lets you move the selected type to a separate file with the same name. When: You have...
Read more >Working with Refactoring
Renaming / Moving Files · Create RenFile1 and RenFile2 as described in steps 1 to 3 underRenaming a File, above. · Within the...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
That’s literally the one thing that’s stopping this (amazing) tool to become the # 1 choice for Java development. I am the only developer in a project of near 100 Java developers who is using VSCode for Java. People are very impressed when I show my Java code in VSCode and also skeptical. So they ask “can it do this?” or “I bet if you try this it won’t let you…”. And refactoring is a key point. I confess I’ve been relying on Eclipse to do more complex code refactoring… It’d be great to have this fetaure incorporated in the tool.
See https://github.com/microsoft/vscode/issues/43768, vscode will fire an FileWillRenameEvent when the user is renaming or moving (drag and drop) files in file explorer. By listening at this event, the language server is able to update package declaration and references.
Currently the change is proposed at vscode insider. When it’s officially ready, it will unblock us on the refactoring features such as move/rename file/rename package name.