sponsor Vim development Vim logo Vim Book Ad

jcallers.vim : grep calls to function under the cursor

 script karma  Rating 4/2, Downloaded by 64  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.

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 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: 18.204.55.168

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.
   
OSDN.net Logo