redhat-developer / redhat-developer/vscode-java

Prioritize and Differentiate Method Completions by Declaring Type

Đang mở
#4,408 0 bình luận 0 reaction 0 người được giao Xem trên GitHub

Chưa có ai nhận issue này.

enhancement
Ngôn ngữ chính
TypeScript
Star
2.3k
Fork
546
Merge trung bình
20 giờ 1 phút
Pull request đã merge (30 ngày)
11

Mô tả

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

Hướng dẫn đóng góp

Mở hướng dẫn đóng góp

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Hướng nghiên cứu

Issue không xác định tệp triển khai hoặc bài kiểm thử nào. Hãy bắt đầu bằng cách tìm các điểm vào của việc xếp hạng hoàn thành Java và trình bày mục hoàn thành, sau đó lần theo cách các kiểu khai báo và tính kế thừa được biểu diễn. Xác định thứ tự hoàn thành và các dấu hiệu trực quan cho các phương thức hiện tại, phương thức của tổ tiên trực tiếp, phương thức của interface và các phương thức ở cấp sâu hơn, đồng thời bổ sung độ bao phủ cho các ví dụ kế thừa cả lớp và interface.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Đánh giá

Công nghệ
java, typescript
Lĩnh vực
developer-experience, tooling
Loại issue
Tính năng
Độ khó
5/5
Thời gian dự kiến
Hơn một tuần
Mức độ hoạt động
Ít trao đổi
Độ rõ ràng
Khá rõ ràng
Mức phù hợp với người mới
35/100

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.