Ensure navigation to definitons follows imports and is transparent to decoration#1712
Merged
DonJayamanne merged 5 commits intomicrosoft:masterfrom Jun 5, 2018
Merged
Ensure navigation to definitons follows imports and is transparent to decoration#1712DonJayamanne merged 5 commits intomicrosoft:masterfrom
DonJayamanne merged 5 commits intomicrosoft:masterfrom
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 135Continue to review full report at Codecov.
|
davidhalter
reviewed
May 20, 2018
| 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.
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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: