Generate toString() not working

Hi all,

It seems like everything I try wants to break.... I tried to generate a toString() for my Grails domain classes, but when I do that, I get an error message, that I should check my idea.log. I searched for 15 minutes, but then I found out that with 'idea.log' you probably mean 'the console', which makes ofcourse a lot of sense....

Anyway, this is the error reported there:

11/19/08 6:50:09 AM idea[6134] Exception raised during posting of notification. Ignored. exception: 'Menu to be set as submenu is already a submenu of some menu.' invoked observer method: '*** -[CWindow windowDidBecomeKey:]' observer: 0x1e57f0 notification name: 'NSWindowDidBecomeKeyNotification'
11/19/08 6:50:09 AM idea[6134] *** Assertion failure in -[NSMenuItem setSubmenu:], /SourceCache/AppKit/AppKit-949.35/Menus.subproj/NSMenuItem.m:631
11/19/08 6:50:09 AM idea[6134] Exception raised during posting of notification. Ignored. exception: 'Menu to be set as submenu is already a submenu of some menu.' invoked observer method: '*** -[CWindow windowDidBecomeKey:]' observer: 0x11c40340 notification name: 'NSWindowDidBecomeKeyNotification'
11/19/08 6:50:09 AM .com.jetbrains.intellij[6134] java.lang.ClassCastException: org.jetbrains.plugins.groovy.lang.psi.impl.GroovyFileImpl
11/19/08 6:50:09 AM .com.jetbrains.intellij[6134] at org.jetbrains.generate.tostring.GenerateToStringWorker.]]>(GenerateToStringWorker.java:53)
11/19/08 6:50:09 AM .com.jetbrains.intellij[6134] at org.jetbrains.generate.tostring.GenerateToStringWorker$1$1.run(GenerateToStringWorker.java:350)
11/19/08 6:50:09 AM .com.jetbrains.intellij[6134] at com.intellij.openapi.application.impl.ApplicationImpl.runWriteAction(ApplicationImpl.java:236)
11/19/08 6:50:09 AM .com.jetbrains.intellij[6134] at org.jetbrains.generate.tostring.GenerateToStringWorker$1.run(GenerateToStringWorker.java:347)
11/19/08 6:50:09 AM .com.jetbrains.intellij[6134] at com.intellij.openapi.command.impl.CommandProcessorImpl.executeCommand(CommandProcessorImpl.java:2)
11/19/08 6:50:09 AM .com.jetbrains.intellij[6134] at com.intellij.openapi.command.impl.CommandProcessorImpl.executeCommand(CommandProcessorImpl.java:100)
11/19/08 6:50:09 AM .com.jetbrains.intellij[6134] at com.intellij.openapi.command.impl.CommandProcessorImpl.executeCommand(CommandProcessorImpl.java:52)
11/19/08 6:50:09 AM .com.jetbrains.intellij[6134] at org.jetbrains.generate.tostring.psi.PsiAdapter.executeCommand(PsiAdapter.java:1150)
11/19/08 6:50:09 AM .com.jetbrains.intellij[6134] at org.jetbrains.generate.tostring.GenerateToStringWorker.executeGenerateActionLater(GenerateToStringWorker.java:359)
11/19/08 6:50:09 AM .com.jetbrains.intellij[6134] at org.jetbrains.generate.tostring.GenerateToStringActionHandlerImpl$1.run(GenerateToStringActionHandlerImpl.java:112)
11/19/08 6:50:09 AM .com.jetbrains.intellij[6134] at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:209)
11/19/08 6:50:09 AM .com.jetbrains.intellij[6134] at java.awt.EventQueue.dispatchEvent(EventQueue.java:461)
11/19/08 6:50:09 AM .com.jetbrains.intellij[6134] at com.intellij.ide.IdeEventQueue.c(IdeEventQueue.java:35)
11/19/08 6:50:09 AM .com.jetbrains.intellij[6134] at com.intellij.ide.IdeEventQueue.b(IdeEventQueue.java:99)
11/19/08 6:50:09 AM .com.jetbrains.intellij[6134] at com.intellij.ide.IdeEventQueue.dispatchEvent(IdeEventQueue.java:217)
11/19/08 6:50:09 AM .com.jetbrains.intellij[6134] at java.awt.EventDispatchThread.pumpOneEventForHierarchy(EventDispatchThread.java:269)
11/19/08 6:50:09 AM .com.jetbrains.intellij[6134] at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:190)
11/19/08 6:50:09 AM .com.jetbrains.intellij[6134] at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:184)
11/19/08 6:50:09 AM .com.jetbrains.intellij[6134] at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:176)
11/19/08 6:50:09 AM .com.jetbrains.intellij[6134] at java.awt.EventDispatchThread.run(EventDispatchThread.java:110)
11/19/08 6:50:13 AM idea[6134] *** Assertion failure in -[NSMenuItem setSubmenu:], /SourceCache/AppKit/AppKit-949.35/Menus.subproj/NSMenuItem.m:631

Erik

2 comments
Comment actions Permalink

Hello Erik,

Actually "Generate toString()" was never supposed to work for Groovy, but
fortunately it turned out to be fairly easy to fix it so that it does work.
The code it generates is far from idiomatic Groovy, though.

It seems like everything I try wants to break.... I tried to generate
a toString() for my Grails domain classes, but when I do that, I get
an error message, that I should check my idea.log. I searched for 15
minutes, but then I found out that with 'idea.log' you probably mean
'the console', which makes ofcourse a lot of sense....

