Jedi: Find all references does not work on function definition

Created on 20 Feb 2018  路  6Comments  路  Source: davidhalter/jedi

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.

https://github.com/Microsoft/vscode-python/issues/810

feature

Most helpful comment

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.

All 6 comments

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.

Today 5 february, let's start countdown?

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.

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

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?

@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 ed36efabeba5f66f070943307e68adfc0d509665, 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.

Was this page helpful?
0 / 5 - 0 ratings