Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

"Go To Definition" shows overloading methods rather than going to the actual method #3095

Closed
stefanrybacki opened this issue May 3, 2023 · 5 comments

Comments

@stefanrybacki
Copy link

stefanrybacki commented May 3, 2023

When having multiple overloaded versions of a method, the "Go To Definition" (Ctrl+Click, etc.) will not got the actual method but show all overloaded versions.

Environment
  • Operating System: UI Windows, Remote SSH into Linux
  • JDK version: 17
  • Visual Studio Code version: 1.77.3
  • Java extension version: 1.18.0
Steps To Reproduce
  1. Create Class like this:
class GoToDefinitionTest {
  public String method1(String param) {
    return method1(param, null);    // Ctrl+Click on method1 here
  }

  public String method1(String param, String otherParam) {
    return method1(param, otherParam, null);
  }

  public String method1(String param, String otherParam, String yetAnotherParam) {
    return "Hello";
  }
}
  1. In the first method1 method Ctrl+Click on the other method1 call.

[Please attach a sample project reproducing the error]
Please attach logs

Current Result

image

Expected Result

Expected is a jump the the second method1 implementation because it is the only correct definition.

Additional Informations

If use "Search for references" for the same method1 call it correctly shows this:
image

Also the reference hints at the methods itself are correct (see the screenshot the first method1 has 0 references, while the other two have each 1 reference).

@jdneo
Copy link
Collaborator

jdneo commented May 5, 2023

Cannot reproduce it on my side:

gtd.mp4

The only difference is that I'm not using Remote extension. I directly tested it locally. - I don't think this has impact on the behavior.

@jdneo jdneo added the need info label May 5, 2023
@stefanrybacki
Copy link
Author

@jdneo I feared that you might not be able to reproduce. It also might be a setting though. I will try to see if it makes a difference on non remote. Thanks for taking the time.

@jdneo
Copy link
Collaborator

jdneo commented May 5, 2023

Don't forget to check the enabled extensions. Maybe the definition location is contributed by some other extensions.

@stefanrybacki
Copy link
Author

@jdneo thanks for the hint regarding other extensions, FYI it seems to be the Metals Scala extension which somehow "overrides" the go to definition command in the java project to a slightly enhanced full text search.

@jdneo
Copy link
Collaborator

jdneo commented May 10, 2023

Thanks for the update. If the workspace only contains pure-Java projects, you can consider disable Metals Scala in that workspace.
image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants