How to get list of all methods of java files in IntelliJ plugin development

I am working on Intelli j plugin development. My requirement is to get the list of all methods in project's java files and add my code in first line of every method.
So far I am able to get list of all java files in my project through plugin but struggling to get methods in java files.
Please share reference links or provide sample code examples.

1 comment
Comment actions Permalink

You can use a JavaRecursiveElementVisitor and override the visitMethod() method, and pass it to PsiFile.acceptChildren(). You can find plenty of reference information and usage examples in the IntelliJ IDEA Community Edition source code.


Please sign in to leave a comment.