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

Find all references does not work on function definition #1047

Closed
KyleMoser opened this issue Feb 20, 2018 · 6 comments
Closed

Find all references does not work on function definition #1047

KyleMoser opened this issue Feb 20, 2018 · 6 comments
Labels

Comments

@KyleMoser
Copy link

I was pointed here by the guys who maintain the Microsoft Visual Studio Code Python extension. The issue is that if I click on my function definition and click "Find All References", only the current function is shown; but if I right click the function name somewhere else (e.g. in a different file where it is being called), it successfully finds every reference in the project.

A full description with a project demonstrating the issue is found in the link below.

microsoft/vscode-python#810

@davidhalter
Copy link
Owner

Usages has been broken since forever. Sorry for that. I'll try to fix it once the next version is out. But for a good fix we need a good index. Otherwise this is just too slow. So there's a lot of work ahead of me. At least a year, probably.

@habibutsu
Copy link

Today 5 february, let's start countdown?

@davidhalter
Copy link
Owner

#1059 is the relevant ticket. I'm currently not working a lot on Jedi - I doubt this will happen soon - if ever. This is an enormous amount of work - probably half a year fulltime - that I don't have. I'm not paid.

@moribellamy
Copy link

That ticket says "the lazy approach is not good enough." Can we expand on "not good enough."? Is there a stopgap that could be off by default but people with small projects could turn it on?

Alternatively: could you educate me on any alternatives for "find usages" in python? I'm only aware of https://github.com/microsoft/python-language-server

@davidhalter
Copy link
Owner

The python-language-server is probably your best option, if you don't want to use PyCharm. There's pretty much nothing else.

For very very small projects we could probably do it, but as soon as you start to analyze more than 100 files it gets very very slow, I feel like. What is a small project for you?

@davidhalter
Copy link
Owner

davidhalter commented Jan 21, 2020

@moribellamy Thanks for the hint. I realized that it's probably possible to at least service smaller projects. At the moment the limit is opening 2000 files and parsing 30 files. This should make it so finding references doesn't take longer than a few seconds and mostly works in <1s.

The relevant changes are mostly in ed36efa, the full diff is 4cd2b9a..9d7858e.

Now since this obviously doesn't fix all cases (I'm looking at people searching usages for str), but it works good enough if you take a name that doesn't appear all over the codebase. For improvements, #1059 is still the solution.

Also searching usages for str still returns more than 500 results :).

Oh and please test! It's all on master and should be working fine. I'm happy to receive bug reports.

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

No branches or pull requests

4 participants