redhat-developer / redhat-developer/vscode-java
Organize imports removes valid imports in Java files with compile errors
まだ誰も着手していません。
- 主要言語
- TypeScript
- スター
- 2.3k
- フォーク
- 546
- 平均マージ
- 20時間 1分
- マージ済み PR(30日)
- 11
説明
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.
コントリビューションガイド
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
調査の方向性
まず、importとコンパイルエラーを含むJavaファイルで問題を再現し、保存時にOrganize Importsコードアクションまたはsource.organizeImportsを実行します。コードアクションの処理を追跡して、コンパイルエラーが未使用importの検出にどのような影響を与えるかを確認します。Javaファイルにコンパイルエラーがある場合でも有効なimportが保持されれば完了です。
索引モデルが issue の本文から書いたものです。
評価
- 技術スタック
- java, vscode
- 領域
- developer-experience, tooling
- issue の種類
- バグ
- 難易度
- 4/5
- 見積もり時間
- 3〜5日
- 活発さ
- 停滞
- 明瞭さ
- おおむね明確
- 初心者へのやさしさ
- 42/100