简体   繁体   中英

Find instances of overridden method in Eclipse

Say I have the following:

public class TextField {
  private String value = "";
  public String getValue() { return value; }
}

And:

public class TextField2 extends TextField {
  public String getValue() { return value; }
}

Is there any way in Eclipse to search for only instances of the getValue() method called on a TextField2 object? I'm assuming the answer is no, but figured I would ask.

You can do this by selecting the overriden method, pressing the key combination Ctrl + Shift + G . Or by selecting Search --> References --> Workspace from the menu. In the Search view that shows the result, click on the button with the arrow icon at the top right of the view and select References to Overriden .

在此处输入图片说明

But as @Sotirios implied in the comment, this would not detect references by variables declared of type TextField which may be instances of the subtype TextField2 at runtime.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM