Register
4coder»Forums»Current best practice to navigate to functions definitions?
Jason
181 posts
Current best practice to navigate to functions definitions?
11 months ago Edited by Jason on Jan. 4, 2020, 12:59 a.m.
I just implemented a simple way to read a type name found under my cursor and display it's definition in the next panel. I was wondering if anyone has implemented a way to mimic this behavior but with function definitions? That is, navigate your cursor to a function name, hit say 'F10' and have 4coder pull up the function definition in other panel window? If not, what's the current quickest way to display or jump to a function definition? I've tried to use 'jump_to_definition' but that doesn't seem to work very well (doesn't list all functions in a buffer, only some)
Alexey
9 posts
Current best practice to navigate to functions definitions?
11 months ago
Function, type, and macro definitions are all listed in the code index, which is asynchronously build on any code changes. See 4coder_code_index.h/cpp for implementation. All definitions are stored per-file both as a signly-linked-list and an array.

boagz57
I've tried to use 'jump_to_definition' but that doesn't seem to work very well (doesn't list all functions in a buffer, only some)


There are a few small bugs in the function parser, see: issue 118 on github.

To navigate straight to function definition you probably need to build a lister with jumps targets (thats what I did at least), because there can be a (?) maximum of two (/?) hits if in C (function declaration + function definition) and virtually unlimited hits in C++ because of overloads. This can be built by hacking the implemetation of jump_to_definition.
Jason
181 posts
Current best practice to navigate to functions definitions?
11 months ago
aolo2
There are a few small bugs in the function parser, see: issue 118 on github.


Ah, awesome, that fixed that issue. Thanks for the info and suggestions. I will use them to try and get things working.