Groovy files editing

Is it possible to edit groovy file like build.gradle from plugin without plain text nodes (PlainTextASTFactory)? After finding groovy PsiFile (GroovyFileImpl) i found no way to import this class. Is somewhere any example or sample of working with groovy files, or plain text nodes is single way for this action? 

0
3 comments

Groovy is a separate plugin and you should include it as `compileOnly` dependency of your plugin.  If you are using Gradle, see `intellij.plugins` attribute.

Also, don't forget to add 

<depends>org.intellij.groovy</depends>

to your plugin.xml. Note that after that your plugin will require groovy to be installed and enabled.

You can also put all groovy-related extensions registrations into separate xml file and require it with optional dependency:

<depends optional="true" config-file="groovy-deps.xml">org.intellij.groovy</depends>

In such case extensions from groovy-deps.xml going to be loaded only if groovy plugin is installed and enabled.

0
Avatar
Permanently deleted user

"include it as `compileOnly` dependency of your plugin"

What exactly should be included? When i try to add <depends> to plugin.xml and as `compileOnly` dependencies 3 jars from https://plugins.jetbrains.com/plugin/1524-jetgroovy i can import GroovyFileImpl but when plugin was ran and i found my file and cast it to this class i get "org.jetbrains.plugins.groovy.lang.psi.impl.GroovyFileImpl cannot be cast to org.jetbrains.plugins.groovy.lang.psi.impl.GroovyFileImpl" 

0

Sorry, it was a gradle script terminology. Looks like you've added classes to your project and now you have your own GroovyFileImpl. According to https://www.jetbrains.com/help/idea/dependencies.html you should set 'Provided' scope for dependency if you are using just a plugin DevKit.

0

Please sign in to leave a comment.