[ANN] - Generate toString() v2.14 released

v2.14 of the toString() plugin has been released at the offical homepage for this plugin at:

http://www.intellij.org/twiki/bin/view/Main/ToStringPlugin

Or using the pluginmanager from within IDEA 4.x.

This version supports the new EAP build 2013, IDEA 4.x and IDEA 3.x as well (not compiled for this yet, but v2.12 is avail for 3.x).

For a release supporting IDEA 3.x download it from the official homepage. The IDEA pluginmanager is only a feature in IDEA 4.x.


About the plugin
================
GenerateToString is a action plugin for IDEA that is used to create or update java classes toString() method. The reason is valuebeans usually needs to dump their fieldvalues for debug purpose, and it's tedious to write the dump code for this. So this action plugin generates the code to dump all the fields in a simple manner.

v2.14 for IDEA 3.x/4.x (apr-26-2004)
====================================
- Compiled with IDEA EAP build 2013 (Pallada)
- FieldNotUsedInToString inspection is now aware of reflection based toString implementations and therefore does not generate a warning for fields not used
- Fixed NPE in FieldNotUsedInToString for IDEA (build 2004) wrongly reports a public void method as a field type.
- Logging added to inspection
- Exclude static fields now default set to true
- If cancel resolution policy used then auto import packages etc. are not executed (leaving all code as it is before)
- Feature to add javadoc to toString() method. Insert javadoc block comment in top of veloctiy macro (see javadoc template example)
http://www.intellij.net/forums/thread.jsp?forum=18&thread=84711&tstart=0&trange=15
- Javadoc is not replaced if the already exists a javadoc for the toString() method
- Template selection dropdown now displays up to 20 templates without using scrollbar
- Settings to enable/disalbe on-the-fly code inspection (on-the-fly is disabled by default)
- Fixed NPE when enabling/disabling action in code/editor menus before having used the action


/Claus, the author

5 comments
Comment actions Permalink

Hmmm. I'm having a hard time getting that to work. The
configuration panel doesn't seem to be doing/saving what
it's telling or showing me and toString() either doesn't use
my changes or throws bad exceptions.

I activated the javadoc template, copy/pasted the javadoc,
reactivated the "default concat" template, pasted the javadoc
before the two return statements, applied and when I tried to
generate toString() I got a massive Velocity error (see below).

One comment about the configuration: when I bring up
my IDE settings panel (Classic View) and the last opened
tab was the toString configuration panel, I always get
two dialogs
"The page has been modified. Save changes made on this page?
which obviously doesn't make much sense as the configuration
panel is not even showing up yet.

Now for the massive velocity stacktrace:

