redhat-developer / redhat-developer/vscode-java

Inconsistant results when performing a textDocument/references request with multiple anonymous classes

Đang mở
#2,781 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.

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

Mô tả

Environment
  • Operating System: Windows 10 x64
  • JDK version: 17.0.3
  • Visual Studio Code version: 1.73
  • Java extension version: 1.12
Description

Hello, I have noticed that since the last version of the extension (v 1.12), finding the references of a symbol now includes the declaration of the symbol. This new feature was asked in this issue and was resolved by managing the includeDeclaration provided in the context of the textDocument/references request.

I have tested this new feature and I found some strange results in my opinion. This happens when using anonymous class.

First case with anonymous classes

In the first screenshot I'm sending, I instantiate multiple anonymous classes form the interface ActionListener. And if I ask for the references on a specific actionPerformed method, the language servers returns all the declarations of this method, even if they are from different anonymous classes.

all-declarations-found

Second classes with named classes

Now in the second screenshot, instead of using anonymous classes, I define multiple classes that implement the ActionListener interface. Now, if I ask for the references on a specific actionPerformed method, this time i will only get the declaration of the given symbol, not the declarations of this method done by the other classes.
just-one-declaration

Discussion

I'm not really sure, but i do think that the results from the second case (with the named classes) is more "correct". In this case, I do get only the references on the symbol i asked. While in the first case (with the anonymous classes), I also get the declarations done by other anonymous classes that are not related to the specific symbol I ask.

Disable the includeDeclaration ?

And one more question, is it possible to set the includeDeclaration flag to false while using your extension?

Thank's in advance for your returns ;)

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

Bắt đầu bằng cách tái hiện yêu cầu textDocument/references với nhiều triển khai ActionListener ẩn danh và có tên, đồng thời so sánh kết quả khi sử dụng includeDeclaration. Điều tra cách tiện ích mở rộng Java xử lý các khai báo phương thức của lớp ẩn danh và xác định xem các tham chiếu có nên khớp với hành vi của lớp có tên hay cung cấp cách tắt includeDeclaration hay không.

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
Lĩnh vực
devtools
Loại issue
Lỗi
Độ khó
4/5
Thời gian dự kiến
3-5 ngày
Mức độ hoạt động
Đình trệ
Độ rõ ràng
Cần làm rõ
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.