redhat-developer / redhat-developer/vscode-java
Inconsistant results when performing a textDocument/references request with multiple anonymous classes
Nadie ha tomado este issue todavía.
- Lenguaje dominante
- TypeScript
- Estrellas
- 2.3k
- Forks
- 546
- Merge medio
- 20 h 1 min
- PR fusionados (30 d)
- 11
Descripción
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 ;)
Guía de contribución
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Línea de trabajo
Comienza reproduciendo la solicitud textDocument/references con varias implementaciones anónimas y con nombre de ActionListener, y compara los resultados cuando se usa includeDeclaration. Investiga cómo la extensión de Java gestiona las declaraciones de métodos de las clases anónimas y determina si las referencias deberían coincidir con el comportamiento de las clases con nombre o exponer una forma de deshabilitar includeDeclaration.
Escrito por el modelo de indexación a partir del texto del issue.
Evaluación
- Stack tecnológico
- java
- Área
- devtools
- Tipo de issue
- Error
- Dificultad
- 4/5
- Tiempo estimado
- 3-5 días
- Estado de actividad
- Estancado
- Claridad
- Necesita aclaración
- Aptitud para principiantes
- 35/100