2012-07-24 74 views
10

引用我想找到的方法“获得”,为下面的类的所有来电:Eclipse中找到方法

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; 
    } 
} 

所以我白标明的文字“获取”,然后右键单击的参考 - 项目。但是它返回了对每个称为“get”的方法的引用,而不是对com.zzz.zzz.zzz.services.EMF.get()的引用。

这是一个eclipse的bug吗?如何让Eclipse仅显示对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 

输出参考搜索:

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 

回答

10

在项目中查找引用依赖于方法的名称,这就是为什么它是不准确的。尝试使用Call Hierarchy。

+0

在霓虹灯的调用层级似乎兄弟也适用于静态方法。我有被称为数百次的静态方法,它们具有完全空的调用层次结构。 – 2016-11-30 11:52:08

11

突出显示时,请按Ctrl + Shift + G。它会在搜索标签/窗口中列出结果列表。它会在您的工作区中找到所有参考。它通过适当的引用来完成,而不是纯文本搜索。

+0

你正在描述**完全** OP说他试过了什么,并没有为他工作。另一方面,Call Hierarchy给了OP他正在寻找的东西。 – 2012-07-25 08:57:07

+0

他使用了项目内的参考文献,这些参考文献略有不同,显然没有按预期工作。我没有亲自使用Project内的References,因为Eclipse没有默认的键盘映射。工作区内的参考文件是IMO的更好选择。我知道一个事实,即Workspace中的References完全按照OP的要求工作。我每天都使用它。 – Roadkillnz 2012-07-25 23:21:58

8

在Eclipse开普勒您可以使用参考当配置搜索过滤掉所有潜在匹配( - 工作区/项目层次要激活的过滤器,点击向下箭头小在搜索视图的右上角并激活潜在匹配复选框。 enter image description here

+2

这意味着“排除潜在匹配”。完善!谢谢。 – Hartmut 2015-07-30 21:09:58