-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
Ensure navigation to definitons follows imports and is transparent to decoration #1712
Conversation
This provides a starting point for more interesting tests.
Specifically this covers some basic cases as well as the reproductions of microsoft#1638 and microsoft#1033 plus the variant of microsoft#1033 which always worked.
This fixes microsoft#1638 and simplifies the code (to what I believe that @davidhalter had in mind in microsoft#1033 (comment)). This change means that all of the test cases recently added to 'navigation.tests.ts' now pass, meaning that navigtion to the definition of functions works through imports and goes to the original function, even when that function is decorated.
Codecov Report
@@ Coverage Diff @@
## master #1712 +/- ##
=======================================
Coverage 71.49% 71.49%
=======================================
Files 277 277
Lines 13014 13014
Branches 2344 2344
=======================================
Hits 9305 9305
Misses 3574 3574
Partials 135 135 Continue to review full report at Codecov.
|
defs = self._get_definitionsx(script.goto_assignments(), request['id']) | ||
except: | ||
pass | ||
defs = self._get_definitionsx(script.goto_assignments(follow_imports=True), request['id']) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I generally like this. This is way nicer than the code that remains here.
I also want to mention that I think you should read (and subscribe to) davidhalter/jedi-vim#808, because this is a very similar issue. There is going to be an additional option probably that might be helpful.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@davidhalter I opened #1735 to track this.
Fixes #1638
It turns out that there are three mechanisms for getting definitions of a symbol from
jedi
:goto_definitions
: follows all imports and considers the actual value of the target symbol (so returns the wrapped version of a decorated function)goto_assignments
: considers the original assignments of a symbol, meaning that it ignores decoration, but doesn't follow import by defaultgoto_assignments(follow_imports=True)
: behaves likegoto_assignments
, but doesn't consider an import to be an assignment and so follows to the original assignmentIt's the latter behaviour that is what I'd find most useful from an IDE.
This pull request: