NPE in GenerateToString plugin

I uninstalled, shut down and then re-installed the toString plugin, but
I'm still getting this exception (plugin v3.13, Irida build 3290)
R

java.lang.NullPointerException
at
org.intellij.idea.plugin.tostring.template.TemplateResource.getMethodBody(TemplateResource.java:68)
at
org.intellij.idea.plugin.tostring.GenerateToStringActionHandler.displayMememberChooser(GenerateToStringActionHandler.java:205)
at
org.intellij.idea.plugin.tostring.GenerateToStringActionHandler.doExecuteAction(GenerateToStringActionHandler.java:132)
at
org.intellij.idea.plugin.tostring.GenerateToStringActionHandler.executeWriteAction(GenerateToStringActionHandler.java:68)
at
com.intellij.openapi.editor.actionSystem.EditorWriteActionHandler$1.run(EditorWriteActionHandler.java:39)
at
com.intellij.openapi.application.impl.ApplicationImpl.runWriteAction(ApplicationImpl.java:70)
at
com.intellij.openapi.editor.actionSystem.EditorWriteActionHandler.execute(EditorWriteActionHandler.java:23)
at
com.intellij.openapi.editor.actionSystem.EditorAction$1.run(EditorAction.java:40)
at
com.intellij.openapi.command.impl.CommandProcessorImpl.executeCommand(CommandProcessorImpl.java:85)
at
com.intellij.openapi.command.impl.CommandProcessorImpl.executeCommand(CommandProcessorImpl.java:24)
at
com.intellij.openapi.editor.actionSystem.EditorAction.actionPerformed(EditorAction.java:46)
at
com.intellij.openapi.editor.actionSystem.EditorAction.actionPerformed(EditorAction.java:31)
at
com.intellij.openapi.actionSystem.ex.ActionListPopup$1.run(ActionListPopup.java:4)
at com.intellij.ui.ListPopup.closePopup(ListPopup.java:87)
at com.intellij.ui.ListPopup$2.keyTyped(ListPopup.java:5)
at java.awt.AWTEventMulticaster.keyTyped(AWTEventMulticaster.java:182)
at java.awt.Component.processKeyEvent(Component.java:5055)
at javax.swing.JComponent.processKeyEvent(JComponent.java:2388)
at java.awt.Component.processEvent(Component.java:4909)
at java.awt.Container.processEvent(Container.java:1569)
at java.awt.Component.dispatchEventImpl(Component.java:3615)
at java.awt.Container.dispatchEventImpl(Container.java:1627)
at java.awt.Component.dispatchEvent(Component.java:3477)
at
java.awt.KeyboardFocusManager.redispatchEvent(KeyboardFocusManager.java:1713)
at
java.awt.DefaultKeyboardFocusManager.dispatchKeyEvent(DefaultKeyboardFocusManager.java:627)
at
java.awt.DefaultKeyboardFocusManager.preDispatchKeyEvent(DefaultKeyboardFocusManager.java:831)
at
java.awt.DefaultKeyboardFocusManager.typeAheadAssertions(DefaultKeyboardFocusManager.java:741)
at
java.awt.DefaultKeyboardFocusManager.dispatchEvent(DefaultKeyboardFocusManager.java:592)
at java.awt.Component.dispatchEventImpl(Component.java:3506)
at java.awt.Container.dispatchEventImpl(Container.java:1627)
at java.awt.Window.dispatchEventImpl(Window.java:1606)
at java.awt.Component.dispatchEvent(Component.java:3477)
at java.awt.EventQueue.dispatchEvent(EventQueue.java:456)
at
com.intellij.ide.IdeEventQueue.defaultDispatchEvent(IdeEventQueue.java:90)
at com.intellij.ide.IdeEventQueue.a(IdeEventQueue.java:24)
at com.intellij.ide.IdeEventQueue.dispatchEvent(IdeEventQueue.java:149)
at
java.awt.EventDispatchThread.pumpOneEventForHierarchy(EventDispatchThread.java: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)

7 comments
Comment actions Permalink

Yeah, I saw that already, but I tried uninstalling and reinstalling as
suggested in the thread and I'm still getting this. Where is the
template stored so that I can try manually resetting it?
R

0
Comment actions Permalink

You have to have stated IDEA without the plugin so it will be completely removed.

You can always go to Settings -> toString and change your current active template to one of the default templates as they should work with the new template syntax.

Hope that helps.

If not let me know.

Claus (author of the plugin)

0
Comment actions Permalink

1) Removed plugin from Plugins list
2) Restarted - saw the "deleting" message in the console
3) Restarted again - no mention of any actions
4) Installed plugin
5) Restarted - saw "copy/delete" messages
6) Tried to generate toString - got the exception I posted previously

Here is what is being proposed for a template:

public String toString() {
#if ( $members.size() > 0 )
#set ( $i = 0 )
return "$classname{" +
#foreach( $member in $members )
#if ( $i == 0 )
"##
#else
", ##
#end
#if ( $member.objectArray )
$member.name=" + ($member.accessor == null ? null :
Arrays.asList($member.accessor)) +
#elseif ( $member.string )
$member.name='" + $member.accessor + "'" +
#else
$member.name=" + $member.accessor +
#end
#set ( $i = $i + 1 )
#end
"}";
#else
return "$classname{}";
#end
}

Claus Ibsen wrote:

You have to have stated IDEA without the plugin so it will be completely removed.

You can always go to Settings -> toString and change your current active template to one of the default templates as they should work with the new template syntax.

Hope that helps.

If not let me know.

Claus (author of the plugin)

0
Comment actions Permalink

Bug report:
- When I select a Template in the Edit Template dialog box and then hit
OK, the template is not applied. That's dubious, I think OK should
automatically apply the template. Cancel would un-apply it.
- If I hit OK without applying the template, the NEXT time I open the
Settings box I get "This page has changed, do you want to save the
settings?"

Anyway, I chose the default using String concat, applied the template,
confirmed that I definitely wanted to use it and everything works fine
now, thanks. (You should probably add a StringBuilder default as well,
right?)

Thanks a lot,
R

0
Comment actions Permalink

Hi Robert

Glad you got it to work after all. It's not supposed to be so troublesome, but what knows this new format would bring of new features in the future - generating other methods than toString().

There should be a default StringBuffer template also, isn't it there?

I can't actually remember what is the latest version of the plugin - you use it right?


- When I select a Template in the Edit Template dialog box and then hit
OK, the template is not applied. That's dubious, I think OK should
automatically apply the template. Cancel would un-apply it.

Yeah there could be a warning when you exit that the current template isn't applied. I'll put it on the todo list for a future release.

0
Comment actions Permalink

Glad you got it to work after all. It's not supposed to be so troublesome, but what knows this new format would bring of new features in the future - generating other methods than toString().


New features, great - new bugs, not great ;)
Once I got it working I uninstalled it and installed it again. Sure
enough, the default config is crashing. You might want to check the
default that's installed when somebody installs for the first time.

> There should be a default StringBuffer template also, isn't it there?

StringBuffer, yes. StringBuilder (new JDK 5.0 class, unsynchronised
version of StringBuffer), no.

> I can't actually remember what is the latest version of the plugin -
you use it right?

Yep, using version 3.13

Thanks for your work!
R

0

Please sign in to leave a comment.