cursive-ide / cursive

Cursive: The IDE for beautiful Clojure code
588 stars 7 forks source link

Cursive exceptions editing ruby files #910

Open conan opened 9 years ago

conan commented 9 years ago

I've just imported a chef (Ruby) project into Intellij, but when I try to edit .erb files (associated with the RHTML editor apparently), I can't - the first character or space I type throws a Cursive AssertionError. I don't know why Cursive has anything to do with these files - how can I stop Cursive being involved for non-Clojure files?

Here are a couple of stacktraces (I get a different one depending on which key I press):

PsiElement({); file: ERbFile:convolo-metrics-api.conf.erb; isvalid: true
java.lang.AssertionError: PsiElement({); file: ERbFile:convolo-metrics-api.conf.erb; isvalid: true
    at com.intellij.psi.util.PsiUtilBase.getPsiFileAtOffset(PsiUtilBase.java:147)
    at com.intellij.psi.util.PsiUtilBase.getPsiFileInEditor(PsiUtilBase.java:141)
    at com.intellij.psi.util.PsiUtilBase.getPsiFileInEditor(PsiUtilBase.java:123)
    at cursive.actions.paredit$create_widget$update_status__2544.invoke(paredit.clj:570)
    at cursive.actions.paredit$create_widget$fn__2547.invoke(paredit.clj:580)
    at cursive.actions.paredit.proxy$com.intellij.openapi.wm.impl.status.EditorBasedWidget$CustomStatusBarWidget$StatusBarWidget$Multiframe$27c457ee.selectionChanged(Unknown Source)
    at sun.reflect.GeneratedMethodAccessor34.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:497)
    at com.intellij.util.messages.impl.MessageBusConnectionImpl.deliverMessage(MessageBusConnectionImpl.java:116)
    at com.intellij.util.messages.impl.MessageBusImpl.doPumpMessages(MessageBusImpl.java:322)
    at com.intellij.util.messages.impl.MessageBusImpl.pumpMessages(MessageBusImpl.java:309)
    at com.intellij.util.messages.impl.MessageBusImpl.pumpMessages(MessageBusImpl.java:295)
    at com.intellij.util.messages.impl.MessageBusImpl.sendMessage(MessageBusImpl.java:288)
    at com.intellij.util.messages.impl.MessageBusImpl.access$200(MessageBusImpl.java:41)
    at com.intellij.util.messages.impl.MessageBusImpl$2.invoke(MessageBusImpl.java:177)
    at com.sun.proxy.$Proxy88.selectionChanged(Unknown Source)
    at com.intellij.openapi.fileEditor.impl.FileEditorManagerImpl$17.run(FileEditorManagerImpl.java:1585)
    at com.intellij.openapi.fileEditor.impl.FileEditorManagerImpl$14$1.run(FileEditorManagerImpl.java:1016)
    at com.intellij.openapi.wm.impl.FocusManagerImpl.a(FocusManagerImpl.java:672)
    at com.intellij.openapi.wm.impl.FocusManagerImpl.g(FocusManagerImpl.java:656)
    at com.intellij.openapi.wm.impl.FocusManagerImpl.e(FocusManagerImpl.java:626)
    at com.intellij.openapi.wm.impl.FocusManagerImpl.access$200(FocusManagerImpl.java:60)
    at com.intellij.openapi.wm.impl.FocusManagerImpl$11.run(FocusManagerImpl.java:522)
    at com.intellij.util.ui.UIUtil.invokeLaterIfNeeded(UIUtil.java:2344)
    at com.intellij.openapi.wm.impl.FocusManagerImpl.doWhenFocusSettlesDown(FocusManagerImpl.java:500)
    at com.intellij.openapi.actionSystem.impl.ToolbarUpdater.a(ToolbarUpdater.java:108)
    at com.intellij.openapi.actionSystem.impl.ToolbarUpdater.updateActions(ToolbarUpdater.java:93)
    at com.intellij.openapi.actionSystem.impl.ActionToolbarImpl$3.run(ActionToolbarImpl.java:929)
    at com.intellij.util.ui.update.UiNotifyConnector$2.showNotify(UiNotifyConnector.java:132)
    at com.intellij.util.ui.update.UiNotifyConnector.showNotify(UiNotifyConnector.java:81)
    at com.intellij.util.ui.update.UiNotifyConnector$Once.showNotify(UiNotifyConnector.java:117)
    at com.intellij.util.ui.update.UiNotifyConnector$1.run(UiNotifyConnector.java:59)
    at com.intellij.openapi.application.impl.LaterInvocator$FlushQueue.run(LaterInvocator.java:332)
    at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:311)
    at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:749)
    at java.awt.EventQueue.access$500(EventQueue.java:97)
    at java.awt.EventQueue$3.run(EventQueue.java:702)
    at java.awt.EventQueue$3.run(EventQueue.java:696)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:75)
    at java.awt.EventQueue.dispatchEvent(EventQueue.java:719)
    at com.intellij.ide.IdeEventQueue.e(IdeEventQueue.java:734)
    at com.intellij.ide.IdeEventQueue._dispatchEvent(IdeEventQueue.java:569)
    at com.intellij.ide.IdeEventQueue.dispatchEvent(IdeEventQueue.java:382)
    at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:201)
    at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:116)
    at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:105)
    at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:101)
    at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:93)
    at java.awt.EventDispatchThread.run(EventDispatchThread.java:82)
