How to tell if a method is overridden?

Anybody know how to tell if a concrete method is overridden, or where an abstract method is implemented, using Psi?

(One of the Last Things To Do before releasing the code rearrangement plugin.)

-Dave

3 comments

PsiSearchHelper has method

PsiMethod[] findOverridingMethods(PsiMethod method, SearchScope
searchScope, boolean checkDeep);


--
Valentin Kipiatkov
JetBrains, Inc
http://www.intellij.com
"Develop with pleasure!"

"Dave Kriewall" <no_mail@jetbrains.com> wrote in message
news:10368983.1066136114380.JavaMail.itn@is.intellij.net...

Anybody know how to tell if a concrete method is overridden, or where an

abstract method is implemented, using Psi?
>

(One of the Last Things To Do before releasing the code rearrangement

plugin.)
>

-Dave



0

Perfect!


I presume that getAccessScope returns the right type (local or global) of search scope. Is this based on whether the method is private or not?

Does the boolean argument 'deep' controls whether methods deeper than one subclass level are considered?

Regardless, the code works! Thanks, Valentin.

-Dave

0

I presume that getAccessScope returns the right type (local or global) of

search scope. Is this based on whether the method is private or not?

Yes, the access scope considers method access scope but you don't need to
use it. Just use

SearchScope ss = createAllScope(project);

and the rest will be handled by PsiSearchHelper.
PsiSearchHelper will anyway not search usages in places where they cannot
exist. So the search scope parameter is needed only when you need to
restrict the scope of the search.

Does the boolean argument 'deep' controls whether methods deeper than one

subclass level are considered?

Exactly.

--
Valentin Kipiatkov
JetBrains, Inc
http://www.intellij.com
"Develop with pleasure!"


>

Does the boolean argument 'deep' controls whether methods deeper than one

subclass level are considered?

"Dave Kriewall" <no_mail@jetbrains.com> wrote in message
news:16768670.1066658988003.JavaMail.itn@is.intellij.net...

Perfect!

>

 SearchScope ss = psh.getAccessScope(child);
> PsiMethod[] overriders = psh.findOverridingMethods(method, ss,
true);]]>

>

I presume that getAccessScope returns the right type (local or global) of

search scope. Is this based on whether the method is private or not?
>

Does the boolean argument 'deep' controls whether methods deeper than one

subclass level are considered?
>

Regardless, the code works! Thanks, Valentin.

>

-Dave

>


0

Please sign in to leave a comment.