How to visit code to get variable, class, and parameter
Answered
I am wanting to make a plugin that'll visit over on a class and check for a few things, for example:
I wanted to get the val name "test", the number "5" and the string "Hello", I couldn't find anywhere on how work with a visitor on the documentations.
I found an example which is for a `HighlightVisitor` which I kinda made it work correctly, however had to use Regex and some other methods to get the data I wanted, so I am assuming it's not the best way to do it.
What would be the best way to achieve this? Could someone show me an example?
Thank you!
Please sign in to leave a comment.
All information is exposed via PSI. You can use PSI Viewer plugin to inspect it live https://plugins.jetbrains.com/plugin/227-psiviewer
https://jetbrains.org/intellij/sdk/docs/basics/architectural_overview/psi.html