curious1
curious1

Reputation: 14727

Eclipse: how to find the references of an inherited field (NOT the

I am doing a Java project. I have a super class and it is inherited by many classes. For example:

SuperClass {
  private String field;
  public String getField() {
    return field;
  }

  public void setField(String field) {
    this.field = field;
  }
}

ChildClass1 extends SuperClass {
....
}

ChildClass2 extends SuperClass {
....
}

I simply need to find the references of getField method for ChildClasss1 (NOT all references including those for ChildClass2). How can I do that in Eclipse?

I tried in Eclipse and it reports all the references. Here is how I did: right-click on the use of the getField by a ChildClass1 object, and then select references and project.

Thanks for any help!

Upvotes: 2

Views: 181

Answers (1)

Leo
Leo

Reputation: 6580

I believe you have two situations here.

  1. new ChildClass1().parentClassMethod()
  2. SuperClass sc = new ChildClass1(); sc.parentClassMethod();

In the first situation, you can make eclipse find all the method calls if you explicitly override parentClassMethod() in ChildClass1 and search from there.

In the second situation, there's no way to know that sc is a ChildClass1 instance in sc.parentClassMethod().

Upvotes: 1

Related Questions