-
-
Notifications
You must be signed in to change notification settings - Fork 507
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
script.usages not working in some circumstances #744
Comments
Usages is really broken in a lot of places. I would probably need to reimplement large parts of it. It might take some time. |
I don't know if this is related to this specific bug or not, but I have also just posted this on StackOverflow, in hopes that it is just my configuration. In any case, thank you for this excellent package! I am using jedi via YCM in vim and an seeing some weird behavior in my project, regarding using the usages endpoint on the jediHttp server. Basically it only finds a small fraction of the usages in my project of a class or function. It does find all the usages in the current file, but does not find the vast majority in other files. The GoTo command works fine and will open a new buffer anywhere in the project as expected. However when I start at the definition and try to see all the usages via the GoToReferences command it only produces about 20% of the actual usages. I have tried making a dummy project to recreate the behavior and it seems to have worked. Here is the simple project structure:
Here are the contents of those files: classes.py class Foo:
def __init__(self, a):
self.a = a
def make_a(self):
print('hello') mod1/recessed.py: from test_jedi.classes import Foo
Foo(5).make_a()
print('Ran this') script.py: from classes import Foo
a = Foo(5)
a.make_a() Now from within vim with recessed.py in the buffer I am able to use GoTo on Foo to immediately open a classes.py buffer. When I then try GoToReferences from the classes.py buffer I only get the usages in script.py and in classes.py. I am at a loss to why jedi does not show me the usage in recessed.py This is the quickfix buffer that shows:
But clearly there is no reference to mod1/recessed.py which clearly has a usage of Foo. Any ideas? |
@dam5h I can very well understand what your problem is. It's just that usages in Jedi is very backwards and has not been worked on for like 2 years. I hope to be able to fix it some day (or maybe someone else can do that). |
The case of @DonJayamanne has been solved (some line numbers in the example were wrong). More complex cases still won't work (especially with complicated folder structures). The problem is basically that we just cannot do this on request. My plan is to create an index (database) that contains all the references to a name. However there's so much work to do, so you just need to be a little bit patient. :) |
Sounds good, hope I didn't seem impatient ; ). Jedi is great stuff, thanks for the work on it. |
It looks like this is fixed now. The line numbers in the first comment are wrong. However the basic issue seems to be fixed. Generally usages should work very well, as long as it's not across folder structures. It only works in the same file (or maybe in the same directory). To have better support for directory structures, the issue to follow is #1059. |
script.usages doesn't work under certain circumstances.
(Original issue DonJayamanne/pythonVSCode/issues/124)
Here's the sample python code:
Finding references for 'var1' from the first line returns an empy list.
Finding references for 'var1' from the second line works.
Non working code (notice the line number):
Working code (notice the line number):
The text was updated successfully, but these errors were encountered: