Getting the java.lang.Object ITypeBinding from an interface method's IMethodBinding [message #1720603] |
Tue, 19 January 2016 11:56  |
Eclipse User |
|
|
|
Hi,
I am currently struggling with a utility method that, given an IMethodBinding returns all ITypeBindings in the hierarchy which declare the method in question.
In particular, I want my method to return both Interface and Object when called with the IMethodBinding for Interface.toString().
interface Interface {
String toString();
}
Alas, I can't find a way to get at the ITypeBinding for java.lang.Object starting from the IMethodBinding for Interface.toString(), as ITypeBinding.getSuperclass() returns null for interfaces.
Is there a way that does not use AST.resolveWellKnownType("java.lang.Object") to accomplish this? I'd rather not have AST in my methods signature, as I would like to stay solely in the realm of IBindings..
Also, repeated calls to resolveWellKnownType look slowish (but I haven't benchmarked this yet).
|
|
|
|
Re: Getting the java.lang.Object ITypeBinding from an interface method's IMethodBinding [message #1722717 is a reply to message #1722450] |
Mon, 08 February 2016 09:47  |
Eclipse User |
|
|
|
Quote:I believe AST.resolveWellKnownType("java.lang.Object") should be OK, as it basically goes through the same internal lookup - resolver.getTypeBInding() - that is also used in TypeBinding.getSuperclass() et al..
Thanks, Stephan for confirming that this is the way to go. Too bad that there is no ITypeBinding.resolveWellKnownType, so one has to pass ASTs around further than actually needed, deep into helper methods which should really be able to operate with bindings alone.
|
|
|
Powered by
FUDForum. Page generated in 0.06934 seconds