Reputation: 27886
For context, say I have these classes:
public class Foo {
public void doStuff() {}
}
public class Bar extends Foo {
@Override
public void doStuff() {}
}
public class Zig extends Foo {
@Override
public void doStuff() {}
}
I'm trying to find only calls to Bar#doStuff()
.
I've tried:
Bar.doStuff
Bar#doStuff()
but they appear to return calls to both Bar.doStuff()
and Foo.doStuff()
and Zig.doStuff()
. Is there something else I need to do, or am I misunderstanding the results I'm getting?
Upvotes: 1
Views: 163
Reputation: 27886
To find the calls which are definitely from Bar
, you can mark Bar#doStuff
as @Deprecated
, and then create a new "Problems" view with a filter to find just these messages.
to create the new Problems view:
New Problems View
Configure Contents
Errors/Warnings in Project
contains
filter (under Description
heading) as appropriateNote: this will not find cases where Bar
s are stored as Foo
s, e.g.:
Foo f = new Bar();
f.doStuff();
Upvotes: 2
Reputation: 12766
Well, due to polymorphism, there's not a good way for the IDE to know that a given Foo isn't potentially a Bar -- so it will show you all calls to doStuff
. I suppose it could do more analysis to determine that the concrete type of a Foo
really is a Foo
-- for example, in the case:
final Foo foo = new Foo();
it is definitely not a Bar
-- but that's a lot of work for little benefit.
You will notice the same holds true for interfaces and their implementations, at least in Eclipse.
Upvotes: 1