"(" ... ... ... ... "\\\\" ... "\\" ... ... ... "*#" ... "*#" ... ... "if" ... "stop" ... ... ... ... ... "{" ... "}" ... at org.intellij.idea.plugin.tostring.GenerateToStringActionHandler.generateMeth odBody(GenerateToStringActionHandler.java:402) at org.intellij.idea.plugin.tostring.GenerateToStringActionHandler.createToStri ngMethod(GenerateToStringActionHandler.java:268) at org.intellij.idea.plugin.tostring.GenerateToStringActionHandler.executeGener ateAction(GenerateToStringActionHandler.java:161) at org.intellij.idea.plugin.tostring.GenerateToStringActionHandler.access$400(G enerateToStringActionHandler.java:40) at org.intellij.idea.plugin.tostring.GenerateToStringActionHandler$3.run(Genera teToStringActionHandler.java:178) at com.intellij.openapi.application.a.b.runWriteAction(b.java:299) at org.intellij.idea.plugin.tostring.GenerateToStringActionHandler$2.run(Genera teToStringActionHandler.java:175) at com.intellij.openapi.command.impl.a.executeCommand(a.java:94) at org.intellij.idea.plugin.tostring.psi.idea4.PsiAdapterIdea4.executeCommand(P siAdapterIdea4.java:135) at org.intellij.idea.plugin.tostring.GenerateToStringActionHandler.executeGener ateActionLater(GenerateToStringActionHandler.java:187) at org.intellij.idea.plugin.tostring.GenerateToStringActionHandler.access$000(G enerateToStringActionHandler.java:40) at org.intellij.idea.plugin.tostring.GenerateToStringActionHandler$1.run(Genera teToStringActionHandler.java:107) at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:178) at java.awt.EventQueue.dispatchEvent(EventQueue.java:454) at com.intellij.ide.q.b(q.java:36) at com.intellij.ide.q.a(q.java:136) at com.intellij.ide.q.dispatchEvent(q.java:48) at java.awt.EventDispatchThread.pumpOneEventForHierarchy(EventDispatchThread.ja va:201) at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java :151) at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:145) at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:137) at java.awt.EventDispatchThread.run(EventDispatchThread.java:100) Caused by: org.apache.velocity.exception.ParseErrorException: Encountered "#else\r\n" at line 19, column 1. Was expecting one of: "(" ... ... ... ... "\\\\" ... "\\" ... ... ... "*#" ... "*#" ... ... "if" ... "stop" ... ... ... ... ... "{" ... "}" ... at org.apache.velocity.app.VelocityEngine.evaluate(VelocityEngine.java:328) at org.apache.velocity.app.VelocityEngine.evaluate(VelocityEngine.java:252) at org.intellij.idea.plugin.tostring.GenerateToStringActionHandler.generateMeth odBody(GenerateToStringActionHandler.java:388) ... 21 more [ 149920] ERROR - .GenerateToStringActionHandler - org.intellij.idea.plugin.tostring.exception.GenerateCodeException: Encountered "#else\r\n" at line 19, column 1. Was expecting one of: "(" ... ... ... ... "\\\\" ... "\\" ... ... ... "*#" ... "*#" ... ... "if" ... "stop" ... ... ... ... ... "{" ... "}" ... at org.intellij.idea.plugin.tostring.GenerateToStringActionHandler.generateMeth odBody(GenerateToStringActionHandler.java:402) at org.intellij.idea.plugin.tostring.GenerateToStringActionHandler.createToStri ngMethod(GenerateToStringActionHandler.java:268) at org.intellij.idea.plugin.tostring.GenerateToStringActionHandler.executeGener ateAction(GenerateToStringActionHandler.java:161) at org.intellij.idea.plugin.tostring.GenerateToStringActionHandler.access$400(G enerateToStringActionHandler.java:40) at org.intellij.idea.plugin.tostring.GenerateToStringActionHandler$3.run(Genera teToStringActionHandler.java:178) at com.intellij.openapi.application.a.b.runWriteAction(b.java:299) at org.intellij.idea.plugin.tostring.GenerateToStringActionHandler$2.run(Genera teToStringActionHandler.java:175) at com.intellij.openapi.command.impl.a.executeCommand(a.java:94) at org.intellij.idea.plugin.tostring.psi.idea4.PsiAdapterIdea4.executeCommand(P siAdapterIdea4.java:135) at org.intellij.idea.plugin.tostring.GenerateToStringActionHandler.executeGener ateActionLater(GenerateToStringActionHandler.java:187) at org.intellij.idea.plugin.tostring.GenerateToStringActionHandler.access$000(G enerateToStringActionHandler.java:40) at org.intellij.idea.plugin.tostring.GenerateToStringActionHandler$1.run(Genera teToStringActionHandler.java:107) at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:178) at java.awt.EventQueue.dispatchEvent(EventQueue.java:454) at com.intellij.ide.q.b(q.java:36) at com.intellij.ide.q.a(q.java:136) at com.intellij.ide.q.dispatchEvent(q.java:48) at java.awt.EventDispatchThread.pumpOneEventForHierarchy(EventDispatchThread.ja va:201) at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java :151) at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:145) at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:137) at java.awt.EventDispatchThread.run(EventDispatchThread.java:100) Caused by: org.apache.velocity.exception.ParseErrorException: Encountered "#else\r\n" at line 19, column 1. Was expecting one of: "(" ... ... ... ... "\\\\" ... "\\" ... ... ... "*#" ... "*#" ... ... "if" ... "stop" ... ... ... ... ... "{" ... "}" ... at org.apache.velocity.app.VelocityEngine.evaluate(VelocityEngine.java:328) at org.apache.velocity.app.VelocityEngine.evaluate(VelocityEngine.java:252) at org.intellij.idea.plugin.tostring.GenerateToStringActionHandler.generateMeth odBody(GenerateToStringActionHandler.java:388) ... 21 more ]]>


Good luck! :

Vince.


0
Comment actions Permalink

Hi Vince

Could you try the syntax checker button in the settings when you edit your template code.

There is something wrong at:
"#else\r\n" at line 19, column 1.

It seems there is a Veloctiy token missing
#end
#else

or something similar.

Have you just tried the simple javadoc template? Does it work?


/Claus


PS: About the changed page. It can be caused by my plugin always return try in an apply() method. I will look into it.

0
Comment actions Permalink

Anyone else having trouble making the javadoc working?

/Claus

0
Comment actions Permalink

I will try to see if something was wrong with my template itself. I usually
use the syntax checker button before I try things out but I might have
skipped it this time around.

The simple javadoc template worked (after I activated it, applied and
restarted IDEA) but couldn't get it to do anything useful as I couldn't
modify it.

I think I was just getting confused with toString not wanting to simply take
into account the changes I would make in the configuration. I would expect
to be able to bring up the config panel, modify the active template, press
"Apply" and have toString used the modified template from now on but that
just doesn't work. (Note that I've saved my template in the past, maybe that
complicates things).

Thanks,

Vince.


0
Comment actions Permalink

Yes it is a little confusing have you can change the templates.

Only the current active is changeable. All the others are read-only to browse. If you want to use a read-only template as a starting point you have to activate it FIRST then do the changes. And finally APPLY the changes with the IDEA button.


/Claus

0

Please sign in to leave a comment.