Vscode-java: Refactor when moving files

Created on 14 Sep 2018  路  9Comments  路  Source: redhat-developer/vscode-java

Automatically 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

  1. Move a Java source file to another folder in the explorer

Current Result

  1. The imports in other source files are not updated

Expected Result

  1. The imports should be updated accordingly
code action refactoring

Most helpful comment

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.

All 9 comments

The original change was made for Eclipse Che. @yaohaizh can we also enable this feature at vscode side?

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.

Automatically fixing imports across the project and package declarations would be a killer feature for Java in vscode.

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.

What is the current status on this? There's some work merged here https://github.com/microsoft/vscode/pull/85830
but I see an open ticket for a language server protocol extension https://github.com/microsoft/language-server-protocol/issues/873

I also like this feature

Is there a way I can get notification for when this fix is released?

@noel-yap You can subscribe to this issue and choose to only get notified once it closes.

Hi any update on this?

Was this page helpful?
0 / 5 - 0 ratings

Related issues

ronniehicks picture ronniehicks  路  3Comments

sfariaNG picture sfariaNG  路  3Comments

zalcorshark picture zalcorshark  路  3Comments

protoEvangelion picture protoEvangelion  路  3Comments

yaohaizh picture yaohaizh  路  4Comments