Java Eclipse查找方法的引用

Java Eclipse查找方法的引用,java,eclipse,eclipse-jdt,Java,Eclipse,Eclipse Jdt,我想为以下类找到方法“get”的所有调用方: package com.zzz.zzz.zzz.services; public final class EMF { private static final EntityManagerFactory emfInstance = Persistence.createEntityManagerFactory("obamaCareIsGood4U"); private EMF() {} public static EntityM

我想为以下类找到方法“get”的所有调用方:

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”提升到高位,并右键单击References-project。但它返回对每个名为“get”的方法的引用,而不仅仅是对com.zzz.zzz.zzz.services.EMF.get()的引用

这是一个eclipse bug吗?如何让Eclipse只显示对com.zzz.zzz.zzz.services.EMF.get()的引用

参考搜索的输出:

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

在Project中查找引用依赖于方法名,这就是它不准确的原因。尝试使用调用层次结构。

在突出显示时,按Ctrl+Shift+G。它将在搜索选项卡/窗口中显示结果列表。它将在您的工作区中查找所有引用。它是通过正确的引用而不是纯文本搜索来实现的。

在Eclipse Kepler中,您可以配置搜索以过滤掉所有潜在匹配(当使用引用-工作区/项目或层次结构时)。要激活过滤器,请单击搜索视图右上角的小向下箭头并激活潜在匹配复选框。

有时,如果您有多个同名的方法,例如,一个类的构造函数,所有方法都具有相同的名称但签名不同,那么查找其中一个构造函数的所有调用方可能会很困难。您可以使用的一个技巧是注释掉正在调查的方法,然后构建。然后编译器会告诉您所有位置s无法找到该签名,因此这些正是所有试图使用该名称和该特定签名调用该方法的地方。

您正在准确描述OP所说的他尝试了什么,但没有为他工作。另一方面,调用层次结构为OP提供了他要找的内容。他使用了Project whic中的引用h是一个微妙的不同点,显然并没有达到预期的效果。我个人不在项目中使用引用,因为Eclipse没有现成的默认键盘映射。在我看来,工作区中的引用是一个更好的选择。我知道,工作区中的引用完全按照OP的要求工作。我每天都使用它nslates为“排除潜在匹配项”。太好了!谢谢。这个老答案不知怎么地帮助解决了一个令人惊讶的事实,即在我的源文件中搜索私有成员的引用会返回所有工作区JAR中的所有相似性,包括javadoc匹配项。即使“潜在”结果被隐藏,“查找引用”在整个工作区中进行筛选,很慢。“get()”方法?“message”字段?不客气。Eclipse知道私有的含义吗?2020年-还没有。在Neon中,调用层次结构似乎也被静态方法打破了。我有数百次调用的静态方法,它们的调用层次结构完全为空。
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