Creating own IntelliJ Plugin written in Scala - doesn't work

Hi guys,

I want to develop my own IntelliJ plugin and I would like to do it using Scala language. When I use Java, everything work perfectly, but I'm not able to run a simple AnAction implemented in Scala.
Have a look at these code samples, I have two AnAction implementations, one in Java and one in Scala, both of them are registered in plugin.xml:

actions.png
pluginxml.png
And if run this plugin, Java Plugin works fine:

javaplugin.png

But unfortunately Scala Plugin doesn't work:

scalaplugin.png

When I hit Scala Plugin I get a huge bunch of errors:

[   8646]   WARN - api.vfs.impl.local.FileWatcher - The current <b>inotify</b>(7) watch limit is too low. <a href="https://confluence.jetbrains.com/display/IDEADEV/Inotify+Watches+Limit">More details.</a> [   8959]   WARN - om.intellij.util.ProfilingUtil - Profiling agent is not enabled. Add -agentlib:yjpagent to idea.vmoptions if necessary to profile IDEA. [  10117]   WARN - .ExternalResourceManagerExImpl - Cannot find standard resource. filename:/META-INF/tapestry_5_3.xsd class=class com.intellij.javaee.ResourceRegistrarImpl, classLoader:null [  56106]  ERROR - ctionSystem.DefaultActionGroup - class with name "com.plasma.bj.idea.plugins.ScalaAction" not found [Plugin: com.yourcompany.unique.plugin.id] com.intellij.diagnostic.PluginException: class with name "com.plasma.bj.idea.plugins.ScalaAction" not found [Plugin: com.yourcompany.unique.plugin.id]      at com.intellij.openapi.actionSystem.impl.ActionManagerImpl.convertStub(ActionManagerImpl.java:158)      at com.intellij.openapi.actionSystem.impl.ActionManagerImpl.a(ActionManagerImpl.java:516)      at com.intellij.openapi.actionSystem.impl.ActionManagerImpl.a(ActionManagerImpl.java:496)      at com.intellij.openapi.actionSystem.impl.ActionManagerImpl.getAction(ActionManagerImpl.java:489)      at com.intellij.openapi.actionSystem.DefaultActionGroup.unStub(DefaultActionGroup.java:354)      at com.intellij.openapi.actionSystem.DefaultActionGroup.getChildren(DefaultActionGroup.java:312)      at com.intellij.openapi.actionSystem.impl.Utils.expandActionGroup(Utils.java:125)      at com.intellij.openapi.actionSystem.impl.Utils.expandActionGroup(Utils.java:86)      at com.intellij.openapi.actionSystem.impl.Utils.fillMenu(Utils.java:280)      at com.intellij.openapi.actionSystem.impl.ActionMenu.g(ActionMenu.java:281)      at com.intellij.openapi.actionSystem.impl.ActionMenu.access$400(ActionMenu.java:41)      at com.intellij.openapi.actionSystem.impl.ActionMenu$MenuListenerImpl.menuSelected(ActionMenu.java:235)      at javax.swing.JMenu.fireMenuSelected(JMenu.java:1043)      at javax.swing.JMenu$MenuChangeListener.stateChanged(JMenu.java:1122)      at javax.swing.DefaultButtonModel.fireStateChanged(DefaultButtonModel.java:349)      at javax.swing.DefaultButtonModel.setSelected(DefaultButtonModel.java:232)      at javax.swing.JMenu.setSelected(JMenu.java:311)      at javax.swing.JMenu.menuSelectionChanged(JMenu.java:1190)      at com.intellij.openapi.actionSystem.impl.ActionMenu.menuSelectionChanged(ActionMenu.java:209)      at javax.swing.MenuSelectionManager.setSelectedPath(MenuSelectionManager.java:125)      at javax.swing.plaf.basic.BasicMenuUI$Handler.mousePressed(BasicMenuUI.java:450)      at java.awt.Component.processMouseEvent(Component.java:6513)      at javax.swing.JComponent.processMouseEvent(JComponent.java:3321)      at java.awt.Component.processEvent(Component.java:6281)      at java.awt.Container.processEvent(Container.java:2229)      at java.awt.Component.dispatchEventImpl(Component.java:4872)      at java.awt.Container.dispatchEventImpl(Container.java:2287)      at java.awt.Component.dispatchEvent(Component.java:4698)      at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:4832)      at java.awt.LightweightDispatcher.processMouseEvent(Container.java:4489)      at java.awt.LightweightDispatcher.dispatchEvent(Container.java:4422)      at java.awt.Container.dispatchEventImpl(Container.java:2273)      at java.awt.Window.dispatchEventImpl(Window.java:2719)      at java.awt.Component.dispatchEvent(Component.java:4698)      at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:747)      at java.awt.EventQueue.access$300(EventQueue.java:103)      at java.awt.EventQueue$3.run(EventQueue.java:706)      at java.awt.EventQueue$3.run(EventQueue.java:704)      at java.security.AccessController.doPrivileged(Native Method)      at java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:76)      at java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:87)      at java.awt.EventQueue$4.run(EventQueue.java:720)      at java.awt.EventQueue$4.run(EventQueue.java:718)      at java.security.AccessController.doPrivileged(Native Method)      at java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:76)      at java.awt.EventQueue.dispatchEvent(EventQueue.java:717)      at com.intellij.ide.IdeEventQueue.e(IdeEventQueue.java:734)      at com.intellij.ide.IdeEventQueue._dispatchEvent(IdeEventQueue.java:565)      at com.intellij.ide.IdeEventQueue.dispatchEvent(IdeEventQueue.java:382)      at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:242)      at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:161)      at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:150)      at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:146)      at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:138)      at java.awt.EventDispatchThread.run(EventDispatchThread.java:91) Caused by: java.lang.ClassNotFoundException: com.plasma.bj.idea.plugins.ScalaAction PluginClassLoader[com.yourcompany.unique.plugin.id, 1.0]      at com.intellij.ide.plugins.cl.PluginClassLoader.loadClass(PluginClassLoader.java:68)      at java.lang.ClassLoader.loadClass(ClassLoader.java:358)      at java.lang.Class.forName0(Native Method)      at java.lang.Class.forName(Class.java:278)      at com.intellij.openapi.actionSystem.impl.ActionManagerImpl.convertStub(ActionManagerImpl.java:152)      ... 54 more [  56110]  ERROR - ctionSystem.DefaultActionGroup - IntelliJ IDEA 14.1.2  Build #IU-141.713.2 [  56110]  ERROR - ctionSystem.DefaultActionGroup - JDK: 1.7.0_80 [  56110]  ERROR - ctionSystem.DefaultActionGroup - VM: Java HotSpot(TM) Server VM [  56110]  ERROR - ctionSystem.DefaultActionGroup - Vendor: Oracle Corporation [  56111]  ERROR - ctionSystem.DefaultActionGroup - OS: Linux [  56111]  ERROR - ctionSystem.DefaultActionGroup - Last Action: JavaPlugin.menuItem [  56111]  ERROR - ctionSystem.DefaultActionGroup - Can't unstub Connect to Scala Plugin server (Connect to Scala Plugin) java.lang.Throwable      at com.intellij.openapi.diagnostic.Logger.error(Logger.java:115)      at com.intellij.openapi.actionSystem.DefaultActionGroup.getChildren(DefaultActionGroup.java:314)      at com.intellij.openapi.actionSystem.impl.Utils.expandActionGroup(Utils.java:125)      at com.intellij.openapi.actionSystem.impl.Utils.expandActionGroup(Utils.java:86)      at com.intellij.openapi.actionSystem.impl.Utils.fillMenu(Utils.java:280)      at com.intellij.openapi.actionSystem.impl.ActionMenu.g(ActionMenu.java:281)      at com.intellij.openapi.actionSystem.impl.ActionMenu.access$400(ActionMenu.java:41)      at com.intellij.openapi.actionSystem.impl.ActionMenu$MenuListenerImpl.menuSelected(ActionMenu.java:235)      at javax.swing.JMenu.fireMenuSelected(JMenu.java:1043)      at javax.swing.JMenu$MenuChangeListener.stateChanged(JMenu.java:1122)      at javax.swing.DefaultButtonModel.fireStateChanged(DefaultButtonModel.java:349)      at javax.swing.DefaultButtonModel.setSelected(DefaultButtonModel.java:232)      at javax.swing.JMenu.setSelected(JMenu.java:311)      at javax.swing.JMenu.menuSelectionChanged(JMenu.java:1190)      at com.intellij.openapi.actionSystem.impl.ActionMenu.menuSelectionChanged(ActionMenu.java:209)      at javax.swing.MenuSelectionManager.setSelectedPath(MenuSelectionManager.java:125)      at javax.swing.plaf.basic.BasicMenuUI$Handler.mousePressed(BasicMenuUI.java:450)      at java.awt.Component.processMouseEvent(Component.java:6513)      at javax.swing.JComponent.processMouseEvent(JComponent.java:3321)      at java.awt.Component.processEvent(Component.java:6281)      at java.awt.Container.processEvent(Container.java:2229)      at java.awt.Component.dispatchEventImpl(Component.java:4872)      at java.awt.Container.dispatchEventImpl(Container.java:2287)      at java.awt.Component.dispatchEvent(Component.java:4698)      at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:4832)      at java.awt.LightweightDispatcher.processMouseEvent(Container.java:4489)      at java.awt.LightweightDispatcher.dispatchEvent(Container.java:4422)      at java.awt.Container.dispatchEventImpl(Container.java:2273)      at java.awt.Window.dispatchEventImpl(Window.java:2719)      at java.awt.Component.dispatchEvent(Component.java:4698)      at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:747)      at java.awt.EventQueue.access$300(EventQueue.java:103)      at java.awt.EventQueue$3.run(EventQueue.java:706)      at java.awt.EventQueue$3.run(EventQueue.java:704)      at java.security.AccessController.doPrivileged(Native Method)      at java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:76)      at java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:87)      at java.awt.EventQueue$4.run(EventQueue.java:720)      at java.awt.EventQueue$4.run(EventQueue.java:718)      at java.security.AccessController.doPrivileged(Native Method)      at java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:76)      at java.awt.EventQueue.dispatchEvent(EventQueue.java:717)      at com.intellij.ide.IdeEventQueue.e(IdeEventQueue.java:734)      at com.intellij.ide.IdeEventQueue._dispatchEvent(IdeEventQueue.java:565)      at com.intellij.ide.IdeEventQueue.dispatchEvent(IdeEventQueue.java:382)      at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:242)      at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:161)      at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:150)      at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:146)      at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:138)      at java.awt.EventDispatchThread.run(EventDispatchThread.java:91) [  56112]  ERROR - ctionSystem.DefaultActionGroup - IntelliJ IDEA 14.1.2  Build #IU-141.713.2 [  56112]  ERROR - ctionSystem.DefaultActionGroup - JDK: 1.7.0_80 [  56112]  ERROR - ctionSystem.DefaultActionGroup - VM: Java HotSpot(TM) Server VM [  56112]  ERROR - ctionSystem.DefaultActionGroup - Vendor: Oracle Corporation [  56112]  ERROR - ctionSystem.DefaultActionGroup - OS: Linux [  56112]  ERROR - ctionSystem.DefaultActionGroup - Last Action: JavaPlugin.menuItem [  81028]  ERROR - ctionSystem.DefaultActionGroup - Null child action in group Scala Plugin (Scala Plugin) of class class com.intellij.openapi.actionSystem.DefaultActionGroup, id=ScalaPlugin.menuItem java.lang.Throwable      at com.intellij.openapi.diagnostic.Logger.error(Logger.java:115)      at com.intellij.openapi.actionSystem.DefaultActionGroup.unStub(DefaultActionGroup.java:356)      at com.intellij.openapi.actionSystem.DefaultActionGroup.getChildren(DefaultActionGroup.java:312)      at com.intellij.openapi.actionSystem.impl.ActionManagerImpl$5.compute(ActionManagerImpl.java:1310)      at com.intellij.openapi.actionSystem.impl.ActionManagerImpl$5.compute(ActionManagerImpl.java:1303)      at com.intellij.openapi.application.impl.ApplicationImpl.runReadAction(ApplicationImpl.java:894)      at com.intellij.openapi.actionSystem.impl.ActionManagerImpl.a(ActionManagerImpl.java:1303)      at com.intellij.openapi.actionSystem.impl.ActionManagerImpl.a(ActionManagerImpl.java:1318)      at com.intellij.openapi.actionSystem.impl.ActionManagerImpl.preloadActionGroup(ActionManagerImpl.java:1297)      at com.intellij.openapi.actionSystem.impl.ActionManagerImpl.c(ActionManagerImpl.java:1288)      at com.intellij.openapi.actionSystem.impl.ActionManagerImpl.access$200(ActionManagerImpl.java:76)      at com.intellij.openapi.actionSystem.impl.ActionManagerImpl$4.run(ActionManagerImpl.java:1268)      at com.intellij.openapi.application.impl.ApplicationImpl$8.run(ApplicationImpl.java:405)      at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:471)      at java.util.concurrent.FutureTask.run(FutureTask.java:262)      at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)      at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)      at java.lang.Thread.run(Thread.java:745)      at org.jetbrains.ide.PooledThreadExecutor$1$1.run(PooledThreadExecutor.java:56) [  81031]  ERROR - ctionSystem.DefaultActionGroup - IntelliJ IDEA 14.1.2  Build #IU-141.713.2 [  81032]  ERROR - ctionSystem.DefaultActionGroup - JDK: 1.7.0_80 [  81032]  ERROR - ctionSystem.DefaultActionGroup - VM: Java HotSpot(TM) Server VM [  81032]  ERROR - ctionSystem.DefaultActionGroup - Vendor: Oracle Corporation [  81032]  ERROR - ctionSystem.DefaultActionGroup - OS: Linux [  81033]  ERROR - ctionSystem.DefaultActionGroup - Last Action: JavaPlugin.menuItem [  81033]  ERROR - ctionSystem.DefaultActionGroup - Can't unstub Connect to Scala Plugin server (Connect to Scala Plugin) java.lang.Throwable      at com.intellij.openapi.diagnostic.Logger.error(Logger.java:115)      at com.intellij.openapi.actionSystem.DefaultActionGroup.getChildren(DefaultActionGroup.java:314)      at com.intellij.openapi.actionSystem.impl.ActionManagerImpl$5.compute(ActionManagerImpl.java:1310)      at com.intellij.openapi.actionSystem.impl.ActionManagerImpl$5.compute(ActionManagerImpl.java:1303)      at com.intellij.openapi.application.impl.ApplicationImpl.runReadAction(ApplicationImpl.java:894)      at com.intellij.openapi.actionSystem.impl.ActionManagerImpl.a(ActionManagerImpl.java:1303)      at com.intellij.openapi.actionSystem.impl.ActionManagerImpl.a(ActionManagerImpl.java:1318)      at com.intellij.openapi.actionSystem.impl.ActionManagerImpl.preloadActionGroup(ActionManagerImpl.java:1297)      at com.intellij.openapi.actionSystem.impl.ActionManagerImpl.c(ActionManagerImpl.java:1288)      at com.intellij.openapi.actionSystem.impl.ActionManagerImpl.access$200(ActionManagerImpl.java:76)      at com.intellij.openapi.actionSystem.impl.ActionManagerImpl$4.run(ActionManagerImpl.java:1268)      at com.intellij.openapi.application.impl.ApplicationImpl$8.run(ApplicationImpl.java:405)      at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:471)      at java.util.concurrent.FutureTask.run(FutureTask.java:262)      at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)      at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)      at java.lang.Thread.run(Thread.java:745)      at org.jetbrains.ide.PooledThreadExecutor$1$1.run(PooledThreadExecutor.java:56) [  81035]  ERROR - ctionSystem.DefaultActionGroup - IntelliJ IDEA 14.1.2  Build #IU-141.713.2 [  81035]  ERROR - ctionSystem.DefaultActionGroup - JDK: 1.7.0_80 [  81036]  ERROR - ctionSystem.DefaultActionGroup - VM: Java HotSpot(TM) Server VM [  81036]  ERROR - ctionSystem.DefaultActionGroup - Vendor: Oracle Corporation [  81036]  ERROR - ctionSystem.DefaultActionGroup - OS: Linux [  81036]  ERROR - ctionSystem.DefaultActionGroup - Last Action: JavaPlugin.menuItem


Most interesting line is this one:

[  56106]  ERROR - ctionSystem.DefaultActionGroup - class with name "com.plasma.bj.idea.plugins.ScalaAction" not found [Plugin: com.yourcompany.unique.plugin.id]


I have no idea what I'm doing wrong or what I missed, guys can you please help me? I tried to go through the https://github.com/JetBrains/intellij-scala configuration, but I can find nothing that would help me.

Thanks,
Bartosz

10 comments
Comment actions Permalink

No one of you guys? No ideas? Whatever...

Please help me :)

0
Comment actions Permalink

Looks like Scala class is not compiled. Can you attach full project to check what's wrong with settings?

Best regards,
Alexander Podkhalyuzin.

0
Comment actions Permalink

Hi Alexander,

Thanks for your interest. Here you can see my whole project: https://github.com/BartoszJanota/automan-debugger.

Thanks,
Bartosz

0
Comment actions Permalink

You need to attach Scala to your module. It's simple, just create Scala library and attach it (see screenshot).
However it's better to use SBT for any Scala development. As example you can use Scala plugin sources. But right now it will require a lot of time and effort to start using SBT for IntelliJ IDEA plugin project, so for the beginning your way is ok.

Best regards,
Alexander Podkhlayuzin.



Attachment(s):
Screen Shot 2015-06-18 at 17.08.41.png
1
Comment actions Permalink

