Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Eclipse find references for method

I wanted to find all the callers of the the method "get" for the following class:

package com.zzz.zzz.zzz.services;

public final class EMF {
  private static final EntityManagerFactory emfInstance =
    Persistence.createEntityManagerFactory("obamaCareIsGood4U");

  private EMF() {}

  public static EntityManagerFactory get() {
    return emfInstance;
  }
}

So I highlited the text "get" and right-clicked References - project. But it returned references to every method called "get", rather than just references to com.zzz.zzz.zzz.services.EMF.get().

Is this an eclipse bug? How do I get Eclipse to show references only to com.zzz.zzz.zzz.services.EMF.get()?

Eclipse Platform  Version:
4.2.0.v20120608-135145-9JF7BHV8FyMteji0Oi_ePMz0xuZ8TVo7lV0z0ecb
Build id:
I20120608-1400,

Spring Tool Suite Version: 3.0.0.M3 Build Id: 201207050802 

Output of reference search:

com.google.common.base - guava-12.0.jar - C:\Users\SofiaVergara\.m2\repository\com\google\guava\guava\12.0 - PatientCare
com.google.common.base - guava-gwt-12.0.jar - C:\Users\SofiaVergara\.m2\repository\com\google\guava\guava-gwt\12.0 - PatientCare
com.google.gwt.junit.server - gwt-user-2.4.0.jar - C:\Users\SofiaVergara\.m2\repository\com\google\gwt\gwt-user\2.4.0 - PatientCare
com.google.gwt.requestfactory.server - gwt-servlet-2.2.0.jar - C:\Users\SofiaVergara\.m2\repository\com\google\gwt\gwt-servlet\2.2.0 - PatientCare
com.google.gwt.resources.rg - gwt-user-2.4.0.jar - C:\Users\SofiaVergara\.m2\repository\com\google\gwt\gwt-user\2.4.0 - PatientCare
com.google.gwt.user.cellview.client - gwt-servlet-2.2.0.jar - C:\Users\SofiaVergara\.m2\repository\com\google\gwt\gwt-servlet\2.2.0 - PatientCare
com.google.gwt.validation.rebind - gwt-user-2.4.0.jar - C:\Users\SofiaVergara\.m2\repository\com\google\gwt\gwt-user\2.4.0 - PatientCare
com.google.web.bindery.requestfactory.apt - gwt-user-2.4.0.jar - C:\Users\SofiaVergara\.m2\repository\com\google\gwt\gwt-user\2.4.0 - PatientCare
com.google.web.bindery.requestfactory.gwt.rebind.model - gwt-user-2.4.0.jar - C:\Users\SofiaVergara\.m2\repository\com\google\gwt\gwt-user\2.4.0 - PatientCare
com.google.web.bindery.requestfactory.vm - gwt-user-2.4.0.jar - C:\Users\SofiaVergara\.m2\repository\com\google\gwt\gwt-user\2.4.0 - PatientCare
com.zzz.zzz.zzz.PatientCare.services.impl - src/main/java/server - PatientCare
com.sun.istack - jaxb-impl-2.2.4.jar - C:\Users\SofiaVergara\.m2\repository\com\sun\xml\bind\jaxb-impl\2.2.4 - PatientCare
com.sun.xml.bind.v2 - jaxb-impl-2.2.4.jar - C:\Users\SofiaVergara\.m2\repository\com\sun\xml\bind\jaxb-impl\2.2.4 - PatientCare
com.sun.xml.bind.v2.runtime - jaxb-impl-2.2.4.jar - C:\Users\SofiaVergara\.m2\repository\com\sun\xml\bind\jaxb-impl\2.2.4 - PatientCare
com.sun.xml.bind.v2.runtime.output - jaxb-impl-2.2.4.jar - C:\Users\SofiaVergara\.m2\repository\com\sun\xml\bind\jaxb-impl\2.2.4 - PatientCare
com.sun.xml.bind.v2.runtime.property - jaxb-impl-2.2.4.jar - C:\Users\SofiaVergara\.m2\repository\com\sun\xml\bind\jaxb-impl\2.2.4 - PatientCare
com.sun.xml.bind.v2.runtime.reflect - jaxb-impl-2.2.4.jar - C:\Users\SofiaVergara\.m2\repository\com\sun\xml\bind\jaxb-impl\2.2.4 - PatientCare
com.sun.xml.bind.v2.runtime.reflect.opt - jaxb-impl-2.2.4.jar - C:\Users\SofiaVergara\.m2\repository\com\sun\xml\bind\jaxb-impl\2.2.4 - PatientCare
com.sun.xml.bind.v2.runtime.unmarshaller - jaxb-impl-2.2.4.jar - C:\Users\SofiaVergara\.m2\repository\com\sun\xml\bind\jaxb-impl\2.2.4 - PatientCare
javax.persistence.spi - hibernate-jpa-2.0-api-1.0.1.Final.jar - C:\Users\SofiaVergara\.m2\repository\org\hibernate\javax\persistence\hibernate-jpa-2.0-api\1.0.1.Final - PatientCare
javax.xml.bind - jaxb-api-2.2.3.jar - C:\Users\SofiaVergara\.m2\repository\javax\xml\bind\jaxb-api\2.2.3 - PatientCare
org.codehaus.jackson - jackson-core-asl-1.8.5.jar - C:\Users\SofiaVergara\.m2\repository\org\codehaus\jackson\jackson-core-asl\1.8.5 - PatientCare
org.codehaus.jackson.impl - jackson-core-asl-1.8.5.jar - C:\Users\SofiaVergara\.m2\repository\org\codehaus\jackson\jackson-core-asl\1.8.5 - PatientCare
org.codehaus.jackson.io - jackson-core-asl-1.8.5.jar - C:\Users\SofiaVergara\.m2\repository\org\codehaus\jackson\jackson-core-asl\1.8.5 - PatientCare
org.codehaus.jackson.map.ext - jackson-mapper-asl-1.8.5.jar - C:\Users\SofiaVergara\.m2\repository\org\codehaus\jackson\jackson-mapper-asl\1.8.5 - PatientCare
org.codehaus.jackson.map.ser - jackson-mapper-asl-1.8.5.jar - C:\Users\SofiaVergara\.m2\repository\org\codehaus\jackson\jackson-mapper-asl\1.8.5 - PatientCare
org.fusesource.restygwt.client.dispatcher - restygwt-1.3-SNAPSHOT.jar - C:\Users\SofiaVergara\.m2\repository\org\fusesource\restygwt\restygwt\1.3-SNAPSHOT - PatientCare
org.hibernate.context - hibernate-core-3.6.10.Final.jar - C:\Users\SofiaVergara\.m2\repository\org\hibernate\hibernate-core\3.6.10.Final - PatientCare
org.hibernate.stat - hibernate-core-3.6.10.Final.jar - C:\Users\SofiaVergara\.m2\repository\org\hibernate\hibernate-core\3.6.10.Final - PatientCare
org.hibernate.util - hibernate-core-3.6.10.Final.jar - C:\Users\SofiaVergara\.m2\repository\org\hibernate\hibernate-core\3.6.10.Final - PatientCare
org.hibernate.validator.internal.util - hibernate-validator-4.3.0.Final.jar - C:\Users\SofiaVergara\.m2\repository\org\hibernate\hibernate-validator\4.3.0.Final - PatientCare
org.hibernate.validator.internal.util.scriptengine - hibernate-validator-4.3.0.Final.jar - C:\Users\SofiaVergara\.m2\repository\org\hibernate\hibernate-validator\4.3.0.Final - PatientCare
org.jboss.resteasy.client - resteasy-jaxrs-2.3.4.Final.jar - C:\Users\SofiaVergara\.m2\repository\org\jboss\resteasy\resteasy-jaxrs\2.3.4.Final - PatientCare
org.jboss.resteasy.client.cache - resteasy-jaxrs-2.3.4.Final.jar - C:\Users\SofiaVergara\.m2\repository\org\jboss\resteasy\resteasy-jaxrs\2.3.4.Final - PatientCare
org.jboss.resteasy.core - resteasy-jaxrs-2.3.4.Final.jar - C:\Users\SofiaVergara\.m2\repository\org\jboss\resteasy\resteasy-jaxrs\2.3.4.Final - PatientCare
org.jboss.resteasy.spi - resteasy-jaxrs-2.3.4.Final.jar - C:\Users\SofiaVergara\.m2\repository\org\jboss\resteasy\resteasy-jaxrs\2.3.4.Final - PatientCare
org.jboss.resteasy.util - resteasy-jaxrs-2.3.4.Final.jar - C:\Users\SofiaVergara\.m2\repository\org\jboss\resteasy\resteasy-jaxrs\2.3.4.Final - PatientCare
like image 746
Blessed Geek Avatar asked Jul 24 '12 16:07

