redhat-developer / redhat-developer/vscode-java

Prioritize and Differentiate Method Completions by Declaring Type

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

还没有人认领这个 Issue。

enhancement
主要语言
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:

  1. Methods declared in the current class
  2. Methods from direct superclasses
  3. Methods from interfaces
  4. 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:

  1. derivedMethod()
  2. baseMethod()
  3. 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:

  1. findByEmail(String email) // declared in UserRepository
  2. findAll() // from PagingRepository
  3. 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

贡献指南

打开贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

调研方向

Issue 中没有确定实现文件或测试。首先定位 Java 补全排序和补全项展示的入口点,然后跟踪声明类型和继承的表示方式。定义当前方法、直接祖先方法、接口方法和更深层方法的补全顺序及视觉标记,并为类继承和接口继承示例添加覆盖。

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

评估

技术栈
java, typescript
领域
developer-experience, tooling
Issue 类型
功能
难度
5/5
预计耗时
一周以上
活跃度
冷清
描述清晰度
基本清楚
新手友好度
35/100

把新 issue 发到你的邮箱

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