Open
Description
Organize imports will remove imports when the references are not valid Java code anymore. This might remove "valid" imports that just happen to be unused at that moment, because there is a compile error before the reference. The references cannot be easily restored once the compile errors are fixed, e.g. manually created static imports. This is problematic in long files with many imports and "editor.codeActionsOnSave" : ["source.organizeImports", ...]
. A typo in the "wrong" place can easily remove all your imports.
Environment
- Operating System: Ubuntu 20.04.3 LTS
- JDK version: 11.0.6+10
- Visual Studio Code version: 1.63.2
- Java extension version: 1.2.0
Steps To Reproduce
- Introduce an import
- Create a compile error that will invalidate the reference
Current Result
All "unused" imports are removed.
Expected Result
Don't remove imports when the Java file has compile errors.