redhat-developer / redhat-developer/vscode-java
Inconsistant results when performing a textDocument/references request with multiple anonymous classes
还没有人认领这个 Issue。
- 主要语言
- TypeScript
- 星标
- 2.3k
- 派生
- 547
- 平均合并
- 20 小时 1 分钟
- 30 天内合并 PR
- 11
描述
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.

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.

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 ;)
贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
调研方向
首先,使用多个匿名和命名的 ActionListener 实现重现 textDocument/references 请求,并比较使用 includeDeclaration 时的结果。调查 Java 扩展如何处理匿名类的方法声明,并确定引用是否应与命名类的行为保持一致,或者是否应提供禁用 includeDeclaration 的方式。
由索引模型根据 Issue 内容生成。
评估
- 技术栈
- java
- 领域
- devtools
- Issue 类型
- 缺陷
- 难度
- 4/5
- 预计耗时
- 3-5 天
- 活跃度
- 停滞
- 描述清晰度
- 需要澄清
- 新手友好度
- 35/100