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

Can't get method declaration searches with parameters to work #3211

Closed
jmle opened this issue Jul 5, 2024 · 5 comments
Closed

Can't get method declaration searches with parameters to work #3211

jmle opened this issue Jul 5, 2024 · 5 comments

Comments

@jmle
Copy link

jmle commented Jul 5, 2024

Given, for instance, the following code:

package org.home;
public class HelloClass
  public String getText(String name) {
    return "Hello " + "name" + "!";
  }
}

I can get the LS to return a match for these method declarations:

  • getText()
  • getText(*)
  • org.home.HelloClass.getText()

but not for getText(String) or getText(java.lang.String).

I am setting the search for IJavaSearchConstants.METHOD, IJavaSearchConstants.DECLARATIONS, and setting the pattern as SearchPattern.R_EXACT_MATCH | SearchPattern.R_PATTERN_MATCH.

According to the docs it is possible to do this. What am I missing?

@snjeza
Copy link
Contributor

snjeza commented Jul 6, 2024

@jmle You may want to take a look at ReferencesHandler.search(...)

@jmle
Copy link
Author

jmle commented Jul 6, 2024

@snjeza thank you, but I don't see how that piece of code is related to my question. Could you briefly explain it to me?

@snjeza
Copy link
Contributor

snjeza commented Jul 6, 2024

thank you, but I don't see how that piece of code is related to my question. Could you briefly explain it to me?

ReferencesHandler.search(...) implements a search in Java LS.

I am setting the search for IJavaSearchConstants.METHOD, IJavaSearchConstants.DECLARATIONS, and setting the pattern as SearchPattern.R_EXACT_MATCH | SearchPattern.R_PATTERN_MATCH.

Could you show your code?

@jmle
Copy link
Author

jmle commented Jul 8, 2024

@snjeza Yep, I know how to search, but this particular search is not working for me.

This is the method where we create the SearchPatterns. The idea is to create another entry in that switch block to handle method declaration searches:

// [...]
        case 13:
            return SearchPattern.createPattern(query, IJavaSearchConstants.METHOD, IJavaSearchConstants.DECLARATIONS, SearchPattern.R_EXACT_MATCH | SearchPattern.R_PATTERN_MATCH);
// [...]

I was expecting this search to return results when looking for methods with particular signatures.

@jmle jmle closed this as completed Jul 8, 2024
@jmle
Copy link
Author

jmle commented Jul 8, 2024

@snjeza I'm closing this as I have found a piece of code where this error might be coming from. Thanks for your help.

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

No branches or pull requests

2 participants