you need a Visitor and a PsiFile to access the methods. If you want to search methods for a Java Class you can use a JavaRecursiveElementVisitor that extends your own visitor and override the method visitMethod. If you want to search methods for another languages you can use a PsiRecusiveElementVisitor and use visitElement and check if the element you get is an instance of PsiMethod.
example for a Visitor for a PsiFile:
public class Visitor extends PsiRecursiveElementVisitor {
private List<PsiMethod> psiMethods = new ArrayList<PsiMethod>();
@Override public void visitElement(PsiElement element) {
if (element instanceof PsiMethod) { psiMethods.add((PsiMethod) element); }
super.visitElement(element); }
public List<PsiMethod> getPsiMethods() { return psiMethods; } }
your PsiFile has an accept Method that accepts the visitor and after that you get the Methods from your visitor. I hope this helps you.
Hello, Hikaru.
Try to explore the following classes:
Hi Hiakru,
you need a Visitor and a PsiFile to access the methods.
If you want to search methods for a Java Class you can use a JavaRecursiveElementVisitor that extends your own visitor and override the method
visitMethod.
If you want to search methods for another languages you can use a PsiRecusiveElementVisitor and use visitElement and check if the element you get is an instance of PsiMethod.
example for a Visitor for a PsiFile:
your PsiFile has an accept Method that accepts the visitor and after that you get the Methods from your visitor.
I hope this helps you.
Markus