Sublime Forum

Go to definition on extern functions

#1

I have loaded my project in ST3. My classes are organised like this: <class_name>.svh and <class_name>.sv The .svh file (Systemverilog) has the declarations of class members and functions, and the functions are declared as extern. The .sv has implementation of the functions.

When you use the go to definition on an extern function in the .svh file, ST3 displays you all the functions that have the same name (from all the .sv files) which are a lot and it’s difficult to find the definition/function implementation that you are interested in.

E.g. many classes have a function called run(). In the .svh file, If you use the go to definition on the extern function run() ST3 displays all the functions named run() from all files and lists them alphabetically, so it doesn’t by default take you to the implementation of run() that you are interested in.

Is it possible when you use the go to definition, ST3 to display you first the declaration of the function which is in the .sv with the same file name? Now the list of the function declarations that show up is alphabetically sorted.

If yes, how could this be done?

Thank you,
Apostolis

0 Likes

#2

Hello again :wink:

The way to do it simply to take the goto definition from the default package (in symbol.py) and modify it to fit your need.

I did a quick test, available here : just save the file in your package user directory and bind a key to the command “my_goto_definition”.

Essentially I just added 98 to 104: I did not change the alphabetical order, but rather I selected by default a file with same name as the current view (if there is one). Anyway it should give a good base to adapt it if you prefer other behaviors.

0 Likes

#3

some other improvements to goto definition were suggested at

0 Likes

#4

Thanks for the immediate answer! This solution solved my problem.
I also read the rest of the suggested threads. I guess it depends on the usecase.

In my case the definition that I’m interested for the functions is always in the same named file.
So the solution of showing by default a file with same name in current view solves my issue.

Thanks again!

0 Likes