[ANN] Rearranger plugin - new version 1.7

The Rearranger plugin:
-- rearranges (reorders) class and class member declarations according to a user-specified order and/or method call hierarchy;
-- generates section-marking comments; and
-- provides several controls for spacing within and between methods and classes.

Version 1.7 contains the following new features:

-- Added ability to exclude certain methods from "extracted-method" analysis and processing. Methods matching a method rule so marked will be moved, but their extracted methods won't.
-- Added new method type "canonical", in addition to existing method types "constructor", "getter/setter" and "other". (Canonical methods are those inherited from java.lang.Object, e.g. equals(), hashCode(), toString().)
-- Made definition of getter and setter methods more flexible. Various criteria based on method name and body are used to determine if a given method is to be considered a getter or setter. A default global definition exists, which (by default) specifies a strict definition. Each rule can specify its own definition to override the default global definition.

Bug fix:

-- Fixed method rule "and overriding" attribute.

-Dave

6 comments
Comment actions Permalink

This is a list of outstanding feature requests I have for the Rearranger plugin. (Putting it here so I won't lose it, and so you can see if yours is on the list -- if not, please reply here.)

- Allow rule matching to be prioritized. For example, given the rulesthe "main" method would match the first rule since it is public, and since it wasn't explicitly excluded from the rule (by adding and whose names do not match "main"). If the second rule was prioritized over the first, the main method would be matched to that rule, and wouldn't be arranged with other public methods matching the first rule.

Display rules in the list sorted by sequence or by priority.

- Group methods by the interface they implement. (Described at http://www.intellij.net/forums/thread.jsp?forum=18&thread=52761&q=#759092.]

- Enhance rearrangement preview to show rules as well as methods that matched the rule. This would simplify debugging; you could determine exactly which rule a method matched by inspecting the tree.

- Rearrange a selection, not entire file.

- Allow conditional execution of rules. See http://www.intellij.net/forums/thread.jsp?forum=18&thread=63427&q=5265617272616e676572#763315. Not clear what the conditions should be, or if this should be applied to each rule, group of rules, and/or entire ruleset (i.e., multiple Rearranger rulesets per project.)

Bugs:

- When generating "extracted method" comments and keeping getters and setters together, "setter" methods are considered to be one level deeper than the corresponding setter, resulting in incorrect generation of "level" comments.

0
Comment actions Permalink

I got this exception in 1094:

java.lang.NullPointerException

at
com.wrq.rearranger.rearrangement.MethodUtil.propertyNameFromMethodTrail(MethodUtil.java:172)

at
com.wrq.rearranger.rearrangement.MethodUtil.isSetter(MethodUtil.java:216)

at
com.wrq.rearranger.rearrangement.Mover$1.rearrangeContents(Mover.java:84)

at
com.wrq.rearranger.rearrangement.GenericRearranger.rearrangeEntries(GenericRearranger.java:97)

at
com.wrq.rearranger.rearrangement.Mover.rearrangeOuterClasses(Mover.java:232)

at
com.wrq.rearranger.RearrangerActionHandler.rearrangeDocument(RearrangerActionHandler.java:120)

at
com.wrq.rearranger.RearrangerActionHandler$rearrangerTask.run(RearrangerActionHandler.java:175)

at com.intellij.openapi.command.impl.a.executeCommand(a.java:6)

at
com.wrq.rearranger.RearrangerActionHandler.runWriteActionRearrangement(RearrangerActionHandler.java:94)

at
com.wrq.rearranger.RearrangerActionHandler$1.run(RearrangerActionHandler.java:65)

at com.intellij.openapi.application.b.b.runWriteAction(b.java:367)

at
com.wrq.rearranger.RearrangerActionHandler.execute(RearrangerActionHandler.java:61)

at
org.intellij.psi.codeStyle.RearrangerUtility$1.psiElementReformatted(RearrangerUtility.java:43)

at
org.intellij.psi.codeStyle.ReformatManager.fireReformatEvent(ReformatManager.java:29)

at
tzambalayev.ideaplugins.reformat.ReformatHandler.fireReformatEvent(ReformatHandler.java:56)

at
tzambalayev.ideaplugins.reformat.ReformatHandler.reformatFile(ReformatHandler.java:68)

at
tzambalayev.ideaplugins.reformat.ReformatAndOptimizeHandler.executeWriteAction(ReformatAndOptimizeHandler.java:15)

at
com.intellij.openapi.editor.actionSystem.EditorWriteActionHandler$1.run(EditorWriteActionHandler.java)

at com.intellij.openapi.application.b.b.runWriteAction(b.java:367)

at
com.intellij.openapi.editor.actionSystem.EditorWriteActionHandler.execute(EditorWriteActionHandler.java:1)

at
com.intellij.openapi.editor.actionSystem.EditorAction$1.run(EditorAction.java)

at com.intellij.openapi.command.impl.a.executeCommand(a.java:86)

at
com.intellij.openapi.editor.actionSystem.EditorAction.actionPerformed(EditorAction.java:24)

at
com.intellij.openapi.editor.actionSystem.EditorAction.actionPerformed(EditorAction.java:10)

at com.intellij.openapi.a.b.d.a(d.java:20)

at com.intellij.openapi.a.b.d.b(d.java:59)

at com.intellij.openapi.a.b.d.a(d.java:38)

at com.intellij.ide.q.a(q.java:115)

at com.intellij.ide.q.dispatchEvent(q.java:68)

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)


Dave Kriewall wrote:

The Rearranger plugin:
-- rearranges (reorders) class and class member declarations according to a user-specified order and/or method call hierarchy;
-- generates section-marking comments; and
-- provides several controls for spacing within and between methods and classes.

Version 1.7 contains the following new features:

-- Added ability to exclude certain methods from "extracted-method" analysis and processing. Methods matching a method rule so marked will be moved, but their extracted methods won't.
-- Added new method type "canonical", in addition to existing method types "constructor", "getter/setter" and "other". (Canonical methods are those inherited from java.lang.Object, e.g. equals(), hashCode(), toString().)
-- Made definition of getter and setter methods more flexible. Various criteria based on method name and body are used to determine if a given method is to be considered a getter or setter. A default global definition exists, which (by default) specifies a strict definition. Each rule can specify its own definition to override the default global definition.

Bug fix:

-- Fixed method rule "and overriding" attribute.

-Dave

0
Comment actions Permalink

That's very odd, Nathan; MethodUtil.java:216 doesn't call propertyNameFromMethodTrail(). And all the callers do check to avoid passing a null parameter.

Could you possibly send me your Rearranger configuration (from /config/options/other.xml, the element ) and the file you were trying to rearrange? Attach them as files to your reply, or if they're sensitive or large, you can email them directly to me at davek ]]> wrq.com.

Thanks for the bug report,
-Dave

0
Comment actions Permalink

I got a similar Exception with 1104, Rearranger 1.7

java.lang.NullPointerException

at com.wrq.rearranger.rearrangement.MethodUtil.propertyNameFromMethodTrail(MethodUtil.java:172)

at com.wrq.rearranger.rearrangement.MethodUtil.isSetter(MethodUtil.java:216)

at com.wrq.rearranger.rearrangement.Mover$1.rearrangeContents(Mover.java:84)

at com.wrq.rearranger.rearrangement.GenericRearranger.rearrangeEntries(GenericRearranger.java:97)

at com.wrq.rearranger.rearrangement.Mover.rearrangeOuterClasses(Mover.java:232)

at com.wrq.rearranger.RearrangerActionHandler.rearrangeDocument(RearrangerActionHandler.java:120)

at com.wrq.rearranger.RearrangerActionHandler$rearrangerTask.run(RearrangerActionHandler.java:175)

at com.intellij.openapi.command.impl.a.executeCommand(a.java:42)

at com.wrq.rearranger.RearrangerActionHandler.runWriteActionRearrangement(RearrangerActionHandler.java:94)

at com.wrq.rearranger.RearrangerActionHandler$1.run(RearrangerActionHandler.java:65)

at com.intellij.openapi.application.a.b.runWriteAction(b.java:162)

at com.wrq.rearranger.RearrangerActionHandler.execute(RearrangerActionHandler.java:61)

at org.intellij.psi.codeStyle.RearrangerUtility$1.psiElementReformatted(RearrangerUtility.java:43)

at org.intellij.psi.codeStyle.ReformatManager.fireReformatEvent(ReformatManager.java:29)

at tzambalayev.ideaplugins.reformat.ReformatHandler.fireReformatEvent(ReformatHandler.java:56)

at tzambalayev.ideaplugins.reformat.ReformatHandler.reformatFile(ReformatHandler.java:68)

at tzambalayev.ideaplugins.reformat.ReformatAndOptimizeHandler.executeWriteAction(ReformatAndOptimizeHandler.java:15)

at com.intellij.openapi.editor.actionSystem.EditorWriteActionHandler$1.run(EditorWriteActionHandler.java)

at com.intellij.openapi.application.a.b.runWriteAction(b.java:162)

at com.intellij.openapi.editor.actionSystem.EditorWriteActionHandler.execute(EditorWriteActionHandler.java:2)

at com.intellij.openapi.editor.actionSystem.EditorAction$1.run(EditorAction.java)

at com.intellij.openapi.command.impl.a.executeCommand(a.java:35)

at com.intellij.openapi.editor.actionSystem.EditorAction.actionPerformed(EditorAction.java:24)

at com.intellij.openapi.editor.actionSystem.EditorAction.actionPerformed(EditorAction.java:10)

at com.intellij.openapi.a.a.d.a(d.java:37)

at com.intellij.openapi.a.a.d.b(d.java:71)

at com.intellij.openapi.a.a.d.a(d.java:13)

at com.intellij.ide.q.a(q.java:97)

at com.intellij.ide.q.dispatchEvent(q.java:114)

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)

0
Comment actions Permalink

Thanks, Alex -- probably the same bug.

I was in the middle of adding a couple new features; if I get them done in a day or two I'll fix this bug and merge it with the new release. If not, I'll post a fix of the current release.

Thanks for your patience,
-Dave

0
Comment actions Permalink

Nathan, Alex,

please give version 1.8 a try and let me know if you still have trouble. I was able to reproduce it in 1.7, but it works fine in version 1.8 even though I changed no relevant code (as far as I can determine).

Thanks,
-Dave

0

Please sign in to leave a comment.