How do I find the calling methods?

Typically for finding method callers in Eclipse, I use ctrl-alt-h for the method. If nothing comes up, it's a callback from another library. I'm pretty sure this method isn't a callback, and I'm pretty sure it is being called from somewhere. How can I tell if nothing is showing with ctrl-alt-h?

+3


source to share


2 answers


You can place the cursor on the method name and press Ctrl-Shift-G

(default keyboard shortcut).

This will open a project search to find references to your method.

Edit



In frameworks using declarative markup (Spring, Android, etc.), you may need to take a more manual approach: finding files.

  • Copy or highlight method name
  • Click Ctrl-H

    (default binding) and select File search

    (you can assign a binding binding for it, but no custom is provided)
  • Fill in containing text

    with your method name if not auto-filled
  • Optionally select "case sensitive" or your file if available
  • Then choose a scope (the project should be a good place to start)
+4


source


Other tactics include:



  • If the method implements the interface, ask Eclipse for the callers of the interface. Sometimes Eclipse will identify more callers through the interface method, especially when callers don't know they are using a particular implementation.
  • Likewise, if a method overrides a base class method, ask Eclipse for the callers of it.
  • Place a breakpoint in the method and look at the call stack in the debugger.
  • If it is possible that a Java method can be called by native code through JNI, use text search for the Java method name in native code.
  • If available, ask the authors of the method.
+1


source







All Articles