[Ann]GenerateCollectionMethods plugin 1.0 released


As a break from going slowly insane doing InspectionGadget performance optimizations, I coded up a simple code generation plugin last night instead. It's called GenerateCollectionMethods, and is available via the PluginManager. GenerateCollectionMethods adds two commands to the Alt-Ins code generation menu: "Collection Methods" and "Array Methods". These act much like the "getter and setter" code generation command, except that the methods created don't break encapsulation of array and collection fields. For a collection field named "bars", the plugin will generate methods "addBar", "removeBar" and "getBars" (which returns a safe copy of the field, if possible). Similarly for an array field named "foos", the plugin will generate methods "getFooAt", "setFooAt" and "getFoos". This makes it as easy to create collection and array accessor methods as it is to create setters and getters.

GenerateCollectionMethods is available for any use, commercial or non-commercial, including (as always) inclusion into the IDEA product. GenerateCollectionMethods has only been tested against the Irida EAP. Let me know if you have any difficulties, comments, or suggestions with this plugin.

--Dave Griffith

2 comments
Comment actions Permalink

Ctrl-Click in VF XHTML design view.
( => the file type is xhtml, not java)

java.lang.NullPointerException
at
com.siyeh.gcm.GenerateArrayMethodsAction.update(GenerateArrayMethodsAction.java:29)
at
com.intellij.openapi.editor.actionSystem.EditorAction.update(EditorAction.java:60)
at
com.intellij.openapi.actionSystem.ex.ActionListPopup.isGroupEmpty(ActionListPopup.java:35)
at
com.intellij.codeInsight.generation.actions.GenerateAction.update(GenerateAction.java:6)
at
com.intellij.openapi.actionSystem.impl.Utils.expandActionGroup(Utils.java:24)
at com.intellij.openapi.actionSystem.impl.Utils.fillMenu(Utils.java:8)
at
com.intellij.openapi.actionSystem.impl.ActionPopupMenuImpl$MyMenu.show(ActionPopupMenuImpl.java:49)
at
jetbrains.fabrique.ide.web.xhtmlView.XhtmlView$XhtmlViewMouseListener.invokePopup(XhtmlView.java:468)
at com.intellij.util.EditorPopupHandler.a(EditorPopupHandler.java:8)
at
com.intellij.util.EditorPopupHandler.mousePressed(EditorPopupHandler.java:6)
at com.intellij.openapi.editor.impl.EditorImpl.a(EditorImpl.java:276)
at
com.intellij.openapi.editor.impl.EditorImpl.access$6000(EditorImpl.java:832)
at
com.intellij.openapi.editor.impl.EditorImpl$MyMouseAdapter.mousePressed(EditorImpl.java:14)
at
java.awt.AWTEventMulticaster.mousePressed(AWTEventMulticaster.java:222)
at java.awt.Component.processMouseEvent(Component.java:5163)
at java.awt.Component.processEvent(Component.java:4963)
at java.awt.Container.processEvent(Container.java:1613)
at java.awt.Component.dispatchEventImpl(Component.java:3681)
at java.awt.Container.dispatchEventImpl(Container.java:1671)
at java.awt.Component.dispatchEvent(Component.java:3543)
at
java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:3527)
at java.awt.LightweightDispatcher.processMouseEvent(Container.java:3239)
at java.awt.LightweightDispatcher.dispatchEvent(Container.java:3172)
at java.awt.Container.dispatchEventImpl(Container.java:1657)
at java.awt.Window.dispatchEventImpl(Window.java:1606)
at java.awt.Component.dispatchEvent(Component.java:3543)
at java.awt.EventQueue.dispatchEvent(EventQueue.java:456)
at
com.intellij.ide.IdeEventQueue.defaultDispatchEvent(IdeEventQueue.java:104)
at com.intellij.ide.IdeEventQueue.a(IdeEventQueue.java:23)
at com.intellij.ide.IdeEventQueue.dispatchEvent(IdeEventQueue.java:111)
at
java.awt.EventDispatchThread.pumpOneEventForHierarchy(EventDispatchThread.java:234)
at
java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:184)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:178)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:170)
at java.awt.EventDispatchThread.run(EventDispatchThread.java:100)



java.lang.NullPointerException
at
com.siyeh.gcm.GenerateArrayMethodsAction.update(GenerateArrayMethodsAction.java:29)
at
com.intellij.openapi.editor.actionSystem.EditorAction.update(EditorAction.java:60)
at
com.intellij.openapi.actionSystem.ex.ActionListPopup.isGroupEmpty(ActionListPopup.java:35)
at
com.intellij.codeInsight.generation.actions.GenerateAction.update(GenerateAction.java:6)
at
com.intellij.openapi.actionSystem.impl.Utils.expandActionGroup(Utils.java:24)
at com.intellij.openapi.actionSystem.impl.Utils.fillMenu(Utils.java:8)
at
com.intellij.openapi.actionSystem.impl.ActionPopupMenuImpl$MyMenu$MyPopupMenuListener.popupMenuWillBecomeVisible(ActionPopupMenuImpl.java:4)
at
javax.swing.JPopupMenu.firePopupMenuWillBecomeVisible(JPopupMenu.java:643)
at javax.swing.JPopupMenu.setVisible(JPopupMenu.java:757)
at javax.swing.JPopupMenu.show(JPopupMenu.java:950)
at
com.intellij.openapi.actionSystem.impl.ActionPopupMenuImpl$MyMenu.show(ActionPopupMenuImpl.java:48)
at
jetbrains.fabrique.ide.web.xhtmlView.XhtmlView$XhtmlViewMouseListener.invokePopup(XhtmlView.java:468)
at com.intellij.util.EditorPopupHandler.a(EditorPopupHandler.java:8)
at
com.intellij.util.EditorPopupHandler.mousePressed(EditorPopupHandler.java:6)
at com.intellij.openapi.editor.impl.EditorImpl.a(EditorImpl.java:276)
at
com.intellij.openapi.editor.impl.EditorImpl.access$6000(EditorImpl.java:832)
at
com.intellij.openapi.editor.impl.EditorImpl$MyMouseAdapter.mousePressed(EditorImpl.java:14)
at
java.awt.AWTEventMulticaster.mousePressed(AWTEventMulticaster.java:222)
at java.awt.Component.processMouseEvent(Component.java:5163)
at java.awt.Component.processEvent(Component.java:4963)
at java.awt.Container.processEvent(Container.java:1613)
at java.awt.Component.dispatchEventImpl(Component.java:3681)
at java.awt.Container.dispatchEventImpl(Container.java:1671)
at java.awt.Component.dispatchEvent(Component.java:3543)
at
java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:3527)
at java.awt.LightweightDispatcher.processMouseEvent(Container.java:3239)
at java.awt.LightweightDispatcher.dispatchEvent(Container.java:3172)
at java.awt.Container.dispatchEventImpl(Container.java:1657)
at java.awt.Window.dispatchEventImpl(Window.java:1606)
at java.awt.Component.dispatchEvent(Component.java:3543)
at java.awt.EventQueue.dispatchEvent(EventQueue.java:456)
at
com.intellij.ide.IdeEventQueue.defaultDispatchEvent(IdeEventQueue.java:104)
at com.intellij.ide.IdeEventQueue.a(IdeEventQueue.java:23)
at com.intellij.ide.IdeEventQueue.dispatchEvent(IdeEventQueue.java:111)
at
java.awt.EventDispatchThread.pumpOneEventForHierarchy(EventDispatchThread.java:234)
at
java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:184)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:178)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:170)
at java.awt.EventDispatchThread.run(EventDispatchThread.java:100)



0
Comment actions Permalink


Wow, what an amazingly stupid bug on my part. You would think I would know by now that everything returned by the OpenAPI needs to be checked for null, but evidently not.

Fixed in 1.0.1. Thanks for the report.

--Dave Griffith

0

Please sign in to leave a comment.