redhat-developer / redhat-developer/vscode-java

Organize Imports should be smarter about single-letter types

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

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

code action
主要言語
TypeScript
スター
2.3k
フォーク
546
平均マージ
20時間 1分
マージ済み PR(30日)
11

説明

When there's an unresolved single-letter type usage in the code, doing Organize Imports should not blindly import a type it finds

Environment
  • Operating System: Windows 10
  • JDK version: 14
  • Visual Studio Code version: 1.45.0
  • Java extension version: 0.61.0
Steps To Reproduce
  1. do Organize Imports on the code below, while there's a single type T available for import (in my case it was inside Apache POI, but you could just create a trivial T.java file
import java.util.Map;

//import org.apache.poi.ss.formula.functions.T;

public class Bar {

    public void print(Comparable<T> bar, Map<Integer, T> whatever) {

    }

}
Current Result

the type T is imported

Expected Result

the actual issue here is that I forgot to specify the type variable T. Ideally, the extension would give a single error saying exactly that. If that's not feasible, it should at least ask confirmation before importing single-letter types, even if there's only a single one available: the chances that the user actually wants to import such a type are much smaller than the chance that there's an error w.r.t. type variables

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

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

はじめの一歩

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

調査の方向性

Organize Imports のエントリポイントから始め、この issue の Java スニペットを使って動作を再現します。インポート可能な単一文字の型(T など)を使用してください。拡張機能が単一文字の型を無条件にインポートするのではなく、代わりに不足している型変数の問題を報告するか、確認を求めるようになれば作業は完了です。

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

評価

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

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

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