Anyway, this is the error reported there:

11/19/08 6:50:09 AM idea[6134] Exception raised during posting of
notification. Ignored. exception: 'Menu to be set as submenu is
already a submenu of some menu.' invoked observer method: '***
-[CWindow windowDidBecomeKey:]' observer: 0x1e57f0 notification
name: 'NSWindowDidBecomeKeyNotification' 11/19/08 6:50:09 AM
idea[6134] *** Assertion failure in -[NSMenuItem setSubmenu:],
/SourceCache/AppKit/AppKit-949.35/Menus.subproj/NSMenuItem.m:631
11/19/08 6:50:09 AM idea[6134] Exception raised during posting of
notification. Ignored. exception: 'Menu to be set as submenu is
already a submenu of some menu.' invoked observer method: '***
-[CWindow windowDidBecomeKey:]' observer: 0x11c40340 notification
name: 'NSWindowDidBecomeKeyNotification' 11/19/08 6:50:09 AM
.com.jetbrains.intellij[6134]
java.lang.ClassCastException:
org.jetbrains.plugins.groovy.lang.psi.impl.GroovyFileImpl 11/19/08
6:50:09 AM .com.jetbrains.intellij[6134] at
org.jetbrains.generate.tostring.GenerateToStringWorker.<init>(Generate
ToStringWorker.java:53) 11/19/08 6:50:09 AM
.com.jetbrains.intellij[6134] at
org.jetbrains.generate.tostring.GenerateToStringWorker$1$1.run(Generat
eToStringWorker.java:350) 11/19/08 6:50:09 AM
.com.jetbrains.intellij[6134] at
com.intellij.openapi.application.impl.ApplicationImpl.runWriteAction(A
pplicationImpl.java:236) 11/19/08 6:50:09 AM
.com.jetbrains.intellij[6134] at
org.jetbrains.generate.tostring.GenerateToStringWorker$1.run(GenerateT
oStringWorker.java:347) 11/19/08 6:50:09 AM
.com.jetbrains.intellij[6134] at
com.intellij.openapi.command.impl.CommandProcessorImpl.executeCommand(
CommandProcessorImpl.java:2) 11/19/08 6:50:09 AM
.com.jetbrains.intellij[6134] at
com.intellij.openapi.command.impl.CommandProcessorImpl.executeCommand(
CommandProcessorImpl.java:100) 11/19/08 6:50:09 AM
.com.jetbrains.intellij[6134] at
com.intellij.openapi.command.impl.CommandProcessorImpl.executeCommand(
CommandProcessorImpl.java:52) 11/19/08 6:50:09 AM
.com.jetbrains.intellij[6134] at
org.jetbrains.generate.tostring.psi.PsiAdapter.executeCommand(PsiAdapt
er.java:1150) 11/19/08 6:50:09 AM
.com.jetbrains.intellij[6134] at
org.jetbrains.generate.tostring.GenerateToStringWorker.executeGenerate
ActionLater(GenerateToStringWorker.java:359) 11/19/08 6:50:09 AM
.com.jetbrains.intellij[6134] at
org.jetbrains.generate.tostring.GenerateToStringActionHandlerImpl$1.ru
n(GenerateToStringActionHandlerImpl.java:112) 11/19/08 6:50:09 AM
.com.jetbrains.intellij[6134] at
java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:209)
11/19/08 6:50:09 AM .com.jetbrains.intellij[6134] at
java.awt.EventQueue.dispatchEvent(EventQueue.java:461) 11/19/08
6:50:09 AM .com.jetbrains.intellij[6134] at
com.intellij.ide.IdeEventQueue.c(IdeEventQueue.java:35) 11/19/08
6:50:09 AM .com.jetbrains.intellij[6134] at
com.intellij.ide.IdeEventQueue.b(IdeEventQueue.java:99) 11/19/08
6:50:09 AM .com.jetbrains.intellij[6134] at
com.intellij.ide.IdeEventQueue.dispatchEvent(IdeEventQueue.java:217)
11/19/08 6:50:09 AM .com.jetbrains.intellij[6134] at
java.awt.EventDispatchThread.pumpOneEventForHierarchy(EventDispatchThr
ead.java:269) 11/19/08 6:50:09 AM
.com.jetbrains.intellij[6134] at
java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThrea
d.java:190) 11/19/08 6:50:09 AM
.com.jetbrains.intellij[6134] at
java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:184)
11/19/08 6:50:09 AM .com.jetbrains.intellij[6134] at
java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:176)
11/19/08 6:50:09 AM .com.jetbrains.intellij[6134] at
java.awt.EventDispatchThread.run(EventDispatchThread.java:110)
11/19/08 6:50:13 AM idea[6134] *** Assertion failure in -[NSMenuItem
setSubmenu:],
/SourceCache/AppKit/AppKit-949.35/Menus.subproj/NSMenuItem.m:631

Erik

--
Dmitry Jemerov
Development Lead
JetBrains, Inc.
http://www.jetbrains.com/
"Develop with Pleasure!"


0
Comment actions Permalink

Hmm, is not an idea to have a option to generate something like:

String toString() {
"${var1} $ $"
}

??

Or would that be to hard? Ps, what happens now if you do a toString in a Groovy class, or Groovy script??

0

Please sign in to leave a comment.