redhat-developer / redhat-developer/vscode-java

Organize imports removes valid imports in Java files with compile errors

オープン
#2,294 コメント 8 件 リアクション 2 件 担当者 0 名 GitHub で見る

まだ誰も着手していません。

bug code action
主要言語
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
  1. Introduce an import
  2. Create a compile error that will invalidate the reference

java_compile_error_organize_import

Current Result

All "unused" imports are removed.

Expected Result

Don't remove imports when the Java file has compile errors.

コントリビューションガイド

コントリビューションガイドを開く

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

調査の方向性

まず、importとコンパイルエラーを含むJavaファイルで問題を再現し、保存時にOrganize Importsコードアクションまたはsource.organizeImportsを実行します。コードアクションの処理を追跡して、コンパイルエラーが未使用importの検出にどのような影響を与えるかを確認します。Javaファイルにコンパイルエラーがある場合でも有効なimportが保持されれば完了です。

索引モデルが issue の本文から書いたものです。

評価

技術スタック
java, vscode
領域
developer-experience, tooling
issue の種類
バグ
難易度
4/5
見積もり時間
3〜5日
活発さ
停滞
明瞭さ
おおむね明確
初心者へのやさしさ
42/100

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。