redhat-developer / redhat-developer/vscode-java
Prioritize and Differentiate Method Completions by Declaring Type
还没有人认领这个 Issue。
- 主要语言
- TypeScript
- 星标
- 2.3k
- 派生
- 546
- 平均合并
- 20 小时 1 分钟
- 30 天内合并 PR
- 11
描述
Summary
Improve Java IntelliSense in Visual Studio Code by prioritizing methods based on their declaring type and visually distinguishing methods declared in the current class from inherited ones.
Problem
When invoking code completion on an object, methods from the entire inheritance hierarchy (class, superclasses, interfaces) are presented in a flat, mostly alphabetical or heuristically ranked list.
This creates two issues:
- Hard to quickly identify methods defined in the current class
- No clear distinction between local vs inherited methods
Expected Behavior
1. Ordering by Declaring Type
Completion items should be grouped and ordered as follows:
- Methods declared in the current class
- Methods from direct superclasses
- Methods from interfaces
- Methods from deeper inheritance levels
Within each group, keep existing sorting (alphabetical or relevance-based).
2. Frequency-Based Promotion
- Frequently used methods may be promoted higher in the list
- However, usage-based ranking should not completely override structural grouping
3. Visual Differentiation
- Methods declared in the current class should be bolded
- (Optional) Other methods may include subtle indicators of their declaring type
Example (Class Inheritance)
class Base {
void baseMethod() {}
}
interface MyInterface {
void interfaceMethod() {}
}
class Derived extends Base implements MyInterface {
void derivedMethod() {}
}
When invoking completion on Derived:
Expected order:
- derivedMethod()
- baseMethod()
- interfaceMethod()
Example (Interface Inheritance)
interface BaseRepository<T> {
void save(T entity);
}
interface PagingRepository<T> extends BaseRepository<T> {
Iterable<T> findAll();
}
interface UserRepository extends PagingRepository<User> {
User findByEmail(String email);
}
When invoking completion on UserRepository:
Expected order:
- findByEmail(String email) // declared in UserRepository
- findAll() // from PagingRepository
- save(T entity) // from BaseRepository
Real-World Use Case
This is especially useful in frameworks like Spring Data / Hibernate, where repositories are composed via multiple interface layers.
For example:
- Developers primarily care about methods declared in their own repository interface
- Framework-provided methods (e.g.,
save,findAll) are secondary but still important
Improved ordering and highlighting would:
- Make custom query methods immediately visible
- Reduce cognitive load when working with large inherited APIs
Motivation
- Faster identification of relevant methods
- Better usability in deep inheritance hierarchies
- Clear distinction between user-defined and framework-provided methods
- Aligns with developer mental models
贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
调研方向
Issue 中没有确定实现文件或测试。首先定位 Java 补全排序和补全项展示的入口点,然后跟踪声明类型和继承的表示方式。定义当前方法、直接祖先方法、接口方法和更深层方法的补全顺序及视觉标记,并为类继承和接口继承示例添加覆盖。
由索引模型根据 Issue 内容生成。
评估
- 技术栈
- java, typescript
- 领域
- developer-experience, tooling
- Issue 类型
- 功能
- 难度
- 5/5
- 预计耗时
- 一周以上
- 活跃度
- 冷清
- 描述清晰度
- 基本清楚
- 新手友好度
- 35/100