Instantiation hierarchy [message #500477] |
Thu, 26 November 2009 05:05  |
Eclipse User |
|
|
|
Is there a way in Eclipse - or a plugin - that provides the following feature:
for instance
class A {
B b;
}
class B {
C c;
}
class C { ... }
Right-click on "C" / the-wanted-feature would show
A -> B -> C,
showing the instantiation path up to C, based on the source code in the workspace.
Thanks as usual.
[Updated on: Thu, 26 November 2009 10:34] by Moderator
|
|
|
|
|
|
|
|
Re: Instantiation hierarchy [message #500757 is a reply to message #500600] |
Sat, 28 November 2009 03:31   |
Eclipse User |
|
|
|
"J.Barnen" <333@kochira.com> wrote in message
news:hen6ca$s3t$1@build.eclipse.org...
> Nope. I'm not looking for the "call hierarchy".
> Please read again my 2 posts.
> Is my English that bad :)
In your example there is no instantiation, only type reference. So it is
not surprising that people are having trouble answering.
If I assume you do mean instantiation, then the following example might be
what you meant:
class A {
B b = new B();
}
class B {
C c = new C();
}
class C { ... }
Now, I can sort of imagine writing something that, when clicking on the
declaration of type C, located all the places where C was instantiated; and
then located in turn all the places where the type doing that instantiation
was itself instantiated. This would amount to doing a call hierarchy on all
the constructors of C, collapsing the results for all the constructors
together, and then just listing the classes where the calls took place; then
doing the same, recursively.
Probably a pretty simple plug-in to write, if you wanted to pursue that.
AFAIK the functionality does not exist right now.
|
|
|
|
|
Re: Instantiation hierarchy [message #501634 is a reply to message #501012] |
Thu, 03 December 2009 03:09  |
Eclipse User |
|
|
|
"Eric Rizzo" <eclipse-bugs@rizzoweb.com> wrote in message
news:hf0s9j$k8l$4@build.eclipse.org...
> On 11/26/09 7:26 PM, J.Barnen wrote:
>> Nope. I'm not looking for the "call hierarchy".
>> Please read again my 2 posts.
>> Is my English that bad :)
>
> Try describing how a call hierarchy of constructors different than what
> you're looking for.
Eric, consider the following case:
class A {
A(int x) { ... }
A(String s) { ... }
}
class B {
A _a1;
A _a2;
B(int y) {
_a1 = new A(y);
...
}
B(String t) {
_a1 = new A(t);
_a2 = new A(t.size());
...
}
void quux(B b) {
B b2 = new B(b._a1.toString() + b._a2.toString());
...
}
}
class C {
static void zubzub(String args[]) {
B b1 = new B(3);
B b2 = new B("Foo");
}
}
class D {
void foo() {
C.zubzub("hello world");
}
}
Now, I think what the OP wants is just something like:
C -> B -> A
That is, I think he just wants to know what types instantiate what other
types. The information is all there in the call hierarchy of A's
constructors, but it's ugly: he has to get the call hierarchies of each of
the separate constructors of A, and so forth, identify the calls that don't
involve construction (like D.foo; D does not create a C, so the graph is not
D->C->B->A) and manually coalesce the information.
|
|
|
Powered by
FUDForum. Page generated in 0.11684 seconds