redhat-developer / redhat-developer/vscode-java

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

オープン
#2,781 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

まだ誰も着手していません。

navigation
主要言語
TypeScript
スター
2.3k
フォーク
546
平均マージ
20時間 1分
マージ済み PR(30日)
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.

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 ;)

コントリビューションガイド

コントリビューションガイドを開く

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

調査の方向性

まず、複数の匿名および名前付きの ActionListener 実装で textDocument/references リクエストを再現し、includeDeclaration を使用した場合の結果を比較します。Java 拡張機能が匿名クラスのメソッド宣言をどのように処理するかを調査し、references が名前付きクラスの動作と一致すべきか、または includeDeclaration を無効にする方法を提供すべきかを判断します。

索引モデルが issue の本文から書いたものです。

評価

技術スタック
java
領域
devtools
issue の種類
バグ
難易度
4/5
見積もり時間
3〜5日
活発さ
停滞
明瞭さ
説明が足りない
初心者へのやさしさ
35/100

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。