Execute a Kotlin method from psiClass

已回答

I have psiClass, i want to execute it's one of it's method

fun readFrom(input: InputStream)

Any leads or examples?

0

What does "execute" mean? Please provide some context.

0

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.

0

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.

0

请先登录再写评论。