sponsor Vim development Vim logo Vim Book Ad

jcallers.vim : grep calls to function under the cursor

 script karma  Rating 3/3, Downloaded by 628  Comments, bugs, improvements  Vim wiki

created by
ivan wellesz
 
script type
utility
 
description
Grep every calls to the function under the cursor with your grepprg.
...closely organized like jreplace script is .. @see Vim wiki

1 - Starts with a :normal mA  .. AS A GLOBAL MARK [A] .. you can jump back to as a return point.

2 - The resulting list will be inserted as a multi-line comment in the current buffer .. you can undo at will:
        /* CALLERS::
        src/file.js:485      caller_f:493:     callee_f(args);
        src/file.java:485  caller_f:493:     callee_f(args);
        */
3 - Let you navigate the grep quickfix resulting list.

Notes:
- Currently tuned up to catch .js and .java calling function def lines into the list third field.
- And you will figure out how to get more by adjusting the F_callers:fdef pattern.

- USES [A global mark] as a call return point
...(there are 2 calls to [A mark] you can adjust to use another mark :normal mA and :normal 'A

- USES [b register] to store the resulting multi-line-comment
...(so as you can undo the insertion .. but keep the results handy)
...(there are 3 setreg(b) calls you can adjust to use another register

- USES [q register] to store the generated :grep call
...(so you can use @q to edit and call it yourself later)
...( :nnoremap Q   @q .. may help )
 
install details
- put the file where you put your other scripts (it has no dependency)
- then map something to source it.
...mine is:
:nnoremap <esc><c-s-down>   :so ~/VIM/scripts/jcallers.vim<cr><cr>

 

rate this script Life Changing Helpful Unfulfilling 
script versions (upload new version)

Click on the package to download.

package script version date Vim version user release notes
jcallers.vim 210626 2021-06-26 7.0 ivan wellesz added \\\",}\\\" to callee pattern to catch literal object embedding
jcallers.vim 210430 2021-04-30 7.0 ivan wellesz 1. Added egrep flavor dependent code comments:
...so you can select regex that works for you.
2. Inserted callee search pattern within results:
...so you have an idea about why those results.
jcallers.vim 210320 2021-03-20 7.0 ivan wellesz ...added [declared caller function] look-behind pattern (i.e. no var,let or const)
jcallers.vim 200830 2020-08-30 7.0 ivan wellesz Previous version sends untouched vim [*] search pattern to egrep... BUT:
...regex escaping may be required .. depending on egrep flavors.
Please report about what you had to do at lines 65-66 to make it work for you...
jcallers.vim 200805 2020-08-05 7.0 ivan wellesz previous version issue corrected .. first quickfix list entry was missed
jcallers.vim 200731 2020-07-31 7.0 ivan wellesz Added protected access modifier to catch java caller's def-line
jcallers.vim 200729 2020-07-30 7.0 ivan wellesz - Some comments added near script lines that could be worth tuning
...(so you can adjust to your liking)

- Commented-out [word boundaries removal] from the searched function pattern
..(so as to look for the EXACT word-under-the-cursor)
jcallers.vim 200728 2020-07-29 7.0 ivan wellesz Initial upload
ip used for rating: 3.19.30.232

If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to the maillist. Help Bram help Uganda.
   
Vim at Github