redhat-developer / redhat-developer/vscode-java

Organize Imports should be smarter about single-letter types

未关闭
#1,438 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

还没有人认领这个 Issue。

code action
主要语言
TypeScript
星标
2.3k
派生
547
平均合并
20 小时 1 分钟
30 天内合并 PR
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. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

调研方向

从 Organize Imports 的入口点开始,使用此 issue 中的 Java 代码片段复现该行为,并使用一个可供导入的单字母类型(例如 T)。当扩展不再盲目导入这个单字母类型,而是报告缺少类型变量的问题或请求确认时,这项工作就完成了。

由索引模型根据 Issue 内容生成。

评估

技术栈
java, typescript, vscode
领域
developer-experience, tooling
Issue 类型
缺陷
难度
4/5
预计耗时
3-5 天
活跃度
停滞
描述清晰度
基本清楚
新手友好度
42/100

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。