So I watched Dimitry's demo of live coding a plugin from scratch and got inspired. I am trying to feel my way around writing an Android Studio plugin using IntelliJ CE. (I noticed Studio doesn't have plugin project templates, what a shame!) My initial goal is to invoke my plugin from a "build.gradle" file and visualize/list all of the code blocks at the cursor following very close to the live coding demo. I'm currently stuck on this statement in my plugin which returns false:
The PsiElement in question is a "whitespace element in a GrCloseableBlockImpl paranet. (psiElement.getParent() returns "Closable block" in the debugger.) I've further drilled down in the debugger to:
Which also returns false. Interestingly enough this returns true in the same debug session:
To get my plugin to even compile I added all of the jars under the Groovy Plugin folder in my IJ 13.1 CE install location. This has me thinking the issue is most likely classloader related. I was confused why I couldn't access the Groovy Psi stuff without adding these plugin Jars. I'm seeing groovy isn't yet as fully baked into the IDE as Java though getting closer everyday. When I tried marking these jar dependencies as "provided" instead of "Compile" in the module settings I got NoClassDefFound errors so I know I have to inline them even though I feel they are already included with the product. My overall question is how does one use the Groovy Psi stuff in a plugin? Is my approach of inlining the Groovy plugin jars correct or am I missing something? Also why does my attempt at finding CodeBlocks not working as I would expect?
I just found out that there are 2 different classloaders involved! my psiElement is loaded by:
Where the GrCodeBlock is loaded by:
This probably means that I'll have to load all of the GroovyPSI stuff using reflection... (yuk!) Is there a better way?