Execute a Kotlin method from psiClass
Answered
I have psiClass, i want to execute it's one of it's method
fun readFrom(input: InputStream)
Any leads or examples?
Please sign in to leave a comment.
What does "execute" mean? Please provide some context.
Hi Yann,
I was wondering if Intellij provides any easy to use api to generate the class instance using psiClass. I understand, that it need to make use of reflection. I tried using java reflection with different classLoader of the module where class file lives in the project, but i was getting ClassNotFound exception. The url path and qualified name were correct and files does exist in those location.
Basically, I am building a plugin which grabs virtual file from device explorer and a generated Serialiser psiClass from android project, but to make use of the Serialiser class, it need to invoked, using the psiClass info like fully qualified name.
I was also wondering, what would be the recommend way though - is it recommend to be dependent on .class file of the project or it's better to use the same tools and generate them in the plugin itself.
You'll need to compile the class from the project yourself (or locate the compiled output) to be able to execute it. The PSI is just a semantic view of the sources.