PsiWhiteSpace; file: ERbFile:convolo-metrics-api.conf.erb; isvalid: true
java.lang.AssertionError: PsiWhiteSpace; file: ERbFile:convolo-metrics-api.conf.erb; isvalid: true
    at com.intellij.psi.util.PsiUtilBase.getPsiFileAtOffset(PsiUtilBase.java:147)
    at com.intellij.psi.util.PsiUtilBase.getPsiFileInEditor(PsiUtilBase.java:141)
    at com.intellij.psi.util.PsiUtilBase.getPsiFileInEditor(PsiUtilBase.java:123)
    at cursive.editor.ClojureTypedHandler.isStructuralEditingContext(ClojureTypedHandler.java:77)
    at cursive.editor.ClojureTypedHandler.execute(ClojureTypedHandler.java:33)
    at com.intellij.openapi.editor.actionSystem.TypedAction$TypingCommand$1.run(TypedAction.java:129)
    at com.intellij.openapi.application.impl.ApplicationImpl.runWriteAction(ApplicationImpl.java:931)
    at com.intellij.openapi.editor.actionSystem.TypedAction$TypingCommand.run(TypedAction.java:123)
    at com.intellij.openapi.command.impl.CoreCommandProcessor.executeCommand(CoreCommandProcessor.java:124)
    at com.intellij.openapi.editor.actionSystem.TypedAction.actionPerformed(TypedAction.java:107)
    at com.intellij.openapi.editor.impl.EditorImpl.a(EditorImpl.java:1085)
    at com.intellij.openapi.editor.impl.EditorImpl.processKeyTyped(EditorImpl.java:5205)
    at com.intellij.openapi.editor.impl.EditorImpl$10.keyTyped(EditorImpl.java:915)
    at java.awt.Component.processKeyEvent(Component.java:6480)
    at javax.swing.JComponent.processKeyEvent(JComponent.java:2832)
    at java.awt.Component.processEvent(Component.java:6302)
    at java.awt.Container.processEvent(Container.java:2234)
    at java.awt.Component.dispatchEventImpl(Component.java:4881)
    at java.awt.Container.dispatchEventImpl(Container.java:2292)
    at java.awt.Component.dispatchEvent(Component.java:4703)
    at java.awt.KeyboardFocusManager.redispatchEvent(KeyboardFocusManager.java:1954)
    at java.awt.DefaultKeyboardFocusManager.dispatchKeyEvent(DefaultKeyboardFocusManager.java:806)
    at java.awt.DefaultKeyboardFocusManager.preDispatchKeyEvent(DefaultKeyboardFocusManager.java:1074)
    at java.awt.DefaultKeyboardFocusManager.typeAheadAssertions(DefaultKeyboardFocusManager.java:945)
    at java.awt.DefaultKeyboardFocusManager.dispatchEvent(DefaultKeyboardFocusManager.java:771)
    at java.awt.Component.dispatchEventImpl(Component.java:4752)
    at java.awt.Container.dispatchEventImpl(Container.java:2292)
    at java.awt.Window.dispatchEventImpl(Window.java:2750)
    at java.awt.Component.dispatchEvent(Component.java:4703)
    at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:751)
    at java.awt.EventQueue.access$500(EventQueue.java:97)
    at java.awt.EventQueue$3.run(EventQueue.java:702)
    at java.awt.EventQueue$3.run(EventQueue.java:696)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:75)
    at java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:86)
    at java.awt.EventQueue$4.run(EventQueue.java:724)
    at java.awt.EventQueue$4.run(EventQueue.java:722)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:75)
    at java.awt.EventQueue.dispatchEvent(EventQueue.java:721)
    at com.intellij.ide.IdeEventQueue.e(IdeEventQueue.java:734)
    at com.intellij.ide.IdeEventQueue._dispatchEvent(IdeEventQueue.java:539)
    at com.intellij.ide.IdeEventQueue.dispatchEvent(IdeEventQueue.java:382)
    at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:201)
    at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:116)
    at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:105)
    at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:101)
    at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:93)
    at java.awt.EventDispatchThread.run(EventDispatchThread.java:82)