Thanks for your advices :)!

I added the Scala library (I have it listed in .idea/libraries/) and it still the same. My plugin doesn't work, I'm getting the same error. What did I miss?
Were you able to run my code and to use ScalaAction? Maybe my run configuration is wrong, it's is a default Plugin configuration. What should it look like?

I always use SBT for any Scala development. But as you mentioned, it is probably hard to add SBT to a plugin project (how to do it?). Do you have a tutorial or an exemplary plugin template which contains SBT (something not as complicated and huge as the Scala plugin)?

Best,
Bartosz

0
Comment actions Permalink

Hi Alexander,
I prepared a new plugin project and added Scala as a library and now it works perfectly :)! It must have been something wrong with the old configuration. So for the beggining this way is okay - I can develop my plugin using Scala only. Thanks!

So now my question is (as I wrote in the recent post) - how can I add SBT to my plugin project?

Thanks,
Bartosz

0
Comment actions Permalink

You can try to use Scala plugin sbt buildscript by removing most parts (but you still need to have some IDEA xml files in VCS like run configurations). It's not unreal task.
IntelliJ IDEA team is working on Gradle script/plugin to support IDEA projects, we will probably do the same for SBT, but not in the nearest future.
So... you can wait for Gradle way, or use our SBT script to create your own.

Best regards,
Alexander Podkhalyuzin.

0
Comment actions Permalink

The link to gradle plugin: https://github.com/JetBrains/gradle-intellij-plugin

Best regards,
Alexander Podkhalyuzin.

0
Comment actions Permalink

I'm gonna do it later, I know it is unreal, but it is just frustrating when you want to code something but you can't, because your project is still not configured.

I'll go through Gradle scripts as well. Maybe it is a good idea to write a post on my blog: how to start with IntelliJ IDEA Plugin development in Scala?

Thank you for your answers :),
Bartosz

0
Comment actions Permalink

Thanks, it might be very helpful!

0

Please sign in to leave a comment.