How can we judge if a method is overrides other method? [message #217707] |
Tue, 25 October 2005 05:42  |
Eclipse User |
|
|
|
Hi, dear all
I get an MethodDeclaration instance through traversing from
CompilationUnit. MethodDeclaration can offer many info about method, but
I haven't found a method to tell if this method overrides other method.
Although I found some internal API such as "Bindings" is revelant, I
think there should be other ways rather to use internal API.
Could you please help me?
Thanks!
James
|
|
|
|
|
|
Re: How can we judge if a method is overrides other method? [message #217901 is a reply to message #217881] |
Wed, 26 October 2005 05:57  |
Eclipse User |
|
|
|
You are right. Thanks for discussion!
Jerome Lanneluc wrote:
> I'm afraid that what you're asking is not available yet (see the
> feature request https://bugs.eclipse.org/bugs/show_bug.cgi?id=90660).
>
> So in the meantime, the only solution is to search the hierarchy and
> test every method.
>
> Jerome
>
> James Gan wrote:
>
>> Hi, Jerome
>>
>> Thank you for telling me this API. This is really helpful. But my
>> problem is a little different. I haven't an otherMethodBinding in
>> hand. I want to know if a method overrides any other method.
>>
>> Should I search the hierarchy and get every method then test it with
>> "overrides()"?
>>
>> Jerome Lanneluc wrote:
>>
>>> MethodDeclaration methodDeclaration = ...
>>> IMethodBinding methodBinding = methodDeclaration.resolveBinding();
>>> return methodBinding.overrides(otherMethodBinding);
>>>
>>> Note you need to ask the ASTParser to resolve bindings before
>>> creating the AST.
>>> See ASTParser#setResolveBindings(boolean).
>>>
>>> Jerome
>>>
>>> James Gan wrote:
>>>
>>>> Hi, dear all
>>>>
>>>> I get an MethodDeclaration instance through traversing from
>>>> CompilationUnit. MethodDeclaration can offer many info about method,
>>>> but I haven't found a method to tell if this method overrides other
>>>> method. Although I found some internal API such as "Bindings" is
>>>> revelant, I think there should be other ways rather to use internal
>>>> API.
>>>>
>>>> Could you please help me?
>>>>
>>>> Thanks!
>>>> James
|
|
|
Powered by
FUDForum. Page generated in 0.06299 seconds