Blessed Geek


People also ask

How do you check where all the method is called in eclipse?

In Eclipse, one can right click on a method and choose "open call hierarchy" and eclipse shows all the methods that call the selected method and all the methods that are called from the selected method (callers and callees of the selected method).

How do I find methods in eclipse?

You can open any method or type in your workspace using the "Open Type" wizard or the "Open Method" wizard. -Or- press Ctrl+Shift+T (for a type) or Ctrl+Shift+M (for a method). The "Open Type/Method" dialog will appear. If a type/method was previously selected in the editor or outline views, it will be displayed.

How do you check reference variables in Eclipse?

Ctrl + Shift + U shows all usages of a variable, with different icons for read and write references.

How do you navigate to implement a method in eclipse?

If you use the f3 key or ctrl+click over a class/method in eclipse, it opens the corresponding class/method.


2 Answers

With get highlighted, hit Ctrl+Shift+G. It'll come up with a list of results in the search tab/window. It'll find all references within your workspace. It does it via proper references, and not a plain text search.

like image 68
Roadkillnz Avatar answered Sep 29 '22 17:09

Roadkillnz


Find references in Project relies on method name, that's why it's not accurate. Try using Call Hierarchy.

like image 28
Marko Topolnik Avatar answered Sep 29 '22 18:09

Marko Topolnik