redhat-developer / redhat-developer/vscode-java
Organize Imports should be smarter about single-letter types
还没有人认领这个 Issue。
- 主要语言
- 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
- 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.javafile
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
贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
调研方向
从 Organize Imports 的入口点开始,使用此 issue 中的 Java 代码片段复现该行为,并使用一个可供导入的单字母类型(例如 T)。当扩展不再盲目导入这个单字母类型,而是报告缺少类型变量的问题或请求确认时,这项工作就完成了。
由索引模型根据 Issue 内容生成。
评估
- 技术栈
- java, typescript, vscode
- 领域
- developer-experience, tooling
- Issue 类型
- 缺陷
- 难度
- 4/5
- 预计耗时
- 3-5 天
- 活跃度
- 停滞
- 描述清晰度
- 基本清楚
- 新手友好度
- 42/100