Add "follow reference" to go to typedef#519
Open
Mortal wants to merge 3 commits intoxavierd:masterfrom
Open
Conversation
…angFollowReference[Preview]
|
That's the function I'm always dreaming of. In fact I has already modified my local libclang.py to do extra type checks and follow canonical type to get its declaration. Can't wait to see this get merged. |
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 join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Currently, clang_complete does not support following definitions very well in code like this:
I want to go from
fooinmain()to thetypedef factory<Foo, int> foo;line. However,C-](org:ClangGotoDeclaration) goes straight through the typedef to the definition offactory::factory, which is useless. After some print-debugging, it seems that in functiongotoDeclaration, neithercursor.get_definition()norcursor.referencedreturns a cursor to the typedef; both return cursors to the constructor. From my limited experimentation it seems to only occur when the typedef is for a templated type.(Of course, this is a trivial example. For a challenge, I dare you to try finding the definition of
bufferused in this function. clang_complete currently can only take you to something calledpipe_middlewhich is not what you want.grepis useless since the wordbufferis used all over the codebase.)Fortunately,
cursor.type.get_declaration()goes to the typedef. This patch adds support for going to that cursor and thus fixes the problem.I've added
map \g :call g:ClangGotoDeclaration()<CR>to myvimrc(mimicking jedi-vim's function for that binding, and now I can go to the typedef using that binding.