Structural search for implementing methods ?

Given an extensive code base, I'd like to find the methods that are implementations/overrides of methods of classes of a given package.

On my projects we're using an external component library. Custom components are made by extending the base classes and providing implementations of methods. A classis approach.

I'd like to find in our code what classes implement or override methods of the external library.

Is that possible with Structural Search ?

1 comment
Comment actions Permalink

It's possible but it's not easy:)

Here's an example to find methods overriding a method of java.util.AbstractList:
- start with the existing template "methods of the class"
- add an extends or implements clause

class $Class$ extends java.util.AbstractList { 
  $ReturnType$ $MethodName$($ParameterType$ $Parameter$);
}


- edit variable MethodName and give the following script constraints

import com.intellij.psi.PsiClass
import com.intellij.psi.PsiMethod

for (PsiMethod superMethod : __context__.findSuperMethods(null)) {
  PsiClass aClass = superMethod.getContainingClass();
  if ("java.util.AbstractList".equals(aClass.getQualifiedName())) {
    return true;
  }
}
return false;


Change the "java.util.AbstractList" in both the template and the script to refer to the library class you want to check.


Bas

0

Please sign in to leave a comment.