parse .java file outside plugin
Hello! I wanted to use java-parser from jetBrains library. I have a simple task, I want to parse my .java class from disk and get AST, and then I want to make analysis by AST (i.e get names of anonymous classes, like Main$2$1). But as I understood all classes which do this job require some classes which environment gives me if I write a plugin. I have nothing to do with plugins, I just want to write main() method and parse .java class.
For example PsiJavaFileImpl requires FileViewProvider, and ClassFileViewProvider requires PsiManager, VirtualFile and all this staff.
My question: how can I do it without all these classes? I just need an instance of parser without any plugin staff.
I saw a ticket that you published PSI library (https://youtrack.jetbrains.com/issue/IDEA-192396), and I need to use it, but it didn't really help me to understand how to do it.
Thanks!
Please sign in to leave a comment.
This is not really trivial but search turns up some suggestions
https://intellij-support.jetbrains.com/hc/en-us/community/posts/206755275-Create-standalone-parser-from-plugin-code
https://intellij-support.jetbrains.com/hc/en-us/community/posts/203374950-Use-Grammar-Kit-parser-standalone