java.lang.AssertionError: PsiWhiteSpace; file: ERbFile:convolo-metrics-api.conf.erb; isvalid: true
    at com.intellij.psi.util.PsiUtilBase.getPsiFileAtOffset(PsiUtilBase.java:147)
    at com.intellij.psi.util.PsiUtilBase.getPsiFileInEditor(PsiUtilBase.java:141)
    at com.intellij.psi.util.PsiUtilBase.getPsiFileInEditor(PsiUtilBase.java:123)
    at cursive.editor.ClojureTypedHandler.isStructuralEditingContext(ClojureTypedHandler.java:77)
    at cursive.editor.ClojureTypedHandler.execute(ClojureTypedHandler.java:33)
    at com.intellij.openapi.editor.actionSystem.TypedAction$TypingCommand$1.run(TypedAction.java:129)
    at com.intellij.openapi.application.impl.ApplicationImpl.runWriteAction(ApplicationImpl.java:931)
    at com.intellij.openapi.editor.actionSystem.TypedAction$TypingCommand.run(TypedAction.java:123)
    at com.intellij.openapi.command.impl.CoreCommandProcessor.executeCommand(CoreCommandProcessor.java:124)
    at com.intellij.openapi.editor.actionSystem.TypedAction.actionPerformed(TypedAction.java:107)
    at com.intellij.openapi.editor.impl.EditorImpl.a(EditorImpl.java:1085)
    at com.intellij.openapi.editor.impl.EditorImpl.processKeyTyped(EditorImpl.java:5205)
    at com.intellij.openapi.editor.impl.EditorImpl$10.keyTyped(EditorImpl.java:915)
    at java.awt.Component.processKeyEvent(Component.java:6480)
    at javax.swing.JComponent.processKeyEvent(JComponent.java:2832)
    at java.awt.Component.processEvent(Component.java:6302)
    at java.awt.Container.processEvent(Container.java:2234)
    at java.awt.Component.dispatchEventImpl(Component.java:4881)
    at java.awt.Container.dispatchEventImpl(Container.java:2292)
    at java.awt.Component.dispatchEvent(Component.java:4703)
    at java.awt.KeyboardFocusManager.redispatchEvent(KeyboardFocusManager.java:1954)
    at java.awt.DefaultKeyboardFocusManager.dispatchKeyEvent(DefaultKeyboardFocusManager.java:806)
    at java.awt.DefaultKeyboardFocusManager.preDispatchKeyEvent(DefaultKeyboardFocusManager.java:1074)
    at java.awt.DefaultKeyboardFocusManager.typeAheadAssertions(DefaultKeyboardFocusManager.java:945)
    at java.awt.DefaultKeyboardFocusManager.dispatchEvent(DefaultKeyboardFocusManager.java:771)
    at java.awt.Component.dispatchEventImpl(Component.java:4752)
    at java.awt.Container.dispatchEventImpl(Container.java:2292)
    at java.awt.Window.dispatchEventImpl(Window.java:2750)
    at java.awt.Component.dispatchEvent(Component.java:4703)
    at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:751)
    at java.awt.EventQueue.access$500(EventQueue.java:97)
    at java.awt.EventQueue$3.run(EventQueue.java:702)
    at java.awt.EventQueue$3.run(EventQueue.java:696)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:75)
    at java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:86)
    at java.awt.EventQueue$4.run(EventQueue.java:724)
    at java.awt.EventQueue$4.run(EventQueue.java:722)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:75)
    at java.awt.EventQueue.dispatchEvent(EventQueue.java:721)
    at com.intellij.ide.IdeEventQueue.e(IdeEventQueue.java:734)
    at com.intellij.ide.IdeEventQueue._dispatchEvent(IdeEventQueue.java:539)
    at com.intellij.ide.IdeEventQueue.dispatchEvent(IdeEventQueue.java:382)
    at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:201)
    at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:116)
    at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:105)
    at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:101)
    at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:93)
    at java.awt.EventDispatchThread.run(EventDispatchThread.java:82)
cursive-ide commented 9 years ago

All those exceptions are Cursive trying to work out if it's a Clojure file so it can leave it alone. It's very strange. Is the Ruby project open source?

conan commented 9 years ago

No, it's our internal chef stuff I'm afraid. The file is a template of an EDN file, though.

conan commented 9 years ago

It's stuff that looks like:

{:port <%= node.api[:apiPort] %>}

It actually contains more keys with more chef attributes and variables, but I can't paste it here, sorry.

cursive-ide commented 9 years ago

Ok, do you know of an open source chef project I could try to reproduce it on?

conan commented 9 years ago

Ah OK, I think I've figured it out. These files are chef template files, which mean they're used as the basis for other files - in this case, configuration files ending .conf. I can reproduce the problem by creating a new file (anywhere, even in an existing Clojure project) that contains .conf.erb in its filename (I guess it's because I have *.conf associated with Clojure editors). Make the file look like an EDN file but with a chef attribute, for example:

{:hi <%= @there %>}

What I don't get is why *.conf matches something like test.conf.erb and tries to bring in Cursive.

conan commented 9 years ago

(I've got the Ruby plugin and Chef integration plugin installed)

conan commented 9 years ago

The upshot is that it's caused by the fact that I have .conf files associated with Clojure, so it won't happen for people that don't have weird associations like that. That said, it doesn't seem like such a crazy thing to do - working with EDN files and wanting to use Cursive's excellent tooling for them, too.

cursive-ide commented 9 years ago

Yeah, that sounds like a reasonable thing to do. I'll try to reproduce based on that description, thanks. You're right that *.conf shouldn't match *.conf.erb - I don't know what's up with that. It sounds like IntelliJ might be getting confused there somehow.

conan commented 9 years ago

I'll see if I can find a workaround in the File Types and post back here if I do.