Generate toString plugin NPE

No message
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:306)
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:92)
at com.intellij.openapi.command.impl.CommandProcessorImpl.executeCommand(CommandProcessorImpl.java:64)
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:12)
at com.intellij.ui.ListPopup.closePopup(ListPopup.java:106)
at com.intellij.ui.ListPopup$2.keyTyped(ListPopup.java:6)
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:101)
at com.intellij.ide.IdeEventQueue.a(IdeEventQueue.java:26)
at com.intellij.ide.IdeEventQueue.dispatchEvent(IdeEventQueue.java:148)
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)

6 comments
Comment actions Permalink

I will look into it later tonight.

What version of the plugin are you using? I assume the latest released.

/Claus

0
Comment actions Permalink

yes it was latest version.
btw, error occured on EAP version (also latest one)

0
Comment actions Permalink

The problem is that your template is not compatible with this new version.

You either have to fix your template by adding this to the top:

public String toString() {

And adding and ending } at the end of your template.

Or upgrade from a fresh by uninstalling the plugin, starting IDEA without this plugin and installing the plugin again.


- Note: Templates supported in this version is not compatible with plugin v3.00 or older. To upgrade:
1) Uninstall plugin, 2) Start IDEA without this plugin, 3) Install plugin, 4) Restart IDEA

0
Comment actions Permalink

I'll try that,
thanks

0
Comment actions Permalink

Did it work?

In a future version I have added a validation for template compability that will give a warning if method signature and enclosing { } is missing.

The new template syntax is just as you would write the code in java.

1) You can have javadoc in top.
2) Method declaration
3) Method body

/**

  • This is javadoc for $classname

*/
public String toString() {
// HERE IS TEMPLATE CODE
}


/Claus

0
Comment actions Permalink

yup..reinstalling did the trick..

btw, I got an exception though because my template wasn't ok..after recreating it everything works fine, thanks..


Stacktrace for invalid template:

--
Encountered "#else\r\n" at line 18, column 1.
Was expecting one of:
"(" ... ... ... ]]> ...
"

" ...
"
" ...
... ... "*#" ... "*#" ... ... "if" ... "stop" ... ... ... ... ... "{" ... "}" ... org.intellij.idea.plugin.tostring.exception.GenerateCodeException: Encountered "#else\r\n" at line 18, column 1. Was expecting one of: "(" ... ... ... ]]> ...
"

" ...
"
" ...
... ... "*#" ... "*#" ... ... "if" ... "stop" ... ... ... ... ... "{" ... "}" ... at org.intellij.idea.plugin.tostring.GenerateToStringActionHandler.velocityGenerateCode(GenerateToStringActionHandler.java:459) at org.intellij.idea.plugin.tostring.GenerateToStringActionHandler.createToStringMethod(GenerateToStringActionHandler.java:316) at org.intellij.idea.plugin.tostring.GenerateToStringActionHandler.executeGenerateAction(GenerateToStringActionHandler.java:237) at org.intellij.idea.plugin.tostring.GenerateToStringActionHandler.access$400(GenerateToStringActionHandler.java:40) at org.intellij.idea.plugin.tostring.GenerateToStringActionHandler$3.run(GenerateToStringActionHandler.java:254) at com.intellij.openapi.application.impl.ApplicationImpl.runWriteAction(ApplicationImpl.java:5) at org.intellij.idea.plugin.tostring.GenerateToStringActionHandler$2.run(GenerateToStringActionHandler.java:251) at com.intellij.openapi.command.impl.CommandProcessorImpl.executeCommand(CommandProcessorImpl.java:34) at com.intellij.openapi.command.impl.CommandProcessorImpl.executeCommand(CommandProcessorImpl.java:13) at org.intellij.idea.plugin.tostring.psi.idea4.PsiAdapterIdea4.executeCommand(PsiAdapterIdea4.java:124) at org.intellij.idea.plugin.tostring.GenerateToStringActionHandler.executeGenerateActionLater(GenerateToStringActionHandler.java:263) at org.intellij.idea.plugin.tostring.GenerateToStringActionHandler.access$000(GenerateToStringActionHandler.java:40) at org.intellij.idea.plugin.tostring.GenerateToStringActionHandler$1.run(GenerateToStringActionHandler.java:147) at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:178) at java.awt.EventQueue.dispatchEvent(EventQueue.java:454) at com.intellij.ide.IdeEventQueue.defaultDispatchEvent(IdeEventQueue.java:158) at com.intellij.ide.IdeEventQueue.a(IdeEventQueue.java:45) at com.intellij.ide.IdeEventQueue.dispatchEvent(IdeEventQueue.java:122) 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) Caused by: org.apache.velocity.exception.ParseErrorException: Encountered "#else\r\n" at line 18, 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.velocityGenerateCode(GenerateToStringActionHandler.java:446)
... 22 more


0

Please sign in to leave a comment.