redhat-developer / redhat-developer/vscode-java
Improve quick fix
まだ誰も着手していません。
- 主要言語
- TypeScript
- スター
- 2.3k
- フォーク
- 546
- 平均マージ
- 20時間 1分
- マージ済み PR(30日)
- 11
説明
Hi! I would like to suggest a new feature to improve the extension.
When programming in Java is a very common mistake to import the wrong class for some basic types. For example, importing java.awt.List instead of java.util.List.
In such cases, you don't have a quick fix action to solve the problem. Check the image below:

To fix this, one solution is to trigger the auto completion and choose the right type. But then, the extension will include the whole class name to avoid conflicts, because it probably assumes that you may have other classes with the same name in use on the code. Check the image below:

So, my suggestion is to include a quick fix (and an auto completion) named "Replace by ..." where the user can choose to replace the import with another option easily. So, if I have the following code:
import java.awt.List;
private List doSomethingWithJavaAwtList(){
// Do domething
}
private List<String> toList(String src){
return Arrays.asList(src.split(","));
}
Then, I can position the cursor on top of List<String>, invoke the quick fix and it will present me the following options:
- Replace misleading import by java.util.List
- Replace misleading import by com.vendor.library.List
Selecting an option imports the right class and (if necessary) replaces other occurrences with the full qualified name. So, for the previous example, it would become:
import java.awt.List;
import java.util.List;
private java.awt.List doSomethingWithJavaAwtList(){
// Do domething
}
private List<String> toList(String src){
return Arrays.asList(src.split(","));
}
The suggestions given by the extension could be provided automatically based on the class name and/or provided by the user in "settings.json", globally or per project/workspace. For example:
{
"java.configurations.misleading-imports.suggestions": {
"List": [
"java.util.List"
],
"Connection" : [
"java.sql.Connection"
]
}
}
Also, it would be interesting to provide a feature allowing the user to quickly set a class as the preferred suggestion on the configurations. Something like this:
- Replace misleading import by java.util.List and set as preferred replacement for this type
コントリビューションガイド
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
調査の方向性
まず、Java の import に関する拡張機能の quick-fix と auto-completion のエントリポイントを追跡し、次に、誤解を招く import の候補に対して提案されている settings.json 設定を確認します。既存の動作を issue の例と比較します。完了条件には、選択可能な置換候補、他の出現箇所を競合なく修飾する処理、任意で指定できる優先置換を含める必要があります。
索引モデルが issue の本文から書いたものです。
評価
- 技術スタック
- java, typescript, vscode
- 領域
- developer-experience, tooling
- issue の種類
- 機能追加
- 難易度
- 5/5
- 見積もり時間
- 1週間以上
- 活発さ
- 停滞
- 明瞭さ
- おおむね明確
- 初心者へのやさしさ
